#5629 Change activation failure to a QDialog

This commit is contained in:
Andrew Nelless 2016-10-03 11:54:45 +01:00 committed by Andrew Nelless
parent c799041ce8
commit d6bcdcbea7
6 changed files with 156 additions and 7 deletions

View File

@ -18,7 +18,8 @@ FORMS += res/MainWindowBase.ui \
res/SetupWizardBase.ui \ res/SetupWizardBase.ui \
res/AddClientDialogBase.ui \ res/AddClientDialogBase.ui \
res/ActivationDialog.ui \ res/ActivationDialog.ui \
res/CancelActivationDialog.ui res/CancelActivationDialog.ui \
res/FailedLoginDialog.ui
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/MainWindow.cpp \ src/MainWindow.cpp \
src/AboutDialog.cpp \ src/AboutDialog.cpp \
@ -62,7 +63,8 @@ SOURCES += src/main.cpp \
src/SubscriptionManager.cpp \ src/SubscriptionManager.cpp \
src/ActivationNotifier.cpp \ src/ActivationNotifier.cpp \
src/ActivationDialog.cpp \ src/ActivationDialog.cpp \
src/CancelActivationDialog.cpp src/CancelActivationDialog.cpp \
src/FailedLoginDialog.cpp
HEADERS += src/MainWindow.h \ HEADERS += src/MainWindow.h \
src/AboutDialog.h \ src/AboutDialog.h \
src/ServerConfig.h \ src/ServerConfig.h \
@ -109,7 +111,8 @@ HEADERS += src/MainWindow.h \
src/ActivationNotifier.h \ src/ActivationNotifier.h \
src/ElevateMode.h \ src/ElevateMode.h \
src/ActivationDialog.h \ src/ActivationDialog.h \
src/CancelActivationDialog.h src/CancelActivationDialog.h \
src/FailedLoginDialog.h
RESOURCES += res/Synergy.qrc RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc RC_FILE = res/win/Synergy.rc
macx { macx {

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FailedLoginDialog</class>
<widget class="QDialog" name="FailedLoginDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>165</height>
</rect>
</property>
<property name="windowTitle">
<string>Activation Error</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>50</x>
<y>120</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>382</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://symless.com/account/reset/?source=gui&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Forgotten your password?&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="messageLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>382</width>
<height>72</height>
</rect>
</property>
<property name="text">
<string>An error occurred while trying to activate Synergy. The Symless server returned the following error:
%1</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
<zorder>label_2</zorder>
<zorder>messageLabel</zorder>
<zorder>buttonBox</zorder>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>FailedLoginDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>FailedLoginDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -8,6 +8,7 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "QUtility.h" #include "QUtility.h"
#include "SubscriptionManager.h" #include "SubscriptionManager.h"
#include "FailedLoginDialog.h"
#include <QMessageBox> #include <QMessageBox>
#include <QThread> #include <QThread>
@ -116,9 +117,8 @@ void ActivationDialog::accept()
return; return;
} }
else if (!webClient.getEdition (edition, error)) { else if (!webClient.getEdition (edition, error)) {
message.critical (this, "Activation Error", FailedLoginDialog failedLoginDialog (this, error);
tr("An error occurred while trying to activate Synergy. " failedLoginDialog.exec();
"The Symless server returned the following error:\n\n%1").arg(error));
return; return;
} }

View File

@ -0,0 +1,15 @@
#include "FailedLoginDialog.h"
#include "ui_FailedLoginDialog.h"
FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message):
QDialog(parent),
ui(new Ui::FailedLoginDialog)
{
ui->setupUi(this);
ui->messageLabel->setText(ui->messageLabel->text().arg(message));
}
FailedLoginDialog::~FailedLoginDialog()
{
delete ui;
}

View File

@ -0,0 +1,23 @@
#ifndef FAILEDLOGINDIALOG_H
#define FAILEDLOGINDIALOG_H
#include <QDialog>
#include <QString>
namespace Ui {
class FailedLoginDialog;
}
class FailedLoginDialog : public QDialog
{
Q_OBJECT
public:
explicit FailedLoginDialog(QWidget *parent = 0, QString message = "");
~FailedLoginDialog();
private:
Ui::FailedLoginDialog *ui;
};
#endif // FAILEDLOGINDIALOG_H

View File

@ -46,7 +46,7 @@ WebClient::getEdition (int& edition, QString& errorOut) {
throw std::runtime_error ("Unrecognised server response."); throw std::runtime_error ("Unrecognised server response.");
} }
} else { } else {
errorOut = tr("Login failed. Invalid email or password."); errorOut = tr("Login failed. Invalid email address or password.");
return false; return false;
} }
} else { } else {