Add button to reload all unit files

This commit is contained in:
Martchus 2022-07-04 19:55:52 +02:00
parent cc31872fc7
commit d735455c2a
3 changed files with 14 additions and 1 deletions

View File

@ -199,7 +199,7 @@ bool SyncthingService::concludeAsyncCall(QDBusPendingCallWatcher *watcher, bool
}
if (reload && !watcher->isError()) {
// reload unit files if reload flag was set (for enable/disable to make the change immediately apparent)
registerErrorHandler(m_currentSystemdInterface->Reload(), QT_TR_NOOP_UTF8("reload manager"), false, false);
reloadAllUnitFiles();
}
}
return resultStillRelevant;
@ -391,6 +391,14 @@ void SyncthingService::setEnabled(bool enabled)
#endif
}
/*!
* \brief Reload all unit files.
*/
void Data::SyncthingService::reloadAllUnitFiles()
{
registerErrorHandler(m_currentSystemdInterface->Reload(), QT_TR_NOOP_UTF8("reload all unit files"), false, false);
}
/*!
* \brief Handles when a new unit is added to react if it matches the name of the unit we're monitoring.
*/

View File

@ -87,6 +87,7 @@ public Q_SLOTS:
void setEnabled(bool enable);
void enable();
void disable();
void reloadAllUnitFiles();
Q_SIGNALS:
void unitNameChanged(const QString &unitName);

View File

@ -1218,9 +1218,13 @@ SystemdOptionPage::~SystemdOptionPage()
QWidget *SystemdOptionPage::setupWidget()
{
auto *const widget = SystemdOptionPageBase::setupWidget();
auto *const refreshAction = new QAction(QCoreApplication::translate("QtGui::SystemdOptionPage", "Reload all unit files"), widget);
refreshAction->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/view-refresh.svg"))));
ui()->syncthingUnitLineEdit->addCustomAction(refreshAction);
if (!m_service) {
return widget;
}
QObject::connect(refreshAction, &QAction::triggered, m_service, &SyncthingService::reloadAllUnitFiles);
QObject::connect(ui()->syncthingUnitLineEdit, &QLineEdit::textChanged, m_service, &SyncthingService::setUnitName);
QObject::connect(ui()->startPushButton, &QPushButton::clicked, m_service, &SyncthingService::start);
QObject::connect(ui()->stopPushButton, &QPushButton::clicked, m_service, &SyncthingService::stop);