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);
}
if (prefs.showTrayIcon && QSystemTrayIcon::isSystemTrayAvailable()) {
m_trayicon = new RclTrayIcon(this,
QIcon(QString(":/images/recoll.png")));
m_trayicon->show();
} else {
m_trayicon = 0;
}
enableTrayIcon(prefs.showTrayIcon);
fileRebuildIndexAction->setEnabled(false);
fileToggleIndexingAction->setEnabled(false);
@ -465,6 +459,21 @@ void RclMain::init()
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)
{
prefs.synFileEnable = on;

View File

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

View File

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