2022-08-06 21:08:55 +02:00
|
|
|
#ifndef SETTINGS_WIZARD_H
|
|
|
|
#define SETTINGS_WIZARD_H
|
|
|
|
|
|
|
|
#include "../global.h"
|
|
|
|
|
2022-09-03 21:32:44 +02:00
|
|
|
#include <c++utilities/misc/flagenumclass.h>
|
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
#include <QWizard>
|
|
|
|
#include <QWizardPage>
|
|
|
|
|
2022-08-23 18:19:47 +02:00
|
|
|
#include <memory>
|
2022-08-23 12:31:43 +02:00
|
|
|
|
2022-09-17 23:09:00 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QLabel)
|
2022-09-25 22:14:21 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QProgressBar)
|
2022-11-10 21:45:12 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
|
2022-09-17 23:09:00 +02:00
|
|
|
|
2023-01-09 16:01:37 +01:00
|
|
|
namespace Data {
|
|
|
|
class SyncthingConnection;
|
|
|
|
}
|
|
|
|
|
2023-02-26 20:01:02 +01:00
|
|
|
class WizardTests;
|
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
namespace QtGui {
|
|
|
|
|
2022-08-23 18:19:47 +02:00
|
|
|
class SetupDetection;
|
2022-08-22 23:48:18 +02:00
|
|
|
|
2022-08-23 21:06:58 +02:00
|
|
|
namespace Ui {
|
|
|
|
class MainConfigWizardPage;
|
2022-09-03 21:32:44 +02:00
|
|
|
class AutostartWizardPage;
|
2022-09-17 23:09:00 +02:00
|
|
|
class ApplyWizardPage;
|
2022-09-03 21:32:44 +02:00
|
|
|
} // namespace Ui
|
|
|
|
|
2022-09-06 16:24:53 +02:00
|
|
|
enum class MainConfiguration : quint64 {
|
2022-09-03 21:32:44 +02:00
|
|
|
None,
|
|
|
|
CurrentlyRunning,
|
|
|
|
LauncherExternal,
|
|
|
|
LauncherBuiltIn,
|
|
|
|
SystemdUserUnit,
|
|
|
|
SystemdSystemUnit,
|
|
|
|
};
|
|
|
|
|
2022-09-06 16:24:53 +02:00
|
|
|
enum class ExtraConfiguration : quint64 {
|
2022-09-03 21:32:44 +02:00
|
|
|
None,
|
|
|
|
SystemdIntegration = (1 << 0),
|
|
|
|
};
|
2022-08-23 21:06:58 +02:00
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT Wizard : public QWizard {
|
|
|
|
Q_OBJECT
|
2022-10-16 15:08:29 +02:00
|
|
|
friend class WizardTests;
|
2022-08-06 21:08:55 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Wizard(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
|
|
|
|
~Wizard() override;
|
|
|
|
|
|
|
|
static Wizard *instance();
|
2022-10-16 15:08:29 +02:00
|
|
|
static bool hasInstance();
|
2022-08-23 18:19:47 +02:00
|
|
|
SetupDetection &setupDetection();
|
2022-09-03 21:32:44 +02:00
|
|
|
MainConfiguration mainConfig() const;
|
|
|
|
ExtraConfiguration extraConfig() const;
|
|
|
|
bool autoStart() const;
|
2023-05-18 23:50:27 +02:00
|
|
|
bool keepExistingAutoStartEntry() const;
|
2022-09-25 22:14:21 +02:00
|
|
|
bool isConfigApplied() const;
|
2022-09-17 23:09:00 +02:00
|
|
|
const QString &configError() const;
|
2023-01-09 16:01:37 +01:00
|
|
|
Data::SyncthingConnection *appliedConnection();
|
2022-08-06 21:08:55 +02:00
|
|
|
|
2022-09-25 22:14:21 +02:00
|
|
|
public Q_SLOTS:
|
2022-10-01 22:25:33 +02:00
|
|
|
bool changeSettings();
|
2023-01-09 16:01:37 +01:00
|
|
|
void handleConfigurationApplied(const QString &configError = QString(), Data::SyncthingConnection *connection = nullptr);
|
2022-09-25 22:14:21 +02:00
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
Q_SIGNALS:
|
2022-09-25 22:14:21 +02:00
|
|
|
void settingsDialogRequested();
|
2022-10-02 20:33:07 +02:00
|
|
|
void openLauncherSettingsRequested();
|
2022-10-01 22:25:33 +02:00
|
|
|
void openSyncthingRequested();
|
2022-09-25 22:14:21 +02:00
|
|
|
void settingsChanged();
|
|
|
|
void configApplied();
|
2022-08-06 21:08:55 +02:00
|
|
|
|
2022-08-27 23:35:15 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void showDetailsFromSetupDetection();
|
2023-01-09 15:34:51 +01:00
|
|
|
void handleConfigurationSelected(QtGui::MainConfiguration mainConfig, QtGui::ExtraConfiguration extraConfig);
|
2023-05-18 23:50:27 +02:00
|
|
|
void handleAutostartSelected(bool autostartEnabled, bool keepExisting);
|
2022-10-02 19:24:26 +02:00
|
|
|
void pollForSyncthingConfig();
|
2022-08-27 23:35:15 +02:00
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
private:
|
2022-10-02 19:24:26 +02:00
|
|
|
QString hintAboutSyncthingLog() const;
|
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
static Wizard *s_instance;
|
2022-08-23 18:19:47 +02:00
|
|
|
std::unique_ptr<SetupDetection> m_setupDetection;
|
2022-09-03 21:32:44 +02:00
|
|
|
MainConfiguration m_mainConfig = MainConfiguration::None;
|
|
|
|
ExtraConfiguration m_extraConfig = ExtraConfiguration::None;
|
|
|
|
bool m_autoStart = false;
|
2023-05-18 23:50:27 +02:00
|
|
|
bool m_autoStartKeepExisting = false;
|
2022-09-25 22:14:21 +02:00
|
|
|
bool m_configApplied = false;
|
2022-09-17 23:09:00 +02:00
|
|
|
QString m_configError;
|
2023-01-09 16:01:37 +01:00
|
|
|
Data::SyncthingConnection *m_appliedConnection = nullptr;
|
2022-10-02 19:24:26 +02:00
|
|
|
int m_elapsedPollTime;
|
2022-08-06 21:08:55 +02:00
|
|
|
};
|
|
|
|
|
2022-10-16 15:08:29 +02:00
|
|
|
inline bool Wizard::hasInstance()
|
|
|
|
{
|
|
|
|
return s_instance != nullptr;
|
|
|
|
}
|
|
|
|
|
2022-09-03 21:32:44 +02:00
|
|
|
inline MainConfiguration Wizard::mainConfig() const
|
|
|
|
{
|
|
|
|
return m_mainConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ExtraConfiguration Wizard::extraConfig() const
|
|
|
|
{
|
|
|
|
return m_extraConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Wizard::autoStart() const
|
|
|
|
{
|
|
|
|
return m_autoStart;
|
|
|
|
}
|
|
|
|
|
2023-05-18 23:50:27 +02:00
|
|
|
inline bool Wizard::keepExistingAutoStartEntry() const
|
|
|
|
{
|
|
|
|
return m_autoStartKeepExisting;
|
|
|
|
}
|
|
|
|
|
2022-09-25 22:14:21 +02:00
|
|
|
inline bool Wizard::isConfigApplied() const
|
|
|
|
{
|
|
|
|
return m_configApplied;
|
|
|
|
}
|
|
|
|
|
2022-09-17 23:09:00 +02:00
|
|
|
inline const QString &Wizard::configError() const
|
|
|
|
{
|
|
|
|
return m_configError;
|
|
|
|
}
|
|
|
|
|
2023-01-09 16:01:37 +01:00
|
|
|
inline Data::SyncthingConnection *Wizard::appliedConnection()
|
|
|
|
{
|
|
|
|
return m_appliedConnection;
|
|
|
|
}
|
|
|
|
|
2022-08-22 23:48:18 +02:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT WelcomeWizardPage final : public QWizardPage {
|
2022-08-06 21:08:55 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit WelcomeWizardPage(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
bool isComplete() const override;
|
|
|
|
};
|
|
|
|
|
2022-08-22 23:48:18 +02:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT DetectionWizardPage final : public QWizardPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DetectionWizardPage(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
bool isComplete() const override;
|
|
|
|
void initializePage() override;
|
|
|
|
void cleanupPage() override;
|
|
|
|
|
2022-08-23 18:19:47 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
void refresh();
|
2022-10-28 15:00:11 +02:00
|
|
|
void showCheckAgainButton();
|
2022-08-23 18:19:47 +02:00
|
|
|
|
2022-08-22 23:48:18 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void tryToConnect();
|
2022-08-23 18:19:47 +02:00
|
|
|
void continueIfDone();
|
|
|
|
|
|
|
|
private:
|
|
|
|
SetupDetection *m_setupDetection;
|
2022-10-28 15:00:11 +02:00
|
|
|
QString m_defaultTitle;
|
|
|
|
QString m_defaultSubTitle;
|
|
|
|
QProgressBar *m_progressBar;
|
|
|
|
QPushButton *m_checkAgainButton;
|
2022-08-23 18:19:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class SYNCTHINGWIDGETS_EXPORT MainConfigWizardPage final : public QWizardPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MainConfigWizardPage(QWidget *parent = nullptr);
|
2022-08-23 21:06:58 +02:00
|
|
|
~MainConfigWizardPage() override;
|
2022-08-23 18:19:47 +02:00
|
|
|
|
|
|
|
bool isComplete() const override;
|
|
|
|
void initializePage() override;
|
|
|
|
void cleanupPage() override;
|
2022-09-03 21:32:44 +02:00
|
|
|
bool validatePage() override;
|
2022-08-23 18:19:47 +02:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void retry();
|
2023-01-11 19:04:08 +01:00
|
|
|
void configurationSelected(QtGui::MainConfiguration mainConfig, QtGui::ExtraConfiguration extraConfig);
|
2022-08-22 23:48:18 +02:00
|
|
|
|
2022-08-27 23:35:15 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleSelectionChanged();
|
|
|
|
|
2022-08-22 23:48:18 +02:00
|
|
|
private:
|
2022-08-23 21:06:58 +02:00
|
|
|
std::unique_ptr<Ui::MainConfigWizardPage> m_ui;
|
2022-08-27 23:35:15 +02:00
|
|
|
bool m_configSelected;
|
2022-08-22 23:48:18 +02:00
|
|
|
};
|
|
|
|
|
2022-09-03 21:32:44 +02:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT AutostartWizardPage final : public QWizardPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AutostartWizardPage(QWidget *parent = nullptr);
|
|
|
|
~AutostartWizardPage() override;
|
|
|
|
|
|
|
|
bool isComplete() const override;
|
|
|
|
void initializePage() override;
|
|
|
|
void cleanupPage() override;
|
|
|
|
bool validatePage() override;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2023-05-18 23:50:27 +02:00
|
|
|
void autostartSelected(bool autostartEnabled, bool keepExisting);
|
2022-09-03 21:32:44 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::AutostartWizardPage> m_ui;
|
|
|
|
bool m_configSelected;
|
|
|
|
};
|
|
|
|
|
2022-09-17 23:09:00 +02:00
|
|
|
class SYNCTHINGWIDGETS_EXPORT ApplyWizardPage final : public QWizardPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ApplyWizardPage(QWidget *parent = nullptr);
|
|
|
|
~ApplyWizardPage() override;
|
|
|
|
|
|
|
|
bool isComplete() const override;
|
|
|
|
void initializePage() override;
|
|
|
|
bool validatePage() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::ApplyWizardPage> m_ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SYNCTHINGWIDGETS_EXPORT FinalWizardPage final : public QWizardPage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit FinalWizardPage(QWidget *parent = nullptr);
|
|
|
|
~FinalWizardPage() override;
|
|
|
|
|
|
|
|
bool isComplete() const override;
|
|
|
|
void initializePage() override;
|
2022-10-01 22:25:33 +02:00
|
|
|
bool validatePage() override;
|
2022-09-17 23:09:00 +02:00
|
|
|
|
2022-09-25 22:14:21 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
void showResults();
|
|
|
|
|
2022-10-01 22:25:33 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleLinkActivated(const QString &href);
|
|
|
|
|
2022-09-17 23:09:00 +02:00
|
|
|
private:
|
2022-11-10 21:45:12 +01:00
|
|
|
QVBoxLayout *m_layout;
|
2022-09-17 23:09:00 +02:00
|
|
|
QLabel *m_label;
|
2022-09-25 22:14:21 +02:00
|
|
|
QProgressBar *m_progressBar;
|
2022-11-10 21:45:12 +01:00
|
|
|
QWidget *m_ownDeviceIdWidget;
|
2022-09-17 23:09:00 +02:00
|
|
|
};
|
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
} // namespace QtGui
|
|
|
|
|
2022-09-03 21:32:44 +02:00
|
|
|
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(QtGui, QtGui::ExtraConfiguration)
|
|
|
|
|
2022-08-06 21:08:55 +02:00
|
|
|
#endif // SETTINGS_WIZARD_H
|