summaryrefslogtreecommitdiff
path: root/src/profilesdialog.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-12-29 07:29:53 -0500
committerGitHub <noreply@github.com>2020-12-29 07:29:53 -0500
commit1b101bda36ed66d08fa597a8956369c9e0af8519 (patch)
treef8a62cc4ac8fb318ef4e86053e389a3187968940 /src/profilesdialog.cpp
parent4b059fa71f0d5043bfac8e48757c69b11a6168c6 (diff)
parent33a177f1eda90b4d1fff92976635beaa59f85172 (diff)
Merge pull request #1333 from isanae/more-stuff-2
More stuff 2
Diffstat (limited to 'src/profilesdialog.cpp')
-rw-r--r--src/profilesdialog.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp
index 14bf0da5..d71a4531 100644
--- a/src/profilesdialog.cpp
+++ b/src/profilesdialog.cpp
@@ -115,11 +115,29 @@ void ProfilesDialog::showEvent(QShowEvent *event)
}
}
-void ProfilesDialog::on_closeButton_clicked()
+void ProfilesDialog::on_close_clicked()
{
close();
}
+void ProfilesDialog::on_select_clicked()
+{
+ const Profile::Ptr currentProfile = ui->profilesList->currentItem()
+ ->data(Qt::UserRole)
+ .value<Profile::Ptr>();
+
+ if (!currentProfile) {
+ return;
+ }
+
+ m_Selected = currentProfile->name();
+ close();
+}
+
+std::optional<QString> ProfilesDialog::selectedProfile() const
+{
+ return m_Selected;
+}
QListWidgetItem *ProfilesDialog::addItem(const QString &name)
{
@@ -142,6 +160,7 @@ void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings)
newItem->setData(Qt::UserRole, QVariant::fromValue(profile));
ui->profilesList->addItem(newItem);
m_FailState = false;
+ ui->profilesList->setCurrentItem(newItem);
emit profileCreated(profile.get());
} catch (const std::exception&) {
m_FailState = true;
@@ -157,6 +176,7 @@ void ProfilesDialog::createProfile(const QString &name, const Profile &reference
newItem->setData(Qt::UserRole, QVariant::fromValue(profile));
ui->profilesList->addItem(newItem);
m_FailState = false;
+ ui->profilesList->setCurrentItem(newItem);
emit profileCreated(profile.get());
} catch (const std::exception&) {
m_FailState = true;
@@ -250,6 +270,12 @@ void ProfilesDialog::on_renameButton_clicked()
{
Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value<Profile::Ptr>();
+ if (currentProfile->name() == m_ActiveProfileName) {
+ QMessageBox::warning(this, tr("Renaming active profile"),
+ tr("The active profile cannot be renamed. Please change to a different profile first."));
+ return;
+ }
+
bool valid = false;
QString name;
@@ -265,7 +291,7 @@ void ProfilesDialog::on_renameButton_clicked()
}
ui->profilesList->currentItem()->setText(name);
-
+
QString oldName = currentProfile->name();
currentProfile->rename(name);
@@ -342,6 +368,11 @@ void ProfilesDialog::on_profilesList_currentItemChanged(QListWidgetItem *current
}
}
+void ProfilesDialog::on_profilesList_itemActivated(QListWidgetItem* item)
+{
+ on_select_clicked();
+}
+
void ProfilesDialog::on_localSavesBox_stateChanged(int state)
{
Profile::Ptr currentProfile = ui->profilesList->currentItem()->data(Qt::UserRole).value<Profile::Ptr>();