summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-16 22:29:33 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-16 22:29:33 +0200
commit5334c76b834cf7effa21849fff1b0c57cdedb62a (patch)
tree3075144929485759be92a1f65f56675bf4deeb86 /gui
parent7586930b5388d4debf9d2b463aa8275a56690afb (diff)
gui, logic: add separate option for starting in tray vs tray enabled
Suggested-by: @MathijsG, #454
Diffstat (limited to 'gui')
-rw-r--r--gui/main-window.cpp16
-rw-r--r--gui/main-window.hpp1
-rw-r--r--gui/main.cpp2
-rw-r--r--gui/options-dialog.cpp1
-rw-r--r--gui/options-dialog.ui28
5 files changed, 38 insertions, 10 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp
index 89235720..0f070cc4 100644
--- a/gui/main-window.cpp
+++ b/gui/main-window.cpp
@@ -687,13 +687,16 @@ void MainWindow::ensure_tray()
}
else
{
- if (isHidden())
+ const bool is_hidden = isHidden() || !isVisible();
+
+ if (is_hidden)
+ {
show();
- if (!isVisible())
setVisible(true);
- raise(); // for OSX
- activateWindow(); // for Windows
+ raise(); // for OSX
+ activateWindow(); // for Windows
+ }
if (tray)
tray->hide();
@@ -824,6 +827,11 @@ bool MainWindow::is_tray_enabled()
return s.tray_enabled && QSystemTrayIcon::isSystemTrayAvailable();
}
+bool MainWindow::start_in_tray()
+{
+ return s.tray_enabled && s.tray_start && QSystemTrayIcon::isSystemTrayAvailable();
+}
+
void MainWindow::set_profile_in_registry(const QString &profile)
{
QSettings settings(OPENTRACK_ORG);
diff --git a/gui/main-window.hpp b/gui/main-window.hpp
index b33b22fe..0dfc0259 100644
--- a/gui/main-window.hpp
+++ b/gui/main-window.hpp
@@ -132,4 +132,5 @@ public:
bool maybe_die_on_config_not_writable(const QString& current, QStringList* ini_list);
void die_on_config_not_writable();
bool is_tray_enabled();
+ bool start_in_tray();
};
diff --git a/gui/main.cpp b/gui/main.cpp
index 47999212..763f1cb5 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -144,7 +144,7 @@ main(int argc, char** argv)
if (!w->isEnabled())
break;
- if (!w->is_tray_enabled())
+ if (!w->start_in_tray())
{
w->setVisible(true);
w->show();
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index c7ecfe08..be846b35 100644
--- a/gui/options-dialog.cpp
+++ b/gui/options-dialog.cpp
@@ -40,6 +40,7 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) :
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
tie_setting(main.tray_enabled, ui.trayp);
+ tie_setting(main.tray_start, ui.tray_start);
tie_setting(main.center_at_startup, ui.center_at_startup);
diff --git a/gui/options-dialog.ui b/gui/options-dialog.ui
index 74b448c7..35d6e7e0 100644
--- a/gui/options-dialog.ui
+++ b/gui/options-dialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>546</width>
- <height>622</height>
+ <height>594</height>
</rect>
</property>
<property name="windowTitle">
@@ -316,10 +316,29 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="trayp">
- <property name="text">
+ <widget class="QGroupBox" name="groupBox_11">
+ <property name="title">
<string>Minimize to tray</string>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="trayp">
+ <property name="text">
+ <string>Enable</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tray_start">
+ <property name="text">
+ <string>Start in tray when enabled</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
@@ -332,7 +351,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>20</width>
+ <width>0</width>
<height>0</height>
</size>
</property>
@@ -1355,7 +1374,6 @@ It won't work properly with translation compensation enabled.</string>
<tabstop>bind_restart_tracking</tabstop>
<tabstop>bind_tcomp_off_held</tabstop>
<tabstop>center_at_startup</tabstop>
- <tabstop>trayp</tabstop>
<tabstop>camera_yaw</tabstop>
<tabstop>camera_pitch</tabstop>
<tabstop>camera_roll</tabstop>