BehaviourSettingsPage: Use QSystemTrayIcon::isSystemTrayAvailable directly

This commit is contained in:
Jonas Kvinge 2023-08-26 21:21:31 +02:00
parent 02ef65bcfd
commit 50c5283599
2 changed files with 5 additions and 9 deletions

View File

@ -58,14 +58,11 @@ bool LocaleAwareCompare(const QString &a, const QString &b) {
BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *parent) BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *parent)
: SettingsPage(dialog, parent), : SettingsPage(dialog, parent),
ui_(new Ui_BehaviourSettingsPage), ui_(new Ui_BehaviourSettingsPage) {
systemtray_available_(false) {
ui_->setupUi(this); ui_->setupUi(this);
setWindowIcon(IconLoader::Load("strawberry", true, 0, 32)); setWindowIcon(IconLoader::Load("strawberry", true, 0, 32));
systemtray_available_ = QSystemTrayIcon::isSystemTrayAvailable();
QObject::connect(ui_->checkbox_showtrayicon, &QCheckBox::toggled, this, &BehaviourSettingsPage::ShowTrayIconToggled); QObject::connect(ui_->checkbox_showtrayicon, &QCheckBox::toggled, this, &BehaviourSettingsPage::ShowTrayIconToggled);
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
@ -147,7 +144,7 @@ void BehaviourSettingsPage::Load() {
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
#ifndef Q_OS_MACOS #ifndef Q_OS_MACOS
if (systemtray_available_) { if (QSystemTrayIcon::isSystemTrayAvailable()) {
ui_->checkbox_showtrayicon->setEnabled(true); ui_->checkbox_showtrayicon->setEnabled(true);
ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool()); ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool());
ui_->radiobutton_hide->setEnabled(true); ui_->radiobutton_hide->setEnabled(true);
@ -160,8 +157,8 @@ void BehaviourSettingsPage::Load() {
} }
#endif #endif
if (systemtray_available_) { if (QSystemTrayIcon::isSystemTrayAvailable()) {
ui_->checkbox_keeprunning->setEnabled(true); ui_->checkbox_keeprunning->setEnabled(ui_->checkbox_showtrayicon->isChecked());
ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool()); ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool());
ui_->checkbox_trayicon_progress->setEnabled(true); ui_->checkbox_trayicon_progress->setEnabled(true);
ui_->checkbox_trayicon_progress->setChecked(s.value("trayicon_progress", false).toBool()); ui_->checkbox_trayicon_progress->setChecked(s.value("trayicon_progress", false).toBool());
@ -189,7 +186,7 @@ void BehaviourSettingsPage::Load() {
ui_->radiobutton_show_minimized->setChecked(true); ui_->radiobutton_show_minimized->setChecked(true);
break; break;
case StartupBehaviour::Hide: case StartupBehaviour::Hide:
if (systemtray_available_) { if (QSystemTrayIcon::isSystemTrayAvailable()) {
ui_->radiobutton_hide->setChecked(true); ui_->radiobutton_hide->setChecked(true);
break; break;
} }

View File

@ -83,7 +83,6 @@ class BehaviourSettingsPage : public SettingsPage {
private: private:
Ui_BehaviourSettingsPage *ui_; Ui_BehaviourSettingsPage *ui_;
QMap<QString, QString> language_map_; QMap<QString, QString> language_map_;
bool systemtray_available_;
}; };
#endif // BEHAVIOURSETTINGSPAGE_H #endif // BEHAVIOURSETTINGSPAGE_H