Skip to content

Commit

Permalink
BehaviourSettingsPage: Use QSystemTrayIcon::isSystemTrayAvailable dir…
Browse files Browse the repository at this point in the history
…ectly
  • Loading branch information
jonaski committed Aug 26, 2023
1 parent 02ef65b commit 50c5283
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/settings/behavioursettingspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,11 @@ bool LocaleAwareCompare(const QString &a, const QString &b) {

BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *parent)
: SettingsPage(dialog, parent),
ui_(new Ui_BehaviourSettingsPage),
systemtray_available_(false) {
ui_(new Ui_BehaviourSettingsPage) {

ui_->setupUi(this);
setWindowIcon(IconLoader::Load("strawberry", true, 0, 32));

systemtray_available_ = QSystemTrayIcon::isSystemTrayAvailable();

QObject::connect(ui_->checkbox_showtrayicon, &QCheckBox::toggled, this, &BehaviourSettingsPage::ShowTrayIconToggled);

#ifdef Q_OS_MACOS
Expand Down Expand Up @@ -147,7 +144,7 @@ void BehaviourSettingsPage::Load() {
s.beginGroup(kSettingsGroup);

#ifndef Q_OS_MACOS
if (systemtray_available_) {
if (QSystemTrayIcon::isSystemTrayAvailable()) {
ui_->checkbox_showtrayicon->setEnabled(true);
ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool());
ui_->radiobutton_hide->setEnabled(true);
Expand All @@ -160,8 +157,8 @@ void BehaviourSettingsPage::Load() {
}
#endif

if (systemtray_available_) {
ui_->checkbox_keeprunning->setEnabled(true);
if (QSystemTrayIcon::isSystemTrayAvailable()) {
ui_->checkbox_keeprunning->setEnabled(ui_->checkbox_showtrayicon->isChecked());
ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool());
ui_->checkbox_trayicon_progress->setEnabled(true);
ui_->checkbox_trayicon_progress->setChecked(s.value("trayicon_progress", false).toBool());
Expand Down Expand Up @@ -189,7 +186,7 @@ void BehaviourSettingsPage::Load() {
ui_->radiobutton_show_minimized->setChecked(true);
break;
case StartupBehaviour::Hide:
if (systemtray_available_) {
if (QSystemTrayIcon::isSystemTrayAvailable()) {
ui_->radiobutton_hide->setChecked(true);
break;
}
Expand Down
1 change: 0 additions & 1 deletion src/settings/behavioursettingspage.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class BehaviourSettingsPage : public SettingsPage {
private:
Ui_BehaviourSettingsPage *ui_;
QMap<QString, QString> language_map_;
bool systemtray_available_;
};

#endif // BEHAVIOURSETTINGSPAGE_H

0 comments on commit 50c5283

Please sign in to comment.