From e4fafb911ad97686b23f9fd45d2734a022890bb8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 9 Jul 2022 01:34:58 +0800 Subject: [PATCH 1/3] Revise behavior of initializing checkboxes The checkboxes initial value should not depend on parent state and should be restored anyway. --- src/gui/optionsdialog.cpp | 36 ++++++------------------------------ src/gui/optionsdialog.h | 5 ----- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 618d880af..f57c080bf 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -675,10 +675,10 @@ void OptionsDialog::saveOptions() pref->setHideZeroValues(m_ui->checkHideZero->isChecked()); pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex()); #ifndef Q_OS_MACOS - pref->setSystemTrayEnabled(systemTrayEnabled()); + pref->setSystemTrayEnabled(m_ui->checkShowSystray->isChecked()); pref->setTrayIconStyle(TrayIcon::Style(m_ui->comboTrayIcon->currentIndex())); - pref->setCloseToTray(closeToTray()); - pref->setMinimizeToTray(minimizeToTray()); + pref->setCloseToTray(m_ui->checkCloseToSystray->isChecked()); + pref->setMinimizeToTray(m_ui->checkMinimizeToSysTray->isChecked()); #endif pref->setStartMinimized(startMinimized()); pref->setSplashScreenDisabled(isSplashScreenDisabled()); @@ -935,12 +935,9 @@ void OptionsDialog::loadOptions() #ifndef Q_OS_MACOS m_ui->checkShowSystray->setChecked(pref->systemTrayEnabled()); - if (m_ui->checkShowSystray->isChecked()) - { - m_ui->checkMinimizeToSysTray->setChecked(pref->minimizeToTray()); - m_ui->checkCloseToSystray->setChecked(pref->closeToTray()); - m_ui->comboTrayIcon->setCurrentIndex(static_cast(pref->trayIconStyle())); - } + m_ui->checkMinimizeToSysTray->setChecked(pref->minimizeToTray()); + m_ui->checkCloseToSystray->setChecked(pref->closeToTray()); + m_ui->comboTrayIcon->setCurrentIndex(static_cast(pref->trayIconStyle())); #endif m_ui->checkPreventFromSuspendWhenDownloading->setChecked(pref->preventFromSuspendWhenDownloading()); @@ -1354,27 +1351,6 @@ bool OptionsDialog::startMinimized() const return m_ui->checkStartMinimized->isChecked(); } -#ifndef Q_OS_MACOS -bool OptionsDialog::systemTrayEnabled() const -{ - return QSystemTrayIcon::isSystemTrayAvailable() - ? m_ui->checkShowSystray->isChecked() - : false; -} - -bool OptionsDialog::minimizeToTray() const -{ - if (!m_ui->checkShowSystray->isChecked()) return false; - return m_ui->checkMinimizeToSysTray->isChecked(); -} - -bool OptionsDialog::closeToTray() const -{ - if (!m_ui->checkShowSystray->isChecked()) return false; - return m_ui->checkCloseToSystray->isChecked(); -} -#endif // Q_OS_MACOS - // Return Share ratio qreal OptionsDialog::getMaxRatio() const { diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index 32f7ee5bb..b7d820230 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -123,11 +123,6 @@ private: void initializeLanguageCombo(); // General options QString getLocale() const; -#ifndef Q_OS_MACOS - bool systemTrayEnabled() const; - bool minimizeToTray() const; - bool closeToTray() const; -#endif bool startMinimized() const; bool isSplashScreenDisabled() const; #ifdef Q_OS_WIN From e54124fdb8d15990db8588c9be89438f44d31b7d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 9 Jul 2022 01:54:30 +0800 Subject: [PATCH 2/3] Add tooltip message when system tray icon isn't available Also don't hide the sub-options as they are already in disabled state. --- src/gui/optionsdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index f57c080bf..876792958 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -262,6 +262,7 @@ OptionsDialog::OptionsDialog(IGUIApplication *app, QWidget *parent) // Load options loadOptions(); + #ifdef Q_OS_MACOS m_ui->checkShowSystray->setVisible(false); #else @@ -270,8 +271,7 @@ OptionsDialog::OptionsDialog(IGUIApplication *app, QWidget *parent) { m_ui->checkShowSystray->setChecked(false); m_ui->checkShowSystray->setEnabled(false); - m_ui->labelTrayIconStyle->setVisible(false); - m_ui->comboTrayIcon->setVisible(false); + m_ui->checkShowSystray->setToolTip(tr("Disabled due to failed to detect system tray presence")); } #endif From 8d73ab65b20556dde1f973dccd56aa50597eb1fa Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 9 Jul 2022 02:02:15 +0800 Subject: [PATCH 3/3] Don't needlessly hide Options dialog The dialog should only close after all operations are done, not before. --- src/gui/optionsdialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 876792958..804e0a7a9 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -650,8 +650,6 @@ void OptionsDialog::saveOptions() auto *pref = Preferences::instance(); auto *session = BitTorrent::Session::instance(); - m_applyButton->setEnabled(false); - // Load the translation QString locale = getLocale(); if (pref->getLocale() != locale) @@ -1419,8 +1417,8 @@ void OptionsDialog::on_buttonBox_accepted() m_ui->tabSelection->setCurrentRow(TAB_WEBUI); return; } + m_applyButton->setEnabled(false); - this->hide(); saveOptions(); } @@ -1444,6 +1442,8 @@ void OptionsDialog::applySettings() m_ui->tabSelection->setCurrentRow(TAB_WEBUI); return; } + + m_applyButton->setEnabled(false); saveOptions(); }