diff --git a/src/gui/main/gui.pro b/src/gui/main/gui.pro
index 635b2344..da083775 100644
--- a/src/gui/main/gui.pro
+++ b/src/gui/main/gui.pro
@@ -15,7 +15,7 @@ FORMS += res/MainWindowBase.ui \
res/SettingsDialogBase.ui \
res/SetupWizardBase.ui \
res/AddClientDialogBase.ui \
- res/LoginDialogBase.ui
+ res/LoginWindowBase.ui
SOURCES += src/main.cpp \
src/MainWindow.cpp \
src/AboutDialog.cpp \
@@ -52,8 +52,8 @@ SOURCES += src/main.cpp \
src/DataDownloader.cpp \
src/AddClientDialog.cpp \
src/CommandProcess.cpp \
- src/LoginAuth.cpp \
- src/LoginDialog.cpp
+ src/LoginWindow.cpp \
+ src/LoginAuth.cpp
HEADERS += src/MainWindow.h \
src/AboutDialog.h \
src/ServerConfig.h \
@@ -90,10 +90,10 @@ HEADERS += src/MainWindow.h \
src/DataDownloader.h \
src/AddClientDialog.h \
src/CommandProcess.h \
+ src/LoginWindow.h \
src/LoginAuth.h \
src/EditionType.h \
- src/LoginResult.h \
- src/LoginDialog.h
+ src/LoginResult.h
RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc
macx {
diff --git a/src/gui/main/res/LoginDialogBase.ui b/src/gui/main/res/LoginDialogBase.ui
deleted file mode 100644
index 48ba3db4..00000000
--- a/src/gui/main/res/LoginDialogBase.ui
+++ /dev/null
@@ -1,167 +0,0 @@
-
-
- LoginDialog
-
-
-
- 0
- 0
- 359
- 175
-
-
-
-
- 0
- 0
-
-
-
- Synergy
-
-
- -
-
-
-
-
-
- :/res/image/about.png
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Minimum
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
- 20
-
-
- 10
-
-
- 0
-
-
- 0
-
-
-
-
-
- Email:
-
-
-
- -
-
-
-
- 200
- 0
-
-
-
-
- -
-
-
- Password:
-
-
-
- -
-
-
-
- 200
- 0
-
-
-
- QLineEdit::Password
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Minimum
-
-
-
- 20
- 10
-
-
-
-
- -
-
-
-
-
-
- <a href="https://synergy-project.org/account/reset/">Forgot password</a>
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Login
-
-
- Return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/gui/main/res/LoginWindow.h b/src/gui/main/res/LoginWindow.h
new file mode 100644
index 00000000..2f1cb636
--- /dev/null
+++ b/src/gui/main/res/LoginWindow.h
@@ -0,0 +1,22 @@
+#ifndef LOGINWINDOW_H
+#define LOGINWINDOW_H
+
+#include
+
+#include "ui_LoginWindowBase.h"
+
+class LoginWindow : public QMainWindow, public Ui::LoginWindowBase
+{
+ Q_OBJECT
+public:
+ LoginWindow(QWidget *parent = 0);
+ ~LoginWindow();
+
+protected:
+ void changeEvent(QEvent *e);
+
+private:
+ Ui::LoginWindow *ui;
+};
+
+#endif // LOGINWINDOW_H
diff --git a/src/gui/main/res/LoginWindowBase.ui b/src/gui/main/res/LoginWindowBase.ui
new file mode 100644
index 00000000..4b58e1b1
--- /dev/null
+++ b/src/gui/main/res/LoginWindowBase.ui
@@ -0,0 +1,149 @@
+
+
+ LoginWindow
+
+
+
+ 0
+ 0
+ 400
+ 200
+
+
+
+ Synergy
+
+
+
+ -
+
+
+ 10
+
+
-
+
+
+
+
+
+ :/res/image/about.png
+
+
+
+
+
+ -
+
+
+ 20
+
+
+ 20
+
+
-
+
+
+ Email:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Password:
+
+
+
+ -
+
+
+ Qt::ImhHiddenText
+
+
+ QLineEdit::Password
+
+
+
+
+
+ -
+
+
+ 20
+
+
+ 20
+
+
-
+
+
+ <a href="http://synergy-project.org/">Register</a>
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Login
+
+
+ Return
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Cancel
+
+
+ Esc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/gui/main/res/image/about.png b/src/gui/main/res/image/about.png
index 23e58c9b..4630bd32 100644
Binary files a/src/gui/main/res/image/about.png and b/src/gui/main/res/image/about.png differ
diff --git a/src/gui/main/src/AppConfig.h b/src/gui/main/src/AppConfig.h
index 642f6d12..d14ca8ac 100644
--- a/src/gui/main/src/AppConfig.h
+++ b/src/gui/main/src/AppConfig.h
@@ -47,7 +47,7 @@ class AppConfig
friend class SettingsDialog;
friend class MainWindow;
friend class SetupWizard;
- friend class LoginDialog;
+ friend class LoginWindow;
public:
AppConfig(QSettings* settings);
diff --git a/src/gui/main/src/LoginAuth.cpp b/src/gui/main/src/LoginAuth.cpp
index 0b91d2c3..a45ffc93 100644
--- a/src/gui/main/src/LoginAuth.cpp
+++ b/src/gui/main/src/LoginAuth.cpp
@@ -17,7 +17,7 @@
#include "LoginAuth.h"
-#include "LoginDialog.h"
+#include "LoginWindow.h"
#include "AppConfig.h"
#include "QUtility.h"
#include "LoginResult.h"
@@ -28,16 +28,16 @@
#include
#include
-void LoginAuth::checkEditionType()
+void LoginAuth::checkUserType()
{
int edition = Unknown;
- int result = doCheckEditionType(edition);
- m_pLoginDialog->setLoginResult(result);
- m_pLoginDialog->setEditionType(edition);
+ int result = doCheckUserType(edition);
+ m_pLoginWindow->setLoginResult(result);
+ m_pLoginWindow->setEditionType(edition);
emit finished();
}
-int LoginAuth::doCheckEditionType(int& edition)
+int LoginAuth::doCheckUserType(int& edition)
{
QString responseJson;
@@ -47,7 +47,7 @@ int LoginAuth::doCheckEditionType(int& edition)
}
catch (std::exception& e)
{
- m_pLoginDialog->setError(e.what());
+ m_pLoginWindow->setError(e.what());
return ExceptionError;
}
@@ -72,12 +72,12 @@ int LoginAuth::doCheckEditionType(int& edition)
// replace "\n" with real new lines.
QString error = errorRegex.cap(1).replace("\\n", "\n");
- m_pLoginDialog->setError(error);
+ m_pLoginWindow->setError(error);
return Error;
}
}
- m_pLoginDialog->setError(responseJson);
+ m_pLoginWindow->setError(responseJson);
return ServerResponseError;
}
diff --git a/src/gui/main/src/LoginAuth.h b/src/gui/main/src/LoginAuth.h
index 272472a8..560c284e 100644
--- a/src/gui/main/src/LoginAuth.h
+++ b/src/gui/main/src/LoginAuth.h
@@ -21,7 +21,7 @@
#include
#include
-class LoginDialog;
+class LoginWindow;
class AppConfig;
class LoginAuth : public QObject
@@ -29,13 +29,13 @@ class LoginAuth : public QObject
Q_OBJECT
public:
- int doCheckEditionType(int& edition);
+ int doCheckUserType(int& edition);
void setEmail(QString email) { m_Email = email; }
void setPassword(QString password) { m_Password = password; }
- void setLoginDialog(LoginDialog* d) { m_pLoginDialog = d; }
+ void setLoginWindow(LoginWindow* w) { m_pLoginWindow = w; }
public slots:
- void checkEditionType();
+ void checkUserType();
signals:
void finished();
@@ -46,7 +46,7 @@ private:
private:
QString m_Email;
QString m_Password;
- LoginDialog* m_pLoginDialog;
+ LoginWindow* m_pLoginWindow;
};
#endif // LOGINAUTH_H
diff --git a/src/gui/main/src/LoginDialog.h b/src/gui/main/src/LoginDialog.h
deleted file mode 100644
index 3ca831e6..00000000
--- a/src/gui/main/src/LoginDialog.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef LOGINDIALOG_H
-#define LOGINDIALOG_H
-
-#include "ui_LoginDialogBase.h"
-
-#include
-
-class MainWindow;
-class SetupWizard;
-class LoginAuth;
-class AppConfig;
-
-class LoginDialog : public QDialog, public Ui::LoginDialog {
- Q_OBJECT
-public:
- LoginDialog(MainWindow* mainWindow,
- SetupWizard* setupWizard,
- bool wizardShouldRun,
- QWidget *parent = 0);
- ~LoginDialog();
-
- void setLoginResult(int result) { m_LoginResult = result; }
- void setEditionType(int type) { m_EditionType = type; }
- void setError(QString error) { m_Error = error; }
-
-protected:
- void changeEvent(QEvent *e);
- void closeEvent(QCloseEvent *event);
- void keyPressEvent(QKeyEvent *e);
-
-private slots:
- void on_m_pPushButtonLogin_clicked();
- void showNext();
-
-private:
- bool validEmailPassword();
-
-private:
- MainWindow* m_pMainWindow;
- SetupWizard* m_pSetupWizard;
- bool m_WizardShouldRun;
- LoginAuth* m_pLoginAuth;
- int m_LoginResult;
- int m_EditionType;
- QString m_Error;
- AppConfig& m_AppConfig;
-};
-
-#endif // LOGINDIALOG_H
diff --git a/src/gui/main/src/LoginDialog.cpp b/src/gui/main/src/LoginWindow.cpp
similarity index 65%
rename from src/gui/main/src/LoginDialog.cpp
rename to src/gui/main/src/LoginWindow.cpp
index 5cf2007c..ef2c28e2 100644
--- a/src/gui/main/src/LoginDialog.cpp
+++ b/src/gui/main/src/LoginWindow.cpp
@@ -1,172 +1,178 @@
-#include "LoginDialog.h"
-
-#include "MainWindow.h"
-#include "SetupWizard.h"
-#include "LoginAuth.h"
-#include "LoginResult.h"
-#include "EditionType.h"
-#include "QUtility.h"
-
-#include
-#include
-#include
-#include
-#include
-
-static const char registerUrl[] = "http://synergy-project.org";
-
-LoginDialog::LoginDialog(
- MainWindow* mainWindow,
- SetupWizard* setupWizard,
- bool wizardShouldRun,
- QWidget *parent) :
- QDialog(parent),
- m_pMainWindow(mainWindow),
- m_pSetupWizard(setupWizard),
- m_WizardShouldRun(wizardShouldRun),
- m_pLoginAuth(NULL),
- m_LoginResult(Ok),
- m_EditionType(Unknown),
- m_AppConfig(m_pMainWindow->appConfig())
-{
- setupUi(this);
- setFixedSize(size());
- m_pLineEditEmail->setText(m_AppConfig.userEmail());
-}
-
-LoginDialog::~LoginDialog()
-{
- if (m_pLoginAuth != NULL) {
- delete m_pLoginAuth;
- }
-}
-
-void LoginDialog::showNext()
-{
- if (m_LoginResult == ExceptionError) {
- QMessageBox::critical(
- this,
- tr("Error"),
- tr("Sorry, an error occured while trying to sign in. "
- "Please contact the help desk, and provide the "
- "following details.\n\n%1").arg(m_Error));
- }
- else if (m_LoginResult == InvalidEmailPassword) {
- QMessageBox::warning(
- this,
- tr("Warning"),
- tr("Login failed, invalid email or password."));
- }
- else if (m_LoginResult == Error) {
- QMessageBox::critical(
- this,
- tr("Error"),
- tr("Login failed, an error occurred.\n\n%1").arg(m_Error));
- }
- else if (m_LoginResult == ServerResponseError) {
- QMessageBox::critical(
- this,
- "Error",
- tr("Login failed, an error occurred.\n\nServer response:\n\n%1")
- .arg(m_Error));
- }
- else {
- hide();
- if (m_WizardShouldRun) {
- m_pSetupWizard->show();
- }
- else {
- m_pMainWindow->setEditionType(m_EditionType);
- if (!m_pLineEditEmail->text().isEmpty()) {
- m_AppConfig.setUserEmail(m_pLineEditEmail->text());
-
- if (m_EditionType != Unknown) {
- QString mac = getFirstMacAddress();
- QString hashSrc = m_pLineEditEmail->text() + mac;
- QString hashResult = hash(hashSrc);
- //m_AppConfig.setUserToken(hashResult);
- //m_AppConfig.setEditionType(m_EditionType);
- }
- }
- m_pMainWindow->show();
- }
- }
-
- delete m_pLoginAuth;
- m_pLoginAuth = NULL;
- m_LoginResult = Ok;
- m_EditionType = Unknown;
- m_pPushButtonLogin->setEnabled(true);
- m_pPushButtonLogin->setDefault(true);
- m_pLineEditEmail->setEnabled(true);
- m_pLineEditPassword->setEnabled(true);
-}
-
-bool LoginDialog::validEmailPassword()
-{
- if (m_pLineEditEmail->text().isEmpty() ||
- m_pLineEditPassword->text().isEmpty()) {
- QMessageBox::warning(
- this,
- "Warning",
- tr("Please fill in your email and password."));
- return false;
- }
-
- return true;
-}
-
-void LoginDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void LoginDialog::closeEvent(QCloseEvent *event)
-{
- event->accept();
- showNext();
-}
-
-void LoginDialog::on_m_pPushButtonLogin_clicked()
-{
- if (validEmailPassword()) {
- if (m_pLoginAuth == NULL) {
- m_pLoginAuth = new LoginAuth();
- m_pLoginAuth->setLoginDialog(this);
- }
-
- m_pPushButtonLogin->setEnabled(false);
- m_pLineEditEmail->setEnabled(false);
- m_pLineEditPassword->setEnabled(false);
-
- QString email = m_pLineEditEmail->text();
- QString password = m_pLineEditPassword->text();
- m_pLoginAuth->setEmail(email);
- m_pLoginAuth->setPassword(password);
-
- QThread* thread = new QThread;
- connect(m_pLoginAuth, SIGNAL(finished()), this, SLOT(showNext()));
- connect(m_pLoginAuth, SIGNAL(finished()), thread, SLOT(quit()));
- connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
-
- m_pLoginAuth->moveToThread(thread);
- thread->start();
-
- QMetaObject::invokeMethod(m_pLoginAuth, "checkEditionType", Qt::QueuedConnection);
- }
-}
-
-void LoginDialog::keyPressEvent(QKeyEvent* e) {
- if(e->key() != Qt::Key_Escape)
- QDialog::keyPressEvent(e);
- else {
- close();
- }
-}
+/*
+ * synergy -- mouse and keyboard sharing utility
+ * Copyright (C) 2015 Synergy Si Ltd.
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file COPYING that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "LoginWindow.h"
+#include "ui_LoginWindowBase.h"
+
+#include "MainWindow.h"
+#include "SetupWizard.h"
+#include "LoginAuth.h"
+#include "LoginResult.h"
+#include "EditionType.h"
+#include "QUtility.h"
+
+#include
+#include
+#include
+
+LoginWindow::LoginWindow(
+ MainWindow* mainWindow,
+ SetupWizard* setupWizard,
+ bool wizardShouldRun,
+ QWidget *parent) :
+ QMainWindow(parent),
+ m_pMainWindow(mainWindow),
+ m_pSetupWizard(setupWizard),
+ m_WizardShouldRun(wizardShouldRun),
+ m_pLoginAuth(NULL),
+ m_LoginResult(Ok),
+ m_EditionType(Unknown),
+ m_AppConfig(m_pMainWindow->appConfig())
+{
+ setupUi(this);
+
+ m_pLineEditEmail->setText(m_AppConfig.userEmail());
+}
+
+LoginWindow::~LoginWindow()
+{
+ if (m_pLoginAuth != NULL) {
+ delete m_pLoginAuth;
+ }
+}
+
+void LoginWindow::showNext()
+{
+ if (m_LoginResult == ExceptionError) {
+ QMessageBox::critical(
+ this,
+ tr("Error"),
+ tr("Sorry, an error occured while trying to sign in. "
+ "Please contact the help desk, and provide the "
+ "following details.\n\n%1").arg(m_Error));
+ }
+ else if (m_LoginResult == InvalidEmailPassword) {
+ QMessageBox::critical(
+ this,
+ tr("Error"),
+ tr("Login failed, invalid email or password."));
+ }
+ else if (m_LoginResult == Error) {
+ QMessageBox::critical(
+ this,
+ tr("Error"),
+ tr("Login failed, an error occurred.\n\n%1").arg(m_Error));
+ }
+ else if (m_LoginResult == ServerResponseError) {
+ QMessageBox::critical(
+ this,
+ "Error",
+ tr("Login failed, an error occurred.\n\nServer response:\n\n%1")
+ .arg(m_Error));
+ }
+ else {
+ hide();
+ if (m_WizardShouldRun) {
+ m_pSetupWizard->show();
+ }
+ else {
+ m_pMainWindow->setEditionType(m_EditionType);
+ if (!m_pLineEditEmail->text().isEmpty()) {
+ m_AppConfig.setUserEmail(m_pLineEditEmail->text());
+
+ if (m_EditionType != Unknown) {
+ QString mac = getFirstMacAddress();
+ QString hashSrc = m_pLineEditEmail->text() + mac;
+ QString hashResult = hash(hashSrc);
+ m_AppConfig.setUserToken(hashResult);
+ m_AppConfig.setEditionType(m_EditionType);
+ }
+ }
+ m_pMainWindow->show();
+ }
+ }
+
+ delete m_pLoginAuth;
+ m_pLoginAuth = NULL;
+ m_LoginResult = Ok;
+ m_EditionType = Unknown;
+ m_pPushButtonLogin->setEnabled(true);
+ m_pPushButtonLogin->setDefault(true);
+}
+
+bool LoginWindow::validEmailPassword()
+{
+ if (m_pLineEditEmail->text().isEmpty() ||
+ m_pLineEditPassword->text().isEmpty()) {
+ QMessageBox::warning(
+ this,
+ "Warning",
+ tr("Please fill in your email and password."));
+ return false;
+ }
+
+ return true;
+}
+
+void LoginWindow::changeEvent(QEvent *e)
+{
+ QMainWindow::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+void LoginWindow::closeEvent(QCloseEvent *event)
+{
+ event->accept();
+ showNext();
+}
+
+void LoginWindow::on_m_pPushButtonLogin_clicked()
+{
+ if (validEmailPassword()) {
+ if (m_pLoginAuth == NULL) {
+ m_pLoginAuth = new LoginAuth();
+ m_pLoginAuth->setLoginWindow(this);
+ }
+
+ m_pPushButtonLogin->setEnabled(false);
+
+ QString email = m_pLineEditEmail->text();
+ QString password = m_pLineEditPassword->text();
+ m_pLoginAuth->setEmail(email);
+ m_pLoginAuth->setPassword(password);
+
+ QThread* thread = new QThread;
+ connect(m_pLoginAuth, SIGNAL(finished()), this, SLOT(showNext()));
+ connect(m_pLoginAuth, SIGNAL(finished()), thread, SLOT(quit()));
+ connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+
+ m_pLoginAuth->moveToThread(thread);
+ thread->start();
+
+ QMetaObject::invokeMethod(m_pLoginAuth, "checkUserType", Qt::QueuedConnection);
+ }
+}
+
+void LoginWindow::on_m_pPushButtonCancel_clicked()
+{
+ showNext();
+}
diff --git a/src/gui/main/src/LoginWindow.h b/src/gui/main/src/LoginWindow.h
new file mode 100644
index 00000000..e0e6d464
--- /dev/null
+++ b/src/gui/main/src/LoginWindow.h
@@ -0,0 +1,67 @@
+/*
+ * synergy -- mouse and keyboard sharing utility
+ * Copyright (C) 2015 Synergy Si Ltd.
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file COPYING that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef LOGINWINDOW_H
+#define LOGINWINDOW_H
+
+#include
+
+#include "ui_LoginWindowBase.h"
+
+class MainWindow;
+class SetupWizard;
+class LoginAuth;
+class AppConfig;
+
+class LoginWindow : public QMainWindow, public Ui::LoginWindow
+{
+ Q_OBJECT
+public:
+ LoginWindow(MainWindow* mainWindow,
+ SetupWizard* setupWizard,
+ bool wizardShouldRun,
+ QWidget *parent = 0);
+ ~LoginWindow();
+
+ void setLoginResult(int result) { m_LoginResult = result; }
+ void setEditionType(int type) { m_EditionType = type; }
+ void setError(QString error) { m_Error = error; }
+
+protected:
+ void changeEvent(QEvent *e);
+ void closeEvent(QCloseEvent *event);
+
+private slots:
+ void on_m_pPushButtonCancel_clicked();
+ void on_m_pPushButtonLogin_clicked();
+ void showNext();
+
+private:
+ bool validEmailPassword();
+private:
+ MainWindow* m_pMainWindow;
+ SetupWizard* m_pSetupWizard;
+ bool m_WizardShouldRun;
+ LoginAuth* m_pLoginAuth;
+ int m_LoginResult;
+ int m_EditionType;
+ QString m_Error;
+ AppConfig& m_AppConfig;
+
+};
+
+#endif // LOGINWINDOW_H
diff --git a/src/gui/main/src/main.cpp b/src/gui/main/src/main.cpp
index 7f5f572f..48141299 100644
--- a/src/gui/main/src/main.cpp
+++ b/src/gui/main/src/main.cpp
@@ -23,7 +23,7 @@
#include "MainWindow.h"
#include "AppConfig.h"
#include "SetupWizard.h"
-#include "LoginDialog.h"
+#include "LoginWindow.h"
#include "QUtility.h"
#include "LoginResult.h"
@@ -95,7 +95,7 @@ int main(int argc, char* argv[])
MainWindow mainWindow(settings, appConfig);
SetupWizard setupWizard(mainWindow, true);
- LoginDialog loginDialog(
+ LoginWindow loginWindow(
&mainWindow,
&setupWizard,
appConfig.wizardShouldRun());
@@ -109,7 +109,7 @@ int main(int argc, char* argv[])
mainWindow.show();
}
else {
- loginDialog.show();
+ loginWindow.show();
}
return app.exec();