#5629 Ensure setEdition signals main UI

This commit is contained in:
Andrew Nelless 2016-10-04 13:41:27 +01:00
parent 15f2e27d18
commit 783056f7cc
8 changed files with 21 additions and 24 deletions

View File

@ -161,10 +161,5 @@ void ActivationDialog::accept()
message.information (this, "Activated!",
tr("Thanks for activating %1!").arg (getEditionName (edition)));
MainWindow& mainWindow = dynamic_cast<MainWindow&>(*this->parent());
mainWindow.setEdition(edition);
mainWindow.updateLocalFingerprint();
mainWindow.saveSettings();
QDialog::accept();
}

View File

@ -238,7 +238,10 @@ void AppConfig::setAutoConfigPrompted(bool prompted)
m_AutoConfigPrompted = prompted;
}
void AppConfig::setEdition(int e) { m_Edition = e; }
void AppConfig::setEdition(int e) {
m_Edition = e;
emit editionSet (e);
}
int AppConfig::edition() const { return m_Edition; }

View File

@ -20,6 +20,7 @@
#define APPCONFIG_H
#include <QObject>
#include <QString>
#include "ElevateMode.h"
@ -47,8 +48,10 @@ enum ProcessMode {
Desktop
};
class AppConfig
class AppConfig: public QObject
{
Q_OBJECT
friend class SettingsDialog;
friend class MainWindow;
friend class SetupWizard;
@ -144,6 +147,9 @@ class AppConfig
static const char m_SynergysName[];
static const char m_SynergycName[];
static const char m_SynergyLogDir[];
signals:
void editionSet(int);
};
#endif

View File

@ -138,15 +138,8 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
setEdition(m_AppConfig.edition());
m_pLabelPadlock->hide();
if (appConfig.getCryptoEnabled()) {
m_pSslCertificate = new SslCertificate(this);
m_pSslCertificate->generateCertificate();
}
updateLocalFingerprint();
connect (this, SIGNAL(windowShown()), this, SLOT(on_windowShown()), Qt::QueuedConnection);
connect (&m_AppConfig, SIGNAL(editionSet(int)), this, SLOT(setEdition(int)), Qt::QueuedConnection);
}
MainWindow::~MainWindow()
@ -1034,11 +1027,17 @@ void MainWindow::serverDetected(const QString name)
void MainWindow::setEdition(int edition)
{
setWindowTitle(getEditionName(edition));
if (m_AppConfig.getCryptoEnabled()) {
m_pSslCertificate = new SslCertificate(this);
m_pSslCertificate->generateCertificate();
}
updateLocalFingerprint();
saveSettings();
}
void MainWindow::updateLocalFingerprint()
{
if (Fingerprint::local().fileExists()) {
if (m_AppConfig.getCryptoEnabled() && Fingerprint::local().fileExists()) {
m_pLabelFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst());

View File

@ -115,10 +115,10 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void autoAddScreen(const QString name);
void updateZeroconfService();
void serverDetected(const QString name);
void setEdition(int edition);
void updateLocalFingerprint();
public slots:
void setEdition(int edition);
void appendLogRaw(const QString& text);
void appendLogInfo(const QString& text);
void appendLogDebug(const QString& text);

View File

@ -151,6 +151,5 @@ void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked)
sslCertificate.generateCertificate();
MainWindow& mainWindow = dynamic_cast<MainWindow&> (*this->parent());
mainWindow.updateLocalFingerprint();
mainWindow.saveSettings();
}
}

View File

@ -28,9 +28,7 @@
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
m_MainWindow(mainWindow),
m_StartMain(startMain),
m_Edition(Unregistered),
m_LoginAttemps(0)
m_StartMain(startMain)
{
setupUi(this);
@ -141,7 +139,6 @@ void SetupWizard::reject()
if (m_StartMain)
{
m_MainWindow.setEdition(m_Edition);
m_MainWindow.open();
}

View File

@ -47,8 +47,6 @@ private:
MainWindow& m_MainWindow;
bool m_StartMain;
SynergyLocale m_Locale;
int m_Edition;
int m_LoginAttemps;
private slots:
void on_m_pComboLanguage_currentIndexChanged(int index);