Skip to content

Commit 04d53c6

Browse files
author
SeongTae Jeong
authored
User can disable 'Save Project' dialog (#2420)
* Add new checkbox in Preferences * Update PreferencesDialog.cpp for new checkbox * Add default value for new setting. * Update MainWindow.cpp for handle new checkbox * Update Korean translation for this branch * Correct the label text clearly and add hints
1 parent f99f128 commit 04d53c6

5 files changed

Lines changed: 267 additions & 233 deletions

File tree

src/MainWindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,9 +1921,10 @@ void MainWindow::logSql(const QString& sql, int msgtype)
19211921
bool MainWindow::askSaveSqlTab(int index, bool& ignoreUnattachedBuffers)
19221922
{
19231923
SqlExecutionArea* sqlExecArea = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(index));
1924+
const bool isPromptSQLTabsInNewProject = Settings::getValue("General", "promptsqltabsinnewproject").toBool();
19241925

19251926
if(sqlExecArea->getEditor()->isModified()) {
1926-
if(sqlExecArea->fileName().isEmpty() && !ignoreUnattachedBuffers) {
1927+
if(sqlExecArea->fileName().isEmpty() && !ignoreUnattachedBuffers && isPromptSQLTabsInNewProject) {
19271928
// Once the project is saved, remaining SQL tabs will not be modified, so this is only expected to be asked once.
19281929
QString message = currentProjectFilename.isEmpty() ?
19291930
tr("Do you want to save the changes made to SQL tabs in a new project file?") :

src/PreferencesDialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ void PreferencesDialog::loadSettings()
8080
ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(Settings::getValue("db", "defaultencoding").toString(), Qt::MatchFixedString));
8181
ui->comboDefaultLocation->setCurrentIndex(Settings::getValue("db", "savedefaultlocation").toInt());
8282
ui->locationEdit->setText(QDir::toNativeSeparators(Settings::getValue("db", "defaultlocation").toString()));
83+
ui->checkPromptSQLTabsInNewProject->setChecked(Settings::getValue("General", "promptsqltabsinnewproject").toBool());
8384
ui->checkUpdates->setChecked(Settings::getValue("checkversion", "enabled").toBool());
8485

8586
ui->checkHideSchemaLinebreaks->setChecked(Settings::getValue("db", "hideschemalinebreaks").toBool());
@@ -343,6 +344,7 @@ void PreferencesDialog::saveSettings(bool accept)
343344
Settings::setValue("General", "DBFileExtensions", m_dbFileExtensions.join(";;") );
344345
Settings::setValue("General", "fontsize", ui->spinGeneralFontSize->value());
345346
Settings::setValue("General", "maxRecentFiles", ui->spinMaxRecentFiles->value());
347+
Settings::setValue("General", "promptsqltabsinnewproject", ui->checkPromptSQLTabsInNewProject->isChecked());
346348

347349
m_proxyDialog->saveSettings();
348350

src/PreferencesDialog.ui

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@
332332
</item>
333333
</widget>
334334
</item>
335-
<item row="12" column="0">
335+
<item row="13" column="0">
336336
<widget class="QLabel" name="labelUseRemotes">
337337
<property name="text">
338338
<string>Show remote options</string>
@@ -342,7 +342,7 @@
342342
</property>
343343
</widget>
344344
</item>
345-
<item row="12" column="1">
345+
<item row="13" column="1">
346346
<widget class="QCheckBox" name="checkUseRemotes">
347347
<property name="text">
348348
<string>enabled</string>
@@ -352,7 +352,7 @@
352352
</property>
353353
</widget>
354354
</item>
355-
<item row="13" column="0">
355+
<item row="14" column="0">
356356
<widget class="QLabel" name="labelUpdates">
357357
<property name="text">
358358
<string>Automatic &amp;updates</string>
@@ -362,14 +362,14 @@
362362
</property>
363363
</widget>
364364
</item>
365-
<item row="13" column="1">
365+
<item row="14" column="1">
366366
<widget class="QCheckBox" name="checkUpdates">
367367
<property name="text">
368368
<string>enabled</string>
369369
</property>
370370
</widget>
371371
</item>
372-
<item row="14" column="0">
372+
<item row="15" column="0">
373373
<widget class="QLabel" name="label_16">
374374
<property name="text">
375375
<string>DB file extensions</string>
@@ -379,7 +379,7 @@
379379
</property>
380380
</widget>
381381
</item>
382-
<item row="14" column="1">
382+
<item row="15" column="1">
383383
<widget class="QPushButton" name="buttonManageFileExtension">
384384
<property name="text">
385385
<string>Manage</string>
@@ -582,6 +582,27 @@
582582
</property>
583583
</widget>
584584
</item>
585+
<item row="12" column="0">
586+
<widget class="QLabel" name="labelPromptSQLTabsInNewProject">
587+
<property name="text">
588+
<string>Prompt to save SQL tabs
589+
in new project file</string>
590+
</property>
591+
</widget>
592+
</item>
593+
<item row="12" column="1">
594+
<widget class="QCheckBox" name="checkPromptSQLTabsInNewProject">
595+
<property name="toolTip">
596+
<string>If this is turned on, then changes to the SQL editor generate a save a project confirmation dialog when closing the SQL editor tab.</string>
597+
</property>
598+
<property name="text">
599+
<string>enabled</string>
600+
</property>
601+
<property name="checked">
602+
<bool>true</bool>
603+
</property>
604+
</widget>
605+
</item>
585606
</layout>
586607
</widget>
587608
<widget class="QWidget" name="tab">

src/Settings.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string&
268268
if(group == "General" && name == "fontsize")
269269
return m_defaultFontSize;
270270

271+
// General/promptsqltabsinnewproject
272+
if(group == "General" && name == "promptsqltabsinnewproject")
273+
return true;
274+
271275
// checkversion group?
272276
if(group == "checkversion")
273277
{

0 commit comments

Comments
 (0)