aboutsummaryrefslogtreecommitdiff
path: root/src/forms/profilesdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/forms/profilesdialog.cpp')
-rw-r--r--src/forms/profilesdialog.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/forms/profilesdialog.cpp b/src/forms/profilesdialog.cpp
index ed4c871..34bd063 100644
--- a/src/forms/profilesdialog.cpp
+++ b/src/forms/profilesdialog.cpp
@@ -24,6 +24,9 @@
#include "browser.h"
#include <QListWidget>
#include <QHBoxLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
+#include <QInputDialog>
ProfilesDialog::ProfilesDialog(MainWindow *window, QWidget *parent) :
QDialog(parent),
@@ -34,8 +37,8 @@ ProfilesDialog::ProfilesDialog(MainWindow *window, QWidget *parent) :
m_view = new ProfileView(0, this);
// Hide the profile view because we're fancy
- // Give focus to the widget because otherwise the listwidget gains focus
- // this causes it to select the first item in it, which in turn triggers the signal
+ // Give focus to the top widget because otherwise the listwidget gains focus
+ // which causes it to select the first item in it, which in turn triggers the signal
// and so the profile view gets shown even though the user hasn't selected anything
// and so we get to be less fancy, defeating the point of the exercise
// [on linux; other OS's not checked]
@@ -44,9 +47,13 @@ ProfilesDialog::ProfilesDialog(MainWindow *window, QWidget *parent) :
ui->setupUi(this);
ui->horizontalLayout->addWidget(m_view);
+ ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Load"));
connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(viewProfile(int)));
+ connect(ui->new_toolButton, SIGNAL(released()), this, SLOT(newProfile()));
connect(this, SIGNAL(accepted()), this, SLOT(loadSelectedProfile()));
+
+ loadProfiles();
}
ProfilesDialog::~ProfilesDialog()
@@ -54,14 +61,25 @@ ProfilesDialog::~ProfilesDialog()
delete ui;
}
-int ProfilesDialog::exec()
+void ProfilesDialog::loadProfiles()
{
- qDebug("Showing...");
+ ui->listWidget->clear();
+
for(QString name : qApp->profiles()) {
QListWidgetItem *item = new QListWidgetItem(qApp->profile(name)->name(), ui->listWidget);
item->setData(Qt::UserRole, name);
}
- return QDialog::exec();
+}
+
+void ProfilesDialog::newProfile()
+{
+ bool ok;
+ QString name = QInputDialog::getText(this, tr("Profile Name"), tr("Profile Name:"), QLineEdit::Normal, tr("Default"), &ok);
+
+ if(ok) {
+ qApp->profile(name);
+ loadProfiles();
+ }
}
void ProfilesDialog::loadSelectedProfile()