diff --git a/src/core/defs.h.in b/src/core/defs.h.in
index 04ec38b07..6f9ee957c 100755
--- a/src/core/defs.h.in
+++ b/src/core/defs.h.in
@@ -61,6 +61,7 @@
#define AUTO_UPDATE_INTERVAL 60000
#define STARTUP_UPDATE_DELAY 1500
#define TIMEZONE_OFFSET_LIMIT 6
+#define CHANGE_EVENT_DELAY 250
#define APP_DB_TEST_MYSQL "MySQLTest"
#define APP_DB_MYSQL_PORT 3306
diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp
index 542d9c6d2..2d0614c3c 100755
--- a/src/gui/formmain.cpp
+++ b/src/gui/formmain.cpp
@@ -137,12 +137,8 @@ void FormMain::prepareMenus() {
m_trayMenu = new QMenu(APP_NAME, this);
#endif
- // Add "check for updates" item on some platforms.
- m_ui->m_actionCheckForUpdates->setIcon(IconThemeFactory::instance()->fromTheme("check-for-updates"));
- m_ui->m_actionCheckForUpdates->setToolTip(tr("Check if new update for the application is available for download."));
-
// Add needed items to the menu.
- m_trayMenu->addAction(m_ui->m_actionSwitchMainWindowTray);
+ m_trayMenu->addAction(m_ui->m_actionSwitchMainWindow);
m_trayMenu->addSeparator();
m_trayMenu->addAction(m_ui->m_actionUpdateAllFeeds);
m_trayMenu->addAction(m_ui->m_actionMarkAllFeedsRead);
@@ -187,12 +183,27 @@ void FormMain::switchMainMenu() {
m_ui->m_menuBar->setVisible(m_ui->m_actionSwitchMainMenu->isChecked());
}
-void FormMain::switchVisibility() {
- if (isVisible()) {
- hide();
+void FormMain::switchVisibility(bool force_hide) {
+ // TODO: Kdyz neni povolena tray ikona, tak je povolena satle polozka "switch window" v menu.
+ // v pripade ze tedy neni povolena tray ikona, tak polozku switch bud disabnout
+ // nebo upravit jeji chovani aby provedla minimalizaci a ne hide.
+ // aktualne nastaveno na tu minimalizaci
+ if (force_hide || isVisible()) {
+ if (SystemTrayIcon::isSystemTrayActivated()) {
+ hide();
+ }
+ else {
+ setWindowState(windowState() & Qt::WindowMinimized);
+ }
+ m_ui->m_actionSwitchMainWindow->blockSignals(true);
+ m_ui->m_actionSwitchMainWindow->setChecked(false);
+ m_ui->m_actionSwitchMainWindow->blockSignals(false);
}
else {
display();
+ m_ui->m_actionSwitchMainWindow->blockSignals(true);
+ m_ui->m_actionSwitchMainWindow->setChecked(true);
+ m_ui->m_actionSwitchMainWindow->blockSignals(false);
}
}
@@ -262,6 +273,7 @@ void FormMain::setupIcons() {
m_ui->m_actionSettings->setIcon(icon_theme_factory->fromTheme("application-settings"));
m_ui->m_actionQuit->setIcon(icon_theme_factory->fromTheme("application-exit"));
m_ui->m_actionAboutGuard->setIcon(icon_theme_factory->fromTheme("application-about"));
+ m_ui->m_actionCheckForUpdates->setIcon(IconThemeFactory::instance()->fromTheme("check-for-updates"));
m_ui->m_actionDefragmentDatabase->setIcon(icon_theme_factory->fromTheme("defragment-database"));
// View.
@@ -372,8 +384,8 @@ void FormMain::createConnections() {
// Menu "View" connections.
connect(m_ui->m_actionFullscreen, SIGNAL(toggled(bool)), this, SLOT(switchFullscreenMode()));
- connect(m_ui->m_actionSwitchMainWindow, SIGNAL(triggered()), this, SLOT(switchVisibility()));
connect(m_ui->m_actionSwitchMainMenu, SIGNAL(toggled(bool)), this, SLOT(switchMainMenu()));
+ connect(m_ui->m_actionSwitchMainWindow, SIGNAL(toggled(bool)), this, SLOT(switchVisibility()));
// Menu "Tools" connections.
connect(m_ui->m_actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
@@ -431,7 +443,8 @@ void FormMain::changeEvent(QEvent *event) {
Settings::instance()->value(APP_CFG_GUI,
"hide_when_minimized",
false).toBool()) {
- QTimer::singleShot(250, this, SLOT(hide()));
+ event->ignore();
+ QTimer::singleShot(CHANGE_EVENT_DELAY, this, SLOT(switchVisibility()));
}
break;
diff --git a/src/gui/formmain.h b/src/gui/formmain.h
index 12ba17d6d..e87696ff9 100644
--- a/src/gui/formmain.h
+++ b/src/gui/formmain.h
@@ -90,7 +90,7 @@ class FormMain : public QMainWindow {
void display();
// Switches visibility of main window.
- void switchVisibility();
+ void switchVisibility(bool force_hide = false);
// Turns on/off fullscreen mode
void switchFullscreenMode();
diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui
index 66771a84c..9bb3ffcce 100644
--- a/src/gui/formmain.ui
+++ b/src/gui/formmain.ui
@@ -371,7 +371,7 @@
true
- false
+ true
Main &window
@@ -450,7 +450,7 @@
Check for &updates
- Check if new application updates are available.
+ Check if new update for the application is available for download.
@@ -494,17 +494,6 @@
Auto-load &images
-
-
- true
-
-
- Switch visibility of main &window
-
-
- Hides main window if it is visible and shows it if it is hidden.
-
-
diff --git a/src/main.cpp b/src/main.cpp
index c914518ff..c56659056 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -115,7 +115,7 @@ int main(int argc, char *argv[]) {
false).toBool() &&
SystemTrayIcon::isSystemTrayActivated()) {
qDebug("Hiding the main window when the application is starting.");
- main_window.hide();
+ main_window.switchVisibility(true);
}
else {
qDebug("Showing the main window when the application is starting.");