From 9bee11c5b8e2d4f5845036019918acc38b87c746 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 10 Jun 2017 20:19:22 +0200 Subject: Added new profile button --- src/forms/profilesdialog.cpp | 28 +++++++++++++++++---- src/forms/profilesdialog.h | 4 ++- src/forms/profilesdialog.ui | 60 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 78 insertions(+), 14 deletions(-) (limited to 'src') 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 #include +#include +#include +#include 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 @@ - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + New + + + + + + + false + + + Clone + + + + + + + false + + + Delete + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + -- cgit v1.2.1