summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-10-07 07:41:13 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-10-07 07:41:13 -0400
commitb4f5c17898317720662fc15a7828b68b2e81d950 (patch)
tree5e18ea26e342f2b7b72f090c443fab226bad4ef5 /src
parent94b40b328b7e455ad4799b98c2b00cd5d96f86f3 (diff)
disallow empty titles
Diffstat (limited to 'src')
-rw-r--r--src/editexecutablesdialog.cpp27
-rw-r--r--src/editexecutablesdialog.h5
2 files changed, 26 insertions, 6 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index 0d6367b8..5c4ee149 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -222,6 +222,7 @@ void EditExecutablesDialog::updateUI(
{
// the ui is currently being set, ignore changes
m_settingUI = true;
+ Guard g([&]{ m_settingUI = false; });
if (e) {
setEdits(*e);
@@ -230,9 +231,6 @@ void EditExecutablesDialog::updateUI(
}
setButtons(item, e);
-
- // any changes from now on are from the user
- m_settingUI = false;
}
void EditExecutablesDialog::setButtons(
@@ -274,6 +272,8 @@ void EditExecutablesDialog::clearEdits()
ui->configureLibraries->setEnabled(false);
ui->useApplicationIcon->setEnabled(false);
ui->useApplicationIcon->setChecked(false);
+
+ m_lastGoodTitle = "";
}
void EditExecutablesDialog::setEdits(const Executable& e)
@@ -287,6 +287,8 @@ void EditExecutablesDialog::setEdits(const Executable& e)
ui->steamAppID->setText(e.steamAppID());
ui->useApplicationIcon->setChecked(e.usesOwnIcon());
+ m_lastGoodTitle = e.title();
+
{
int modIndex = -1;
@@ -559,6 +561,13 @@ void EditExecutablesDialog::on_title_textChanged(const QString& s)
return;
}
+ // don't allow empty names
+ if (s.trimmed().isEmpty()) {
+ return;
+ }
+
+ m_lastGoodTitle = s;
+
// must save before modifying the item in the list widget because saving
// relies on the item's text being the same as an item in m_executablesList
save();
@@ -570,6 +579,13 @@ void EditExecutablesDialog::on_title_textChanged(const QString& s)
}
}
+void EditExecutablesDialog::on_title_editingFinished()
+{
+ if (ui->title->text().trimmed().isEmpty()) {
+ ui->title->setText(m_lastGoodTitle);
+ }
+}
+
void EditExecutablesDialog::on_overwriteSteamAppID_toggled(bool checked)
{
if (m_settingUI) {
@@ -619,9 +635,8 @@ void EditExecutablesDialog::on_browseBinary_clicked()
ui->binary->setText(QDir::toNativeSeparators(binaryName));
}
- // setting title if currently empty or some variation of "New Executable"
- if (ui->title->text().isEmpty() ||
- ui->title->text().startsWith(tr("New Executable"), Qt::CaseInsensitive)) {
+ // setting title if some variation of "New Executable"
+ if (ui->title->text().startsWith(tr("New Executable"), Qt::CaseInsensitive)) {
const auto prefix = QFileInfo(binaryName).baseName();
const auto newTitle = m_executablesList.makeNonConflictingTitle(prefix);
diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h
index 494f0651..9e39b115 100644
--- a/src/editexecutablesdialog.h
+++ b/src/editexecutablesdialog.h
@@ -169,6 +169,7 @@ private slots:
void on_down_clicked();
void on_title_textChanged(const QString& s);
+ void on_title_editingFinished();
void on_overwriteSteamAppID_toggled(bool checked);
void on_createFilesInMod_toggled(bool checked);
void on_forceLoadLibraries_toggled(bool checked);
@@ -196,6 +197,10 @@ private:
// forced libraries set in the dialog
ForcedLibraries m_forcedLibraries;
+ // remembers the last executable title that made sense, reverts to this when
+ // the widget loses focus if it's empty
+ QString m_lastGoodTitle;
+
// true when the change events being triggered are in response to loading
// the executable's data into the UI, not from a user change
bool m_settingUI;