Update status icon and tooltip when changing settings

Required because the reconnect interval which might be included
in the tooltip might have changed.
This commit is contained in:
Martchus 2019-08-01 19:07:58 +02:00
parent 6057b2cb2c
commit 2363e9a7d4
3 changed files with 10 additions and 4 deletions

View File

@ -415,6 +415,9 @@ void SyncthingApplet::handleSettingsChanged()
m_currentConnectionConfig = -1; // force update
setCurrentConnectionConfigIndex(currentConfig);
// update status icons and tooltip because the reconnect interval might have changed
updateStatusIconAndTooltip();
emit settingsChanged();
}

View File

@ -47,9 +47,6 @@ TrayIcon::TrayIcon(const QString &connectionConfig, QObject *parent)
const auto &connection(widget.connection());
const auto &notifier(widget.notifier());
// update status icon and text so the icon is immediately visible also when the connection isn't
updateStatusIconAndText();
// set context menu
#ifndef SYNCTHINGTRAY_UNIFY_TRAY_MENUS
connect(m_contextMenu.addAction(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-default.svg")), tr("Open Syncthing")),
@ -108,7 +105,8 @@ TrayIcon::TrayIcon(const QString &connectionConfig, QObject *parent)
#endif
// apply settings, this also establishes the connection to Syncthing (according to settings)
// note: it is important to apply settings after all Signals & Slots have been connected (eg. to handle SyncthingConnection::error())
// note: It is important to apply settings only after all Signals & Slots have been connected (eg. to handle SyncthingConnection::error()).
// note: This weirdly call updateStatusIconAndText(). So there is not need to call it again within this constructor.
trayMenu().widget().applySettings(connectionConfig);
}

View File

@ -473,6 +473,11 @@ void TrayWidget::applySettings(const QString &connectionConfig)
m_dlModel.setBrightColors(settings.appearance.brightTextColors);
IconManager::instance().applySettings(&settings.icons.status, settings.icons.distinguishTrayIcons ? &settings.icons.tray : nullptr);
// update status icon and text of tray icon because reconnect interval might have changed
if (m_menu && m_menu->icon()) {
m_menu->icon()->updateStatusIconAndText();
}
// show warning when explicitely specified connection configuration was not found
if (!specifiedConnectionConfigFound && !connectionConfig.isEmpty()) {
auto *const msgBox = new QMessageBox(QMessageBox::Warning, QCoreApplication::applicationName(),