Some hiding fixes.
This commit is contained in:
parent
6bbedcf703
commit
6d587c0e03
5 changed files with 28 additions and 25 deletions
|
@ -61,6 +61,7 @@
|
||||||
#define AUTO_UPDATE_INTERVAL 60000
|
#define AUTO_UPDATE_INTERVAL 60000
|
||||||
#define STARTUP_UPDATE_DELAY 1500
|
#define STARTUP_UPDATE_DELAY 1500
|
||||||
#define TIMEZONE_OFFSET_LIMIT 6
|
#define TIMEZONE_OFFSET_LIMIT 6
|
||||||
|
#define CHANGE_EVENT_DELAY 250
|
||||||
|
|
||||||
#define APP_DB_TEST_MYSQL "MySQLTest"
|
#define APP_DB_TEST_MYSQL "MySQLTest"
|
||||||
#define APP_DB_MYSQL_PORT 3306
|
#define APP_DB_MYSQL_PORT 3306
|
||||||
|
|
|
@ -137,12 +137,8 @@ void FormMain::prepareMenus() {
|
||||||
m_trayMenu = new QMenu(APP_NAME, this);
|
m_trayMenu = new QMenu(APP_NAME, this);
|
||||||
#endif
|
#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.
|
// 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->addSeparator();
|
||||||
m_trayMenu->addAction(m_ui->m_actionUpdateAllFeeds);
|
m_trayMenu->addAction(m_ui->m_actionUpdateAllFeeds);
|
||||||
m_trayMenu->addAction(m_ui->m_actionMarkAllFeedsRead);
|
m_trayMenu->addAction(m_ui->m_actionMarkAllFeedsRead);
|
||||||
|
@ -187,12 +183,27 @@ void FormMain::switchMainMenu() {
|
||||||
m_ui->m_menuBar->setVisible(m_ui->m_actionSwitchMainMenu->isChecked());
|
m_ui->m_menuBar->setVisible(m_ui->m_actionSwitchMainMenu->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormMain::switchVisibility() {
|
void FormMain::switchVisibility(bool force_hide) {
|
||||||
if (isVisible()) {
|
// 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();
|
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 {
|
else {
|
||||||
display();
|
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_actionSettings->setIcon(icon_theme_factory->fromTheme("application-settings"));
|
||||||
m_ui->m_actionQuit->setIcon(icon_theme_factory->fromTheme("application-exit"));
|
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_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"));
|
m_ui->m_actionDefragmentDatabase->setIcon(icon_theme_factory->fromTheme("defragment-database"));
|
||||||
|
|
||||||
// View.
|
// View.
|
||||||
|
@ -372,8 +384,8 @@ void FormMain::createConnections() {
|
||||||
|
|
||||||
// Menu "View" connections.
|
// Menu "View" connections.
|
||||||
connect(m_ui->m_actionFullscreen, SIGNAL(toggled(bool)), this, SLOT(switchFullscreenMode()));
|
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_actionSwitchMainMenu, SIGNAL(toggled(bool)), this, SLOT(switchMainMenu()));
|
||||||
|
connect(m_ui->m_actionSwitchMainWindow, SIGNAL(toggled(bool)), this, SLOT(switchVisibility()));
|
||||||
|
|
||||||
// Menu "Tools" connections.
|
// Menu "Tools" connections.
|
||||||
connect(m_ui->m_actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
|
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,
|
Settings::instance()->value(APP_CFG_GUI,
|
||||||
"hide_when_minimized",
|
"hide_when_minimized",
|
||||||
false).toBool()) {
|
false).toBool()) {
|
||||||
QTimer::singleShot(250, this, SLOT(hide()));
|
event->ignore();
|
||||||
|
QTimer::singleShot(CHANGE_EVENT_DELAY, this, SLOT(switchVisibility()));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -90,7 +90,7 @@ class FormMain : public QMainWindow {
|
||||||
void display();
|
void display();
|
||||||
|
|
||||||
// Switches visibility of main window.
|
// Switches visibility of main window.
|
||||||
void switchVisibility();
|
void switchVisibility(bool force_hide = false);
|
||||||
|
|
||||||
// Turns on/off fullscreen mode
|
// Turns on/off fullscreen mode
|
||||||
void switchFullscreenMode();
|
void switchFullscreenMode();
|
||||||
|
|
|
@ -371,7 +371,7 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Main &window</string>
|
<string>Main &window</string>
|
||||||
|
@ -450,7 +450,7 @@
|
||||||
<string>Check for &updates</string>
|
<string>Check for &updates</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Check if new application updates are available.</string>
|
<string>Check if new update for the application is available for download.</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="m_actionSwitchMainMenu">
|
<action name="m_actionSwitchMainMenu">
|
||||||
|
@ -494,17 +494,6 @@
|
||||||
<string>Auto-load &images</string>
|
<string>Auto-load &images</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="m_actionSwitchMainWindowTray">
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Switch visibility of main &window</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Hides main window if it is visible and shows it if it is hidden.</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -115,7 +115,7 @@ int main(int argc, char *argv[]) {
|
||||||
false).toBool() &&
|
false).toBool() &&
|
||||||
SystemTrayIcon::isSystemTrayActivated()) {
|
SystemTrayIcon::isSystemTrayActivated()) {
|
||||||
qDebug("Hiding the main window when the application is starting.");
|
qDebug("Hiding the main window when the application is starting.");
|
||||||
main_window.hide();
|
main_window.switchVisibility(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug("Showing the main window when the application is starting.");
|
qDebug("Showing the main window when the application is starting.");
|
||||||
|
|
Loading…
Add table
Reference in a new issue