Skip to content

Commit 9a9c4a8

Browse files
committed
Disallow saving items with empty name
And remove associated global setting Closes #210
1 parent 918cdc9 commit 9a9c4a8

File tree

6 files changed

+8
-19
lines changed

6 files changed

+8
-19
lines changed

src/dialogs/item_dialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void ItemDialog::handle_ok(QLineEdit* nameLineEdit, QString initName, QString em
7171
aboutToClose();
7272

7373
QString itemName = nameLineEdit->text();
74-
if (itemName.isEmpty() && !Settings::allowEmptyNames.get()) {
74+
if (itemName.isEmpty()) {
7575
QMessageBox::information(this, emptyNameWindowTitle, emptyNameMessage, QMessageBox::Ok, QMessageBox::Ok);
7676
return;
7777
}

src/settings/settings.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ void Settings::checkForVersionChange()
8282
resetGeometrySettings();
8383
}
8484

85+
// 1.3.0 or older
86+
if (settingsVersionUpTo("1.3.0")) {
87+
// Setting for allowing empty names was removed => clean up
88+
qSettings.remove("allowEmptyNames");
89+
}
90+
8591
// Update settings version
8692
const QString currentAppVersion = getAppVersion();
8793
const QString currentSettingsVersion = appVersion.get();

src/settings/settings.h

-2
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ class Settings {
310310
inline static const Setting<bool> confirmDelete = Setting<bool> ("confirmDelete", true);
311311
/** Ask user for confirmation before discarding changes in an edit dialog. */
312312
inline static const Setting<bool> confirmCancel = Setting<bool> ("confirmCancel", true);
313-
/** Allow user to store items with empty names. */
314-
inline static const Setting<bool> allowEmptyNames = Setting<bool> ("allowEmptyNames", false);
315313
/** Warn user if an item with the same name already exists. */
316314
inline static const Setting<bool> warnAboutDuplicateNames = Setting<bool> ("warnAboutDuplicateNames", true);
317315

src/settings/settings_window.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ void SettingsWindow::loadSettings()
9898

9999
confirmDeleteCheckbox ->setChecked (confirmDelete .get());
100100
confirmCancelCheckbox ->setChecked (confirmCancel .get());
101-
allowEmptyNamesCheckbox ->setChecked (allowEmptyNames .get());
102101
warnAboutDuplicateNamesCheckbox ->setChecked (warnAboutDuplicateNames .get());
103102
onlyPrepareActiveTableCheckbox ->setChecked (onlyPrepareActiveTableOnStartup .get());
104103
openProjectSettingsOnNewDatabaseCheckbox ->setChecked (openProjectSettingsOnNewDatabase .get());
@@ -140,7 +139,6 @@ void SettingsWindow::loadDefaults()
140139

141140
confirmDeleteCheckbox ->setChecked (confirmDelete .getDefault());
142141
confirmCancelCheckbox ->setChecked (confirmCancel .getDefault());
143-
allowEmptyNamesCheckbox ->setChecked (allowEmptyNames .getDefault());
144142
warnAboutDuplicateNamesCheckbox ->setChecked (warnAboutDuplicateNames .getDefault());
145143
onlyPrepareActiveTableCheckbox ->setChecked (onlyPrepareActiveTableOnStartup .getDefault());
146144
openProjectSettingsOnNewDatabaseCheckbox ->setChecked (openProjectSettingsOnNewDatabase .getDefault());
@@ -190,7 +188,6 @@ void SettingsWindow::saveSettings()
190188

191189
confirmDelete .set(confirmDeleteCheckbox ->isChecked());
192190
confirmCancel .set(confirmCancelCheckbox ->isChecked());
193-
allowEmptyNames .set(allowEmptyNamesCheckbox ->isChecked());
194191
warnAboutDuplicateNames .set(warnAboutDuplicateNamesCheckbox ->isChecked());
195192
onlyPrepareActiveTableOnStartup .set(onlyPrepareActiveTableCheckbox ->isChecked());
196193
openProjectSettingsOnNewDatabase .set(openProjectSettingsOnNewDatabaseCheckbox ->isChecked());

src/ui/settings_window.ui

+1-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>400</width>
10-
<height>895</height>
10+
<height>868</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -157,13 +157,6 @@
157157
</property>
158158
</widget>
159159
</item>
160-
<item>
161-
<widget class="QCheckBox" name="allowEmptyNamesCheckbox">
162-
<property name="text">
163-
<string>Allow saving when item name is empty</string>
164-
</property>
165-
</widget>
166-
</item>
167160
<item>
168161
<widget class="QCheckBox" name="warnAboutDuplicateNamesCheckbox">
169162
<property name="text">

translation/de.ts

-5
Original file line numberDiff line numberDiff line change
@@ -3135,11 +3135,6 @@ Trotzdem speichern?</translation>
31353135
<source>Ask for confirmation before discarding unsaved changes</source>
31363136
<translation>Vor dem Verwerfen ungesicherter Änderungen nachfragen</translation>
31373137
</message>
3138-
<message>
3139-
<location filename="../src/ui/settings_window.ui" line="163"/>
3140-
<source>Allow saving when item name is empty</source>
3141-
<translation>Speichern von Einträgen ohne Name erlauben</translation>
3142-
</message>
31433138
<message>
31443139
<location filename="../src/ui/settings_window.ui" line="170"/>
31453140
<source>Warn when saving an item with a duplicate name</source>

0 commit comments

Comments
 (0)