Allow opening launcher settings from wizard in case of an error to check logs

This commit is contained in:
Martchus 2022-10-02 20:33:07 +02:00
parent 722e9f6e7d
commit 4896261ef9
6 changed files with 23 additions and 1 deletions

View File

@ -268,12 +268,19 @@ void TrayWidget::showSettingsDialog()
showDialog(dlg, centerWidgetAvoidingOverflow(dlg));
}
void TrayWidget::showLauncherSettings()
{
showSettingsDialog();
settingsDialog()->selectLauncherSettings();
}
void TrayWidget::showWizard()
{
if (!s_wizard) {
s_wizard = Wizard::instance();
connect(s_wizard, &Wizard::destroyed, this, [] { s_wizard = nullptr; });
connect(s_wizard, &Wizard::settingsDialogRequested, this, &TrayWidget::showSettingsDialog);
connect(s_wizard, &Wizard::openLauncherSettingsRequested, this, &TrayWidget::showLauncherSettings);
connect(s_wizard, &Wizard::openSyncthingRequested, this, &TrayWidget::showWebUi);
connect(s_wizard, &Wizard::settingsChanged, this, &TrayWidget::applySettingsChangesFromWizard);
}

View File

@ -61,6 +61,7 @@ public:
public Q_SLOTS:
void showSettingsDialog();
void showLauncherSettings();
void showWizard();
void showAboutDialog();
void showWebUi();

View File

@ -1450,6 +1450,8 @@ SettingsDialog::SettingsDialog(Data::SyncthingConnection *connection, QWidget *p
#endif
});
category->setIcon(QIcon::fromTheme(QStringLiteral("system-run"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/system-run.svg"))));
m_launcherSettingsCategory = static_cast<int>(categories.size());
m_launcherSettingsPageIndex = 1;
categories << category;
categories << values().qt.category();
@ -1490,6 +1492,13 @@ void SettingsDialog::hideConnectionStatus()
m_connectionsOptionPage->hideConnectionStatus();
}
void SettingsDialog::selectLauncherSettings()
{
if (m_launcherSettingsCategory >= 0 && m_launcherSettingsPageIndex >= 0) {
selectPage(m_launcherSettingsCategory, m_launcherSettingsPageIndex);
}
}
} // namespace QtGui
INSTANTIATE_UI_FILE_BASED_OPTION_PAGE_NS(QtGui, ConnectionOptionPage)

View File

@ -174,6 +174,7 @@ public:
explicit SettingsDialog(QWidget *parent = nullptr);
~SettingsDialog() override;
void hideConnectionStatus();
void selectLauncherSettings();
Q_SIGNALS:
void wizardRequested();
@ -182,6 +183,7 @@ private:
void init();
ConnectionOptionPage *m_connectionsOptionPage;
int m_launcherSettingsCategory = -1, m_launcherSettingsPageIndex = -1;
};
} // namespace QtGui

View File

@ -360,7 +360,7 @@ QString Wizard::hintAboutSyncthingLog() const
switch (mainConfig()) {
case MainConfiguration::LauncherExternal:
case MainConfiguration::LauncherBuiltIn:
res += tr(" It can be accessed within the launcher settings.");
res += tr(" It can be accessed within the <a href=\"openLauncherSettings\">launcher settings</a>.");
break;
case MainConfiguration::SystemdUserUnit:
case MainConfiguration::SystemdSystemUnit:
@ -961,6 +961,8 @@ void FinalWizardPage::handleLinkActivated(const QString &href)
auto *const wizard = qobject_cast<Wizard *>(this->wizard());
if (wizard && href == QLatin1String("openSyncthing")) {
emit wizard->openSyncthingRequested();
} else if (wizard && href == QLatin1String("openLauncherSettings")) {
emit wizard->openLauncherSettingsRequested();
} else if (href == QLatin1String("openDocs")) {
QDesktopServices::openUrl(QStringLiteral("https://docs.syncthing.net/intro/getting-started.html#configuring"));
}

View File

@ -58,6 +58,7 @@ public Q_SLOTS:
Q_SIGNALS:
void settingsDialogRequested();
void openLauncherSettingsRequested();
void openSyncthingRequested();
void settingsChanged();
void configApplied();