Fix displaying QR-code in wizard when built-in launcher is used

In this case the connection from the setup detection is not the correct
one. The connection used to apply the settings should generally be used for
querying the QR-code.
This commit is contained in:
Martchus 2023-01-09 16:01:37 +01:00
parent 9da5392c35
commit e9eeb76578
4 changed files with 22 additions and 6 deletions

View File

@ -388,7 +388,7 @@ void SyncthingApplet::concludeWizard(const QString &errorMessage)
} }
m_applyingSettingsForWizard = false; m_applyingSettingsForWizard = false;
if (m_wizard) { if (m_wizard) {
m_wizard->handleConfigurationApplied(errorMessage); m_wizard->handleConfigurationApplied(errorMessage, &m_connection);
} }
} }

View File

@ -297,7 +297,7 @@ void TrayWidget::applySettingsChangesFromWizard()
// consider the settings applied instantly if there's no tray widget instance // consider the settings applied instantly if there's no tray widget instance
if (s_instances.empty()) { if (s_instances.empty()) {
if (s_wizard) { if (s_wizard) {
s_wizard->handleConfigurationApplied(); s_wizard->handleConfigurationApplied(QString(), &m_connection);
} }
return; return;
} }
@ -926,7 +926,7 @@ void TrayWidget::concludeWizard(const QString &errorMessage)
} }
m_applyingSettingsForWizard = false; m_applyingSettingsForWizard = false;
if (s_wizard) { if (s_wizard) {
s_wizard->handleConfigurationApplied(errorMessage); s_wizard->handleConfigurationApplied(errorMessage, &m_connection);
} }
} }

View File

@ -394,12 +394,15 @@ QString Wizard::hintAboutSyncthingLog() const
return res; return res;
} }
void Wizard::handleConfigurationApplied(const QString &configError) void Wizard::handleConfigurationApplied(const QString &configError, Data::SyncthingConnection *connection)
{ {
m_configApplied = true; m_configApplied = true;
if (m_configError.isEmpty()) { if (m_configError.isEmpty()) {
m_configError = configError; m_configError = configError;
} }
if ((m_appliedConnection = connection)) {
connect(connection, &Data::SyncthingConnection::destroyed, this, [this] { m_appliedConnection = nullptr; });
}
emit configApplied(); emit configApplied();
} }
@ -1005,7 +1008,9 @@ void QtGui::FinalWizardPage::showResults()
"Syncthing</a> to pair remote devices and add folders for sharing. If you need further help, read the " "Syncthing</a> to pair remote devices and add folders for sharing. If you need further help, read the "
"<a href=\"openDocs\">documentation to get started</a>.</p>" "<a href=\"openDocs\">documentation to get started</a>.</p>"
"<p>To initiate the pairing from another device, the device ID of this Syncthing device is displayed below.</p>")); "<p>To initiate the pairing from another device, the device ID of this Syncthing device is displayed below.</p>"));
m_layout->addWidget(m_ownDeviceIdWidget = ownDeviceIdWidget(wizard->setupDetection().connection, 256)); if (wizard->appliedConnection()) {
m_layout->addWidget(m_ownDeviceIdWidget = ownDeviceIdWidget(*(wizard->appliedConnection()), 256));
}
} else { } else {
setSubTitle(tr("Not all changes could be applied")); setSubTitle(tr("Not all changes could be applied"));
m_label->setText( m_label->setText(

View File

@ -14,6 +14,10 @@ QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QProgressBar) QT_FORWARD_DECLARE_CLASS(QProgressBar)
QT_FORWARD_DECLARE_CLASS(QVBoxLayout) QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
namespace Data {
class SyncthingConnection;
}
namespace QtGui { namespace QtGui {
class SetupDetection; class SetupDetection;
@ -54,10 +58,11 @@ public:
bool autoStart() const; bool autoStart() const;
bool isConfigApplied() const; bool isConfigApplied() const;
const QString &configError() const; const QString &configError() const;
Data::SyncthingConnection *appliedConnection();
public Q_SLOTS: public Q_SLOTS:
bool changeSettings(); bool changeSettings();
void handleConfigurationApplied(const QString &configError = QString()); void handleConfigurationApplied(const QString &configError = QString(), Data::SyncthingConnection *connection = nullptr);
Q_SIGNALS: Q_SIGNALS:
void settingsDialogRequested(); void settingsDialogRequested();
@ -82,6 +87,7 @@ private:
bool m_autoStart = false; bool m_autoStart = false;
bool m_configApplied = false; bool m_configApplied = false;
QString m_configError; QString m_configError;
Data::SyncthingConnection *m_appliedConnection = nullptr;
int m_elapsedPollTime; int m_elapsedPollTime;
}; };
@ -115,6 +121,11 @@ inline const QString &Wizard::configError() const
return m_configError; return m_configError;
} }
inline Data::SyncthingConnection *Wizard::appliedConnection()
{
return m_appliedConnection;
}
class SYNCTHINGWIDGETS_EXPORT WelcomeWizardPage final : public QWizardPage { class SYNCTHINGWIDGETS_EXPORT WelcomeWizardPage final : public QWizardPage {
Q_OBJECT Q_OBJECT