-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauthenticatorwindow.cpp
99 lines (85 loc) · 3.4 KB
/
authenticatorwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "authenticatorwindow.h"
#include "UI/Common/contactwidget.h"
#include "UI/ErrorUi/errorui.h"
#include "app.h"
#include "ui_authenticatorwindow.h"
#include <QStatusBar>
#include <QtConcurrent/QtConcurrentRun>
namespace ikoOSKAR {
namespace UI {
AuthenticatorWindow::AuthenticatorWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::AuthenticatorWindow)
, authenticator(BLL::Authenticator::getInstance())
{
ui->setupUi(this);
ui->lblBanner->setPixmap(QPixmap(":/banner.png").scaled(300, 60, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
QString statusText = QString("%1 v%2").arg(ikoOSKAR::App::longDisplayName, ikoOSKAR::App::applicationVersion());
statusBar()->showMessage(statusText);
statusBar()->setStyleSheet("margin: 3px");
statusBar()->setSizeGripEnabled(false);
auto website = new Common::ContactWidget(
QPixmap(":/web.png"),
"ikooskar.com.tr",
"https://ikooskar.com.tr");
auto email = new Common::ContactWidget(
QPixmap(":/email.png"),
"mailto:[email protected]");
ui->contactCards->layout()->addWidget(website);
ui->contactCards->layout()->addWidget(email);
connect(authenticator, &BLL::Authenticator::error, this, &AuthenticatorWindow::handleError);
connect(authenticator, &BLL::Authenticator::success, this, &AuthenticatorWindow::handleSuccess);
}
AuthenticatorWindow::~AuthenticatorWindow()
{
delete ui;
}
void AuthenticatorWindow::on_btnActivateLicense_clicked()
{
setButtonsEnabled(false);
(void)QtConcurrent::run([&]() {
QString serial = ui->txtSerial->text().trimmed();
authenticator->signupLicensed(serial);
});
}
void AuthenticatorWindow::on_btnStartDemo_clicked()
{
setButtonsEnabled(false);
(void)QtConcurrent::run([&]() {
authenticator->signupDemo();
});
}
void AuthenticatorWindow::handleError(const QString& errorMessage)
{
const QString errorTitle = "Aktivasyon Hatası";
UI::ErrorUi(errorTitle).displayMessage(errorMessage);
ui->txtSerial->clear();
setButtonsEnabled(true);
}
void AuthenticatorWindow::handleSuccess(const QString& message)
{
const QString title = "Aktivasyon Başarılı";
QMessageBox::information(QApplication::activeWindow(), title, message);
emit restartApp();
}
void AuthenticatorWindow::setButtonsEnabled(bool isEnabled)
{
if (isEnabled) {
ui->btnStartDemo->setText("Ücretsiz Deneme Sürümünü Başlat");
ui->btnStartDemo->setStyleSheet("");
ui->btnStartDemo->setEnabled(true);
ui->btnActivateLicense->setText("Etkinleştir");
ui->btnActivateLicense->setStyleSheet("");
ui->btnActivateLicense->setEnabled(true);
} else {
ui->btnStartDemo->setText("Lütfen Bekleyiniz...");
ui->btnStartDemo->setStyleSheet("color: #777777");
ui->btnStartDemo->setEnabled(false);
ui->btnActivateLicense->setText("Lütfen Bekleyiniz...");
ui->btnActivateLicense->setStyleSheet("color: #777777");
ui->btnActivateLicense->setEnabled(false);
}
}
} // namespace UI
} // namespace ikoOSKAR