Handle systemd service state change in Plasmoid

Previously only the initial service state was considered.
After refactoring the SyncthingService initialization the
state is not known when the Plasmoid is initialized so
this limitation became obvious and had to be fixed.
This commit is contained in:
Martchus 2018-04-12 23:16:51 +02:00
parent b7dbd2c72b
commit 2b1c993a64
1 changed files with 5 additions and 3 deletions

View File

@ -95,19 +95,21 @@ void SyncthingApplet::init()
// restore settings
Settings::restore();
handleSettingsChanged();
// load primary connection config
setCurrentConnectionConfigIndex(config().readEntry<int>("selectedConfig", 0));
// initialize systemd service support
// initialize systemd service support
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
SyncthingService::setMainInstance(&m_service);
m_service.setUnitName(Settings::values().systemd.syncthingUnit);
connect(&m_service, &SyncthingService::systemdAvailableChanged, this, &SyncthingApplet::handleSystemdStatusChanged);
connect(&m_service, &SyncthingService::stateChanged, this, &SyncthingApplet::handleSystemdStatusChanged);
connect(&m_service, &SyncthingService::errorOccurred, this, &SyncthingApplet::handleSystemdServiceError);
#endif
// apply settings and connect according to settings
handleSettingsChanged();
m_initialized = true;
}