Revert "changed login window to dialog #4168"
This reverts commit d1c1d79453
.
This commit is contained in:
parent
52005f0905
commit
c81fa7db52
|
@ -15,7 +15,7 @@ FORMS += res/MainWindowBase.ui \
|
||||||
res/SettingsDialogBase.ui \
|
res/SettingsDialogBase.ui \
|
||||||
res/SetupWizardBase.ui \
|
res/SetupWizardBase.ui \
|
||||||
res/AddClientDialogBase.ui \
|
res/AddClientDialogBase.ui \
|
||||||
res/LoginDialogBase.ui
|
res/LoginWindowBase.ui
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/MainWindow.cpp \
|
src/MainWindow.cpp \
|
||||||
src/AboutDialog.cpp \
|
src/AboutDialog.cpp \
|
||||||
|
@ -52,8 +52,8 @@ SOURCES += src/main.cpp \
|
||||||
src/DataDownloader.cpp \
|
src/DataDownloader.cpp \
|
||||||
src/AddClientDialog.cpp \
|
src/AddClientDialog.cpp \
|
||||||
src/CommandProcess.cpp \
|
src/CommandProcess.cpp \
|
||||||
src/LoginAuth.cpp \
|
src/LoginWindow.cpp \
|
||||||
src/LoginDialog.cpp
|
src/LoginAuth.cpp
|
||||||
HEADERS += src/MainWindow.h \
|
HEADERS += src/MainWindow.h \
|
||||||
src/AboutDialog.h \
|
src/AboutDialog.h \
|
||||||
src/ServerConfig.h \
|
src/ServerConfig.h \
|
||||||
|
@ -90,10 +90,10 @@ HEADERS += src/MainWindow.h \
|
||||||
src/DataDownloader.h \
|
src/DataDownloader.h \
|
||||||
src/AddClientDialog.h \
|
src/AddClientDialog.h \
|
||||||
src/CommandProcess.h \
|
src/CommandProcess.h \
|
||||||
|
src/LoginWindow.h \
|
||||||
src/LoginAuth.h \
|
src/LoginAuth.h \
|
||||||
src/EditionType.h \
|
src/EditionType.h \
|
||||||
src/LoginResult.h \
|
src/LoginResult.h
|
||||||
src/LoginDialog.h
|
|
||||||
RESOURCES += res/Synergy.qrc
|
RESOURCES += res/Synergy.qrc
|
||||||
RC_FILE = res/win/Synergy.rc
|
RC_FILE = res/win/Synergy.rc
|
||||||
macx {
|
macx {
|
||||||
|
|
|
@ -1,167 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>LoginDialog</class>
|
|
||||||
<widget class="QDialog" name="LoginDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>359</width>
|
|
||||||
<height>175</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Synergy</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="pixmap">
|
|
||||||
<pixmap resource="Synergy.qrc">:/res/image/about.png</pixmap>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Minimum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="horizontalSpacing">
|
|
||||||
<number>20</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Email:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="m_pLineEditEmail">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="m_pLineEditPassword">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Minimum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>10</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string><a href="https://synergy-project.org/account/reset/">Forgot password</a></string>
|
|
||||||
</property>
|
|
||||||
<property name="openExternalLinks">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="m_pPushButtonLogin">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Login</string>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Return</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="Synergy.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef LOGINWINDOW_H
|
||||||
|
#define LOGINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#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
|
|
@ -0,0 +1,149 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>LoginWindow</class>
|
||||||
|
<widget class="QMainWindow" name="LoginWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>200</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Synergy</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="Synergy.qrc">:/res/image/about.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="m_pLabelEmail">
|
||||||
|
<property name="text">
|
||||||
|
<string>Email:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="m_pLineEditEmail">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="m_pLabelPassword">
|
||||||
|
<property name="text">
|
||||||
|
<string>Password:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="m_pLineEditPassword">
|
||||||
|
<property name="inputMethodHints">
|
||||||
|
<set>Qt::ImhHiddenText</set>
|
||||||
|
</property>
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_pLabelRegister">
|
||||||
|
<property name="text">
|
||||||
|
<string><a href="http://synergy-project.org/">Register</a></string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_pPushButtonLogin">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Login</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Return</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_pPushButtonCancel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Esc</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="Synergy.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 4.8 KiB |
|
@ -47,7 +47,7 @@ class AppConfig
|
||||||
friend class SettingsDialog;
|
friend class SettingsDialog;
|
||||||
friend class MainWindow;
|
friend class MainWindow;
|
||||||
friend class SetupWizard;
|
friend class SetupWizard;
|
||||||
friend class LoginDialog;
|
friend class LoginWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppConfig(QSettings* settings);
|
AppConfig(QSettings* settings);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "LoginAuth.h"
|
#include "LoginAuth.h"
|
||||||
|
|
||||||
#include "LoginDialog.h"
|
#include "LoginWindow.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
#include "LoginResult.h"
|
#include "LoginResult.h"
|
||||||
|
@ -28,16 +28,16 @@
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
void LoginAuth::checkEditionType()
|
void LoginAuth::checkUserType()
|
||||||
{
|
{
|
||||||
int edition = Unknown;
|
int edition = Unknown;
|
||||||
int result = doCheckEditionType(edition);
|
int result = doCheckUserType(edition);
|
||||||
m_pLoginDialog->setLoginResult(result);
|
m_pLoginWindow->setLoginResult(result);
|
||||||
m_pLoginDialog->setEditionType(edition);
|
m_pLoginWindow->setEditionType(edition);
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoginAuth::doCheckEditionType(int& edition)
|
int LoginAuth::doCheckUserType(int& edition)
|
||||||
{
|
{
|
||||||
QString responseJson;
|
QString responseJson;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ int LoginAuth::doCheckEditionType(int& edition)
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
m_pLoginDialog->setError(e.what());
|
m_pLoginWindow->setError(e.what());
|
||||||
return ExceptionError;
|
return ExceptionError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ int LoginAuth::doCheckEditionType(int& edition)
|
||||||
|
|
||||||
// replace "\n" with real new lines.
|
// replace "\n" with real new lines.
|
||||||
QString error = errorRegex.cap(1).replace("\\n", "\n");
|
QString error = errorRegex.cap(1).replace("\\n", "\n");
|
||||||
m_pLoginDialog->setError(error);
|
m_pLoginWindow->setError(error);
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pLoginDialog->setError(responseJson);
|
m_pLoginWindow->setError(responseJson);
|
||||||
return ServerResponseError;
|
return ServerResponseError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class LoginDialog;
|
class LoginWindow;
|
||||||
class AppConfig;
|
class AppConfig;
|
||||||
|
|
||||||
class LoginAuth : public QObject
|
class LoginAuth : public QObject
|
||||||
|
@ -29,13 +29,13 @@ class LoginAuth : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int doCheckEditionType(int& edition);
|
int doCheckUserType(int& edition);
|
||||||
void setEmail(QString email) { m_Email = email; }
|
void setEmail(QString email) { m_Email = email; }
|
||||||
void setPassword(QString password) { m_Password = password; }
|
void setPassword(QString password) { m_Password = password; }
|
||||||
void setLoginDialog(LoginDialog* d) { m_pLoginDialog = d; }
|
void setLoginWindow(LoginWindow* w) { m_pLoginWindow = w; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void checkEditionType();
|
void checkUserType();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
@ -46,7 +46,7 @@ private:
|
||||||
private:
|
private:
|
||||||
QString m_Email;
|
QString m_Email;
|
||||||
QString m_Password;
|
QString m_Password;
|
||||||
LoginDialog* m_pLoginDialog;
|
LoginWindow* m_pLoginWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOGINAUTH_H
|
#endif // LOGINAUTH_H
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
#ifndef LOGINDIALOG_H
|
|
||||||
#define LOGINDIALOG_H
|
|
||||||
|
|
||||||
#include "ui_LoginDialogBase.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
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
|
|
|
@ -1,172 +1,178 @@
|
||||||
#include "LoginDialog.h"
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
#include "MainWindow.h"
|
* Copyright (C) 2015 Synergy Si Ltd.
|
||||||
#include "SetupWizard.h"
|
*
|
||||||
#include "LoginAuth.h"
|
* This package is free software; you can redistribute it and/or
|
||||||
#include "LoginResult.h"
|
* modify it under the terms of the GNU General Public License
|
||||||
#include "EditionType.h"
|
* found in the file COPYING that should have accompanied this file.
|
||||||
#include "QUtility.h"
|
*
|
||||||
|
* This package is distributed in the hope that it will be useful,
|
||||||
#include <QMessageBox>
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
#include <QCloseEvent>
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
#include <QThread>
|
* GNU General Public License for more details.
|
||||||
#include <QDesktopServices>
|
*
|
||||||
#include <QUrl>
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
static const char registerUrl[] = "http://synergy-project.org";
|
*/
|
||||||
|
|
||||||
LoginDialog::LoginDialog(
|
#include "LoginWindow.h"
|
||||||
MainWindow* mainWindow,
|
#include "ui_LoginWindowBase.h"
|
||||||
SetupWizard* setupWizard,
|
|
||||||
bool wizardShouldRun,
|
#include "MainWindow.h"
|
||||||
QWidget *parent) :
|
#include "SetupWizard.h"
|
||||||
QDialog(parent),
|
#include "LoginAuth.h"
|
||||||
m_pMainWindow(mainWindow),
|
#include "LoginResult.h"
|
||||||
m_pSetupWizard(setupWizard),
|
#include "EditionType.h"
|
||||||
m_WizardShouldRun(wizardShouldRun),
|
#include "QUtility.h"
|
||||||
m_pLoginAuth(NULL),
|
|
||||||
m_LoginResult(Ok),
|
#include <QMessageBox>
|
||||||
m_EditionType(Unknown),
|
#include <QCloseEvent>
|
||||||
m_AppConfig(m_pMainWindow->appConfig())
|
#include <QThread>
|
||||||
{
|
|
||||||
setupUi(this);
|
LoginWindow::LoginWindow(
|
||||||
setFixedSize(size());
|
MainWindow* mainWindow,
|
||||||
m_pLineEditEmail->setText(m_AppConfig.userEmail());
|
SetupWizard* setupWizard,
|
||||||
}
|
bool wizardShouldRun,
|
||||||
|
QWidget *parent) :
|
||||||
LoginDialog::~LoginDialog()
|
QMainWindow(parent),
|
||||||
{
|
m_pMainWindow(mainWindow),
|
||||||
if (m_pLoginAuth != NULL) {
|
m_pSetupWizard(setupWizard),
|
||||||
delete m_pLoginAuth;
|
m_WizardShouldRun(wizardShouldRun),
|
||||||
}
|
m_pLoginAuth(NULL),
|
||||||
}
|
m_LoginResult(Ok),
|
||||||
|
m_EditionType(Unknown),
|
||||||
void LoginDialog::showNext()
|
m_AppConfig(m_pMainWindow->appConfig())
|
||||||
{
|
{
|
||||||
if (m_LoginResult == ExceptionError) {
|
setupUi(this);
|
||||||
QMessageBox::critical(
|
|
||||||
this,
|
m_pLineEditEmail->setText(m_AppConfig.userEmail());
|
||||||
tr("Error"),
|
}
|
||||||
tr("Sorry, an error occured while trying to sign in. "
|
|
||||||
"Please contact the help desk, and provide the "
|
LoginWindow::~LoginWindow()
|
||||||
"following details.\n\n%1").arg(m_Error));
|
{
|
||||||
}
|
if (m_pLoginAuth != NULL) {
|
||||||
else if (m_LoginResult == InvalidEmailPassword) {
|
delete m_pLoginAuth;
|
||||||
QMessageBox::warning(
|
}
|
||||||
this,
|
}
|
||||||
tr("Warning"),
|
|
||||||
tr("Login failed, invalid email or password."));
|
void LoginWindow::showNext()
|
||||||
}
|
{
|
||||||
else if (m_LoginResult == Error) {
|
if (m_LoginResult == ExceptionError) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
this,
|
this,
|
||||||
tr("Error"),
|
tr("Error"),
|
||||||
tr("Login failed, an error occurred.\n\n%1").arg(m_Error));
|
tr("Sorry, an error occured while trying to sign in. "
|
||||||
}
|
"Please contact the help desk, and provide the "
|
||||||
else if (m_LoginResult == ServerResponseError) {
|
"following details.\n\n%1").arg(m_Error));
|
||||||
QMessageBox::critical(
|
}
|
||||||
this,
|
else if (m_LoginResult == InvalidEmailPassword) {
|
||||||
"Error",
|
QMessageBox::critical(
|
||||||
tr("Login failed, an error occurred.\n\nServer response:\n\n%1")
|
this,
|
||||||
.arg(m_Error));
|
tr("Error"),
|
||||||
}
|
tr("Login failed, invalid email or password."));
|
||||||
else {
|
}
|
||||||
hide();
|
else if (m_LoginResult == Error) {
|
||||||
if (m_WizardShouldRun) {
|
QMessageBox::critical(
|
||||||
m_pSetupWizard->show();
|
this,
|
||||||
}
|
tr("Error"),
|
||||||
else {
|
tr("Login failed, an error occurred.\n\n%1").arg(m_Error));
|
||||||
m_pMainWindow->setEditionType(m_EditionType);
|
}
|
||||||
if (!m_pLineEditEmail->text().isEmpty()) {
|
else if (m_LoginResult == ServerResponseError) {
|
||||||
m_AppConfig.setUserEmail(m_pLineEditEmail->text());
|
QMessageBox::critical(
|
||||||
|
this,
|
||||||
if (m_EditionType != Unknown) {
|
"Error",
|
||||||
QString mac = getFirstMacAddress();
|
tr("Login failed, an error occurred.\n\nServer response:\n\n%1")
|
||||||
QString hashSrc = m_pLineEditEmail->text() + mac;
|
.arg(m_Error));
|
||||||
QString hashResult = hash(hashSrc);
|
}
|
||||||
//m_AppConfig.setUserToken(hashResult);
|
else {
|
||||||
//m_AppConfig.setEditionType(m_EditionType);
|
hide();
|
||||||
}
|
if (m_WizardShouldRun) {
|
||||||
}
|
m_pSetupWizard->show();
|
||||||
m_pMainWindow->show();
|
}
|
||||||
}
|
else {
|
||||||
}
|
m_pMainWindow->setEditionType(m_EditionType);
|
||||||
|
if (!m_pLineEditEmail->text().isEmpty()) {
|
||||||
delete m_pLoginAuth;
|
m_AppConfig.setUserEmail(m_pLineEditEmail->text());
|
||||||
m_pLoginAuth = NULL;
|
|
||||||
m_LoginResult = Ok;
|
if (m_EditionType != Unknown) {
|
||||||
m_EditionType = Unknown;
|
QString mac = getFirstMacAddress();
|
||||||
m_pPushButtonLogin->setEnabled(true);
|
QString hashSrc = m_pLineEditEmail->text() + mac;
|
||||||
m_pPushButtonLogin->setDefault(true);
|
QString hashResult = hash(hashSrc);
|
||||||
m_pLineEditEmail->setEnabled(true);
|
m_AppConfig.setUserToken(hashResult);
|
||||||
m_pLineEditPassword->setEnabled(true);
|
m_AppConfig.setEditionType(m_EditionType);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
bool LoginDialog::validEmailPassword()
|
m_pMainWindow->show();
|
||||||
{
|
}
|
||||||
if (m_pLineEditEmail->text().isEmpty() ||
|
}
|
||||||
m_pLineEditPassword->text().isEmpty()) {
|
|
||||||
QMessageBox::warning(
|
delete m_pLoginAuth;
|
||||||
this,
|
m_pLoginAuth = NULL;
|
||||||
"Warning",
|
m_LoginResult = Ok;
|
||||||
tr("Please fill in your email and password."));
|
m_EditionType = Unknown;
|
||||||
return false;
|
m_pPushButtonLogin->setEnabled(true);
|
||||||
}
|
m_pPushButtonLogin->setDefault(true);
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
bool LoginWindow::validEmailPassword()
|
||||||
|
{
|
||||||
void LoginDialog::changeEvent(QEvent *e)
|
if (m_pLineEditEmail->text().isEmpty() ||
|
||||||
{
|
m_pLineEditPassword->text().isEmpty()) {
|
||||||
QDialog::changeEvent(e);
|
QMessageBox::warning(
|
||||||
switch (e->type()) {
|
this,
|
||||||
case QEvent::LanguageChange:
|
"Warning",
|
||||||
retranslateUi(this);
|
tr("Please fill in your email and password."));
|
||||||
break;
|
return false;
|
||||||
default:
|
}
|
||||||
break;
|
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDialog::closeEvent(QCloseEvent *event)
|
void LoginWindow::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
event->accept();
|
QMainWindow::changeEvent(e);
|
||||||
showNext();
|
switch (e->type()) {
|
||||||
}
|
case QEvent::LanguageChange:
|
||||||
|
retranslateUi(this);
|
||||||
void LoginDialog::on_m_pPushButtonLogin_clicked()
|
break;
|
||||||
{
|
default:
|
||||||
if (validEmailPassword()) {
|
break;
|
||||||
if (m_pLoginAuth == NULL) {
|
}
|
||||||
m_pLoginAuth = new LoginAuth();
|
}
|
||||||
m_pLoginAuth->setLoginDialog(this);
|
void LoginWindow::closeEvent(QCloseEvent *event)
|
||||||
}
|
{
|
||||||
|
event->accept();
|
||||||
m_pPushButtonLogin->setEnabled(false);
|
showNext();
|
||||||
m_pLineEditEmail->setEnabled(false);
|
}
|
||||||
m_pLineEditPassword->setEnabled(false);
|
|
||||||
|
void LoginWindow::on_m_pPushButtonLogin_clicked()
|
||||||
QString email = m_pLineEditEmail->text();
|
{
|
||||||
QString password = m_pLineEditPassword->text();
|
if (validEmailPassword()) {
|
||||||
m_pLoginAuth->setEmail(email);
|
if (m_pLoginAuth == NULL) {
|
||||||
m_pLoginAuth->setPassword(password);
|
m_pLoginAuth = new LoginAuth();
|
||||||
|
m_pLoginAuth->setLoginWindow(this);
|
||||||
QThread* thread = new QThread;
|
}
|
||||||
connect(m_pLoginAuth, SIGNAL(finished()), this, SLOT(showNext()));
|
|
||||||
connect(m_pLoginAuth, SIGNAL(finished()), thread, SLOT(quit()));
|
m_pPushButtonLogin->setEnabled(false);
|
||||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
|
||||||
|
QString email = m_pLineEditEmail->text();
|
||||||
m_pLoginAuth->moveToThread(thread);
|
QString password = m_pLineEditPassword->text();
|
||||||
thread->start();
|
m_pLoginAuth->setEmail(email);
|
||||||
|
m_pLoginAuth->setPassword(password);
|
||||||
QMetaObject::invokeMethod(m_pLoginAuth, "checkEditionType", Qt::QueuedConnection);
|
|
||||||
}
|
QThread* thread = new QThread;
|
||||||
}
|
connect(m_pLoginAuth, SIGNAL(finished()), this, SLOT(showNext()));
|
||||||
|
connect(m_pLoginAuth, SIGNAL(finished()), thread, SLOT(quit()));
|
||||||
void LoginDialog::keyPressEvent(QKeyEvent* e) {
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
if(e->key() != Qt::Key_Escape)
|
|
||||||
QDialog::keyPressEvent(e);
|
m_pLoginAuth->moveToThread(thread);
|
||||||
else {
|
thread->start();
|
||||||
close();
|
|
||||||
}
|
QMetaObject::invokeMethod(m_pLoginAuth, "checkUserType", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoginWindow::on_m_pPushButtonCancel_clicked()
|
||||||
|
{
|
||||||
|
showNext();
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LOGINWINDOW_H
|
||||||
|
#define LOGINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#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
|
|
@ -23,7 +23,7 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include "SetupWizard.h"
|
#include "SetupWizard.h"
|
||||||
#include "LoginDialog.h"
|
#include "LoginWindow.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
#include "LoginResult.h"
|
#include "LoginResult.h"
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
MainWindow mainWindow(settings, appConfig);
|
MainWindow mainWindow(settings, appConfig);
|
||||||
SetupWizard setupWizard(mainWindow, true);
|
SetupWizard setupWizard(mainWindow, true);
|
||||||
LoginDialog loginDialog(
|
LoginWindow loginWindow(
|
||||||
&mainWindow,
|
&mainWindow,
|
||||||
&setupWizard,
|
&setupWizard,
|
||||||
appConfig.wizardShouldRun());
|
appConfig.wizardShouldRun());
|
||||||
|
@ -109,7 +109,7 @@ int main(int argc, char* argv[])
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loginDialog.show();
|
loginWindow.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Reference in New Issue