diff options
| author | Felix "xq" Queißner <git@masterq32.de> | 2021-11-20 15:16:34 +0100 |
|---|---|---|
| committer | Felix "xq" Queißner <git@masterq32.de> | 2021-11-20 15:16:34 +0100 |
| commit | 6b39f24484bb0796f3f383401f95904f85b74d7b (patch) | |
| tree | e2dcc6c5782e8a45662b8a79d39049205a7de6f8 /src | |
| parent | 9dd660d66e23f02716d4b2bad84ac86764de71a6 (diff) | |
| download | kristall-6b39f24484bb0796f3f383401f95904f85b74d7b.tar.gz | |
Implements #245
Diffstat (limited to 'src')
| -rw-r--r-- | src/dialogs/settingsdialog.cpp | 15 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.hpp | 4 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.ui | 108 | ||||
| -rw-r--r-- | src/kristall.hpp | 1 | ||||
| -rw-r--r-- | src/main.cpp | 4 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 11 | ||||
| -rw-r--r-- | src/mainwindow.hpp | 2 |
7 files changed, 118 insertions, 27 deletions
diff --git a/src/dialogs/settingsdialog.cpp b/src/dialogs/settingsdialog.cpp index 19b0fd9..4921d50 100644 --- a/src/dialogs/settingsdialog.cpp +++ b/src/dialogs/settingsdialog.cpp @@ -396,6 +396,9 @@ void SettingsDialog::setOptions(const GenericSettings &options) break; } } + + this->ui->tab_keep_window->setChecked(!this->current_options.close_window_with_last_tab); + this->ui->tab_close_window->setChecked(this->current_options.close_window_with_last_tab); } std::optional<QLocale> SettingsDialog::locale() const @@ -1032,3 +1035,15 @@ void SettingsDialog::on_selected_language_currentIndexChanged(int index) kristall::globals().localization->translate(QLocale(language_id)); } + +void SettingsDialog::on_tab_keep_window_clicked() +{ + this->current_options.close_window_with_last_tab = false; +} + + +void SettingsDialog::on_tab_close_window_clicked() +{ + this->current_options.close_window_with_last_tab = true; +} + diff --git a/src/dialogs/settingsdialog.hpp b/src/dialogs/settingsdialog.hpp index 9176cea..59b4496 100644 --- a/src/dialogs/settingsdialog.hpp +++ b/src/dialogs/settingsdialog.hpp @@ -184,6 +184,10 @@ private slots: void on_selected_language_currentIndexChanged(int index); + void on_tab_keep_window_clicked(); + + void on_tab_close_window_clicked(); + private: void reloadStylePreview(); diff --git a/src/dialogs/settingsdialog.ui b/src/dialogs/settingsdialog.ui index 45d9787..f8c3510 100644 --- a/src/dialogs/settingsdialog.ui +++ b/src/dialogs/settingsdialog.ui @@ -276,6 +276,37 @@ <item row="0" column="1"> <widget class="QComboBox" name="selected_language"/> </item> + <item row="13" column="0"> + <widget class="QLabel" name="label_45"> + <property name="text"> + <string>Tab close behaviour</string> + </property> + </widget> + </item> + <item row="13" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QRadioButton" name="tab_keep_window"> + <property name="text"> + <string>Keep window open</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup_10</string> + </attribute> + </widget> + </item> + <item> + <widget class="QRadioButton" name="tab_close_window"> + <property name="text"> + <string>Close window</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup_10</string> + </attribute> + </widget> + </item> + </layout> + </item> </layout> </widget> <widget class="QWidget" name="display_tab"> @@ -698,7 +729,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -736,7 +768,8 @@ <string>Set font...</string> </property> <property name="icon"> - <iconset theme="font-select-symbolic"/> + <iconset theme="font-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -746,7 +779,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -777,7 +811,8 @@ <string>Set font...</string> </property> <property name="icon"> - <iconset theme="font-select-symbolic"/> + <iconset theme="font-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -787,7 +822,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -818,7 +854,8 @@ <string>Set font...</string> </property> <property name="icon"> - <iconset theme="font-select-symbolic"/> + <iconset theme="font-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -828,7 +865,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -859,7 +897,8 @@ <string>Set font...</string> </property> <property name="icon"> - <iconset theme="font-select-symbolic"/> + <iconset theme="font-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -869,7 +908,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -906,7 +946,8 @@ <string>Set font...</string> </property> <property name="icon"> - <iconset theme="font-select-symbolic"/> + <iconset theme="font-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -916,7 +957,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -953,7 +995,8 @@ <string>Set font...</string> </property> <property name="icon"> - <iconset theme="font-select-symbolic"/> + <iconset theme="font-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -963,7 +1006,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1036,7 +1080,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1060,7 +1105,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1084,7 +1130,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1394,7 +1441,8 @@ <string>Set color...</string> </property> <property name="icon"> - <iconset theme="color-select-symbolic"/> + <iconset theme="color-select-symbolic"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1430,7 +1478,8 @@ <string>New</string> </property> <property name="icon"> - <iconset theme="document-new"/> + <iconset theme="document-new"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1443,7 +1492,8 @@ <string>Save</string> </property> <property name="icon"> - <iconset theme="document-save"/> + <iconset theme="document-save"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1456,7 +1506,8 @@ <string>Load</string> </property> <property name="icon"> - <iconset theme="folder"/> + <iconset theme="folder"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1472,7 +1523,8 @@ <string>Import</string> </property> <property name="icon"> - <iconset theme="document-import"/> + <iconset theme="document-import"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1485,7 +1537,8 @@ <string>Export</string> </property> <property name="icon"> - <iconset theme="document-export"/> + <iconset theme="document-export"> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -1661,14 +1714,15 @@ </connection> </connections> <buttongroups> - <buttongroup name="buttonGroup_3"/> - <buttongroup name="buttonGroup"/> + <buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_5"/> - <buttongroup name="buttonGroup_4"/> - <buttongroup name="buttonGroup_7"/> + <buttongroup name="buttonGroup"/> <buttongroup name="buttonGroup_6"/> - <buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_8"/> + <buttongroup name="buttonGroup_3"/> + <buttongroup name="buttonGroup_7"/> + <buttongroup name="buttonGroup_4"/> <buttongroup name="buttonGroup_9"/> + <buttongroup name="buttonGroup_10"/> </buttongroups> </ui> diff --git a/src/kristall.hpp b/src/kristall.hpp index 272525b..e24532c 100644 --- a/src/kristall.hpp +++ b/src/kristall.hpp @@ -90,6 +90,7 @@ struct GenericSettings bool fancy_quotes = true; bool emojis_enabled = true; bool strip_nav = false; + bool close_window_with_last_tab = false; AnsiEscRenderMode ansi_escapes = AnsiEscRenderMode::render; // This is set automatically diff --git a/src/main.cpp b/src/main.cpp index a86f2bd..d4f7d7d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -899,6 +899,8 @@ void GenericSettings::load(QSettings &settings) cache_unlimited_life = settings.value("cache_unlimited_life", true).toBool(); session_restore_behaviour = SessionRestoreBehaviour(settings.value("session_restore_behaviour", int(session_restore_behaviour)).toInt()); + + close_window_with_last_tab = settings.value("close_window_with_last_tab", false).toBool(); } void GenericSettings::save(QSettings &settings) const @@ -965,6 +967,8 @@ void GenericSettings::save(QSettings &settings) const } settings.setValue("session_restore_behaviour", int(session_restore_behaviour)); + + settings.setValue("close_window_with_last_tab", close_window_with_last_tab); } void kristall::applySettings() diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d2eeaf8..32f36c8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -146,6 +146,7 @@ BrowserTab * MainWindow::addEmptyTab(bool focus_new, bool load_default) { BrowserTab * tab = new BrowserTab(this); + connect(tab, &BrowserTab::destroyed, this, &MainWindow::on_tab_closed); connect(tab, &BrowserTab::titleChanged, this, &MainWindow::on_tab_titleChanged); connect(tab, &BrowserTab::fileLoaded, this, &MainWindow::on_tab_fileLoaded); connect(tab, &BrowserTab::requestStateChanged, this, &MainWindow::on_tab_requestStateChanged); @@ -366,6 +367,16 @@ void MainWindow::closeEvent(QCloseEvent *event) event->accept(); } +void MainWindow::on_tab_closed() +{ + // If the user wants, we close the window together with the last tab. + // tabCount() might be 1 here, as the tab is still counted as "open" + if(kristall::globals().options.close_window_with_last_tab and (this->tabCount() <= 1)) + { + this->close(); + } +} + void MainWindow::on_browser_tabs_currentChanged(int index) { if(index >= 0) { diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp index 4f482b8..d81583c 100644 --- a/src/mainwindow.hpp +++ b/src/mainwindow.hpp @@ -61,6 +61,8 @@ public: void closeEvent(QCloseEvent *event) override; private slots: + void on_tab_closed(); + void on_browser_tabs_currentChanged(int index); void on_browser_tabs_tabCloseRequested(int index); |
