Unify code for showing wizard
This commit is contained in:
parent
ae10aaf0a2
commit
442aee992a
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <syncthingwidgets/misc/syncthinglauncher.h>
|
||||
#include <syncthingwidgets/settings/settings.h>
|
||||
#include <syncthingwidgets/settings/wizard.h>
|
||||
|
||||
#include <syncthingconnector/syncthingprocess.h>
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
|
@ -62,14 +61,6 @@ void handleSystemdServiceError(const QString &context, const QString &name, cons
|
|||
}
|
||||
#endif
|
||||
|
||||
static void showWizard(const TrayWidget *trayWidget)
|
||||
{
|
||||
auto *const wizard = Wizard::instance();
|
||||
QtUtilities::centerWidget(wizard);
|
||||
QObject::connect(wizard, &Wizard::settingsDialogRequested, trayWidget, &TrayWidget::showSettingsDialog);
|
||||
wizard->show();
|
||||
}
|
||||
|
||||
int initSyncthingTray(bool windowed, bool waitForTray, const Argument &connectionConfigArg)
|
||||
{
|
||||
// get settings
|
||||
|
@ -117,7 +108,7 @@ int initSyncthingTray(bool windowed, bool waitForTray, const Argument &connectio
|
|||
|
||||
// show wizard on first launch
|
||||
if (settings.firstLaunch || settings.fakeFirstLaunch) {
|
||||
showWizard(widget);
|
||||
widget->showWizard();
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
@ -144,7 +135,7 @@ static void trigger(bool tray, bool webUi, bool wizard)
|
|||
trayWidget->showUsingPositioningSettings();
|
||||
}
|
||||
if (wizard) {
|
||||
showWizard(trayWidget);
|
||||
trayWidget->showWizard();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <syncthingwidgets/misc/syncthinglauncher.h>
|
||||
#include <syncthingwidgets/misc/textviewdialog.h>
|
||||
#include <syncthingwidgets/settings/settingsdialog.h>
|
||||
#include <syncthingwidgets/settings/wizard.h>
|
||||
#include <syncthingwidgets/webview/webviewdialog.h>
|
||||
|
||||
#include <syncthingmodel/syncthingicons.h>
|
||||
|
@ -58,6 +59,7 @@ namespace QtGui {
|
|||
|
||||
QWidget *TrayWidget::s_dialogParent = nullptr;
|
||||
SettingsDialog *TrayWidget::s_settingsDlg = nullptr;
|
||||
Wizard *TrayWidget::s_wizard = nullptr;
|
||||
QtUtilities::AboutDialog *TrayWidget::s_aboutDlg = nullptr;
|
||||
vector<TrayWidget *> TrayWidget::s_instances;
|
||||
|
||||
|
@ -246,6 +248,7 @@ SettingsDialog *TrayWidget::settingsDialog()
|
|||
}
|
||||
if (!s_settingsDlg) {
|
||||
s_settingsDlg = new SettingsDialog(s_instances.size() < 2 ? &m_connection : nullptr, s_dialogParent);
|
||||
connect(s_settingsDlg, &SettingsDialog::wizardRequested, this, &TrayWidget::showWizard);
|
||||
connect(s_settingsDlg, &SettingsDialog::applied, &TrayWidget::applySettingsOnAllInstances);
|
||||
|
||||
// save settings to disk when applied
|
||||
|
@ -264,6 +267,16 @@ void TrayWidget::showSettingsDialog()
|
|||
showDialog(dlg, centerWidgetAvoidingOverflow(dlg));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
showDialog(s_wizard, centerWidgetAvoidingOverflow(s_wizard));
|
||||
}
|
||||
|
||||
void TrayWidget::showAboutDialog()
|
||||
{
|
||||
if (!s_dialogParent) {
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace QtGui {
|
|||
|
||||
class WebViewDialog;
|
||||
class SettingsDialog;
|
||||
class Wizard;
|
||||
class TrayMenu;
|
||||
|
||||
namespace Ui {
|
||||
|
@ -60,6 +61,7 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void showSettingsDialog();
|
||||
void showWizard();
|
||||
void showAboutDialog();
|
||||
void showWebUi();
|
||||
void showOwnDeviceId();
|
||||
|
@ -112,6 +114,7 @@ private:
|
|||
std::unique_ptr<Ui::TrayWidget> m_ui;
|
||||
static QWidget *s_dialogParent;
|
||||
static SettingsDialog *s_settingsDlg;
|
||||
static Wizard *s_wizard;
|
||||
static QtUtilities::AboutDialog *s_aboutDlg;
|
||||
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
|
||||
WebViewDialog *m_webViewDlg;
|
||||
|
|
|
@ -1478,20 +1478,13 @@ void SettingsDialog::init()
|
|||
QIcon::fromTheme(QStringLiteral("tools-wizard"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/tools-wizard.svg"))));
|
||||
startWizardButton->setFlat(true);
|
||||
startWizardButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
connect(startWizardButton, &QPushButton::clicked, this, &SettingsDialog::showWizard);
|
||||
connect(startWizardButton, &QPushButton::clicked, this, &SettingsDialog::wizardRequested);
|
||||
addHeadingWidget(startWizardButton);
|
||||
|
||||
// some settings could be applied without restarting the application, good idea?
|
||||
//connect(this, &Dialogs::SettingsDialog::applied, bind(&Dialogs::QtSettings::apply, &Settings::qtSettings()));
|
||||
}
|
||||
|
||||
void SettingsDialog::showWizard()
|
||||
{
|
||||
auto *const wizard = Wizard::instance();
|
||||
QtUtilities::centerWidget(wizard);
|
||||
wizard->show();
|
||||
}
|
||||
|
||||
void SettingsDialog::hideConnectionStatus()
|
||||
{
|
||||
m_connectionsOptionPage->hideConnectionStatus();
|
||||
|
|
|
@ -175,8 +175,8 @@ public:
|
|||
~SettingsDialog() override;
|
||||
void hideConnectionStatus();
|
||||
|
||||
private Q_SLOTS:
|
||||
void showWizard();
|
||||
Q_SIGNALS:
|
||||
void wizardRequested();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
|
Loading…
Reference in New Issue