enable/disable the tray icon when pref is changed (no restart needed)

This commit is contained in:
Jean-Francois Dockes 2019-03-06 12:00:18 +01:00
parent 4e711e1901
commit 2e4f4d7702
3 changed files with 18 additions and 8 deletions

View File

@ -449,13 +449,7 @@ void RclMain::init()
emit sortDataChanged(m_sortspec); emit sortDataChanged(m_sortspec);
} }
if (prefs.showTrayIcon && QSystemTrayIcon::isSystemTrayAvailable()) { enableTrayIcon(prefs.showTrayIcon);
m_trayicon = new RclTrayIcon(this,
QIcon(QString(":/images/recoll.png")));
m_trayicon->show();
} else {
m_trayicon = 0;
}
fileRebuildIndexAction->setEnabled(false); fileRebuildIndexAction->setEnabled(false);
fileToggleIndexingAction->setEnabled(false); fileToggleIndexingAction->setEnabled(false);
@ -465,6 +459,21 @@ void RclMain::init()
periodictimer->start(1000); periodictimer->start(1000);
} }
void RclMain::enableTrayIcon(bool on)
{
on = on && QSystemTrayIcon::isSystemTrayAvailable();
if (on) {
if (nullptr == m_trayicon) {
m_trayicon = new RclTrayIcon(this,
QIcon(QString(":/images/recoll.png")));
}
m_trayicon->show();
} else {
delete m_trayicon;
m_trayicon = 0;
}
}
void RclMain::setSynEnabled(bool on) void RclMain::setSynEnabled(bool on)
{ {
prefs.synFileEnable = on; prefs.synFileEnable = on;

View File

@ -90,7 +90,7 @@ public:
IndexerState indexerState() const { IndexerState indexerState() const {
return m_indexerState; return m_indexerState;
} }
void enableTrayIcon(bool onoff);
public slots: public slots:
virtual void fileExit(); virtual void fileExit();

View File

@ -315,6 +315,7 @@ void UIPrefsDialog::accept()
prefs.keepSort = keepSortCB->isChecked(); prefs.keepSort = keepSortCB->isChecked();
prefs.showTrayIcon = showTrayIconCB->isChecked(); prefs.showTrayIcon = showTrayIconCB->isChecked();
m_mainWindow->enableTrayIcon(prefs.showTrayIcon);
prefs.closeToTray = closeToTrayCB->isChecked(); prefs.closeToTray = closeToTrayCB->isChecked();
prefs.showTempFileWarning = showTempFileWarningCB->isChecked() ? prefs.showTempFileWarning = showTempFileWarningCB->isChecked() ?
-1 : 1024; -1 : 1024;