diff options
-rw-r--r-- | src/forms/profilesdialog.cpp | 28 | ||||
-rw-r--r-- | src/forms/profilesdialog.h | 4 | ||||
-rw-r--r-- | src/forms/profilesdialog.ui | 60 |
3 files changed, 78 insertions, 14 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() diff --git a/src/forms/profilesdialog.h b/src/forms/profilesdialog.h index 302bf82..71226e0 100644 --- a/src/forms/profilesdialog.h +++ b/src/forms/profilesdialog.h @@ -38,7 +38,9 @@ public: ~ProfilesDialog(); public slots: - int exec(); + void loadProfiles(); + + void newProfile(); private slots: void loadSelectedProfile(); diff --git a/src/forms/profilesdialog.ui b/src/forms/profilesdialog.ui index 7675a9d..7a140b5 100644 --- a/src/forms/profilesdialog.ui +++ b/src/forms/profilesdialog.ui @@ -22,14 +22,58 @@ </layout> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> + <layout class="QHBoxLayout" name="buttons_horizontalLayout"> + <item> + <widget class="QToolButton" name="new_toolButton"> + <property name="text"> + <string>New</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="clone_toolButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Clone</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="delete_toolButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Delete</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> |