#5659 Move activation notification to SubscriptionManager
This commit is contained in:
parent
540882056f
commit
727fc5c220
|
@ -31,27 +31,11 @@ ActivationDialog::~ActivationDialog()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationDialog::notifyActivation(QString identity)
|
|
||||||
{
|
|
||||||
ActivationNotifier* notifier = new ActivationNotifier();
|
|
||||||
notifier->setIdentity(identity);
|
|
||||||
|
|
||||||
QThread* thread = new QThread();
|
|
||||||
connect(notifier, SIGNAL(finished()), thread, SLOT(quit()));
|
|
||||||
connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater()));
|
|
||||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
|
||||||
|
|
||||||
notifier->moveToThread(thread);
|
|
||||||
thread->start();
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActivationDialog::reject()
|
void ActivationDialog::reject()
|
||||||
{
|
{
|
||||||
CancelActivationDialog cancelActivationDialog(this);
|
CancelActivationDialog cancelActivationDialog(this);
|
||||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||||
notifyActivation("skip:unknown");
|
m_subscriptionManager->notifySkip();
|
||||||
m_appConfig->activationHasRun(true);
|
m_appConfig->activationHasRun(true);
|
||||||
m_appConfig->saveSettings();
|
m_appConfig->saveSettings();
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
|
@ -69,10 +53,7 @@ void ActivationDialog::accept()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
QString serialKey = ui->m_pTextEditSerialKey->toPlainText();
|
QString serialKey = ui->m_pTextEditSerialKey->toPlainText();
|
||||||
SubscriptionManager subscriptionManager (m_appConfig);
|
m_subscriptionManager->setSerialKey(serialKey);
|
||||||
subscriptionManager.setSerialKey (serialKey);
|
|
||||||
notifyActivation("serial:" + m_appConfig->serialKey());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
message.critical(this, "Unknown Error",
|
message.critical(this, "Unknown Error",
|
||||||
|
|
|
@ -23,9 +23,6 @@ public slots:
|
||||||
void reject();
|
void reject();
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
protected:
|
|
||||||
void notifyActivation (QString identity);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ActivationDialog *ui;
|
Ui::ActivationDialog *ui;
|
||||||
AppConfig* m_appConfig;
|
AppConfig* m_appConfig;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "EditionType.h"
|
#include "EditionType.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
SubscriptionManager::SubscriptionManager(AppConfig* appConfig) :
|
SubscriptionManager::SubscriptionManager(AppConfig* appConfig) :
|
||||||
m_AppConfig(appConfig) {
|
m_AppConfig(appConfig) {
|
||||||
|
@ -30,6 +31,28 @@ SubscriptionManager::setSerialKey(QString serialKeyString)
|
||||||
SerialKey serialKey (serialKeyString.toStdString());
|
SerialKey serialKey (serialKeyString.toStdString());
|
||||||
if (serialKey.isValid (::time(0)) && (serialKey != m_serialKey)) {
|
if (serialKey.isValid (::time(0)) && (serialKey != m_serialKey)) {
|
||||||
m_AppConfig->setSerialKey (serialKeyString);
|
m_AppConfig->setSerialKey (serialKeyString);
|
||||||
|
notifyActivation ("serial:" + serialKeyString);
|
||||||
emit serialKeyChanged (serialKey);
|
emit serialKeyChanged (serialKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubscriptionManager::notifySkip()
|
||||||
|
{
|
||||||
|
notifyActivation ("skip:unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubscriptionManager::notifyActivation(QString identity)
|
||||||
|
{
|
||||||
|
ActivationNotifier* notifier = new ActivationNotifier();
|
||||||
|
notifier->setIdentity(identity);
|
||||||
|
|
||||||
|
QThread* thread = new QThread();
|
||||||
|
connect(notifier, SIGNAL(finished()), thread, SLOT(quit()));
|
||||||
|
connect(notifier, SIGNAL(finished()), notifier, SLOT(deleteLater()));
|
||||||
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
notifier->moveToThread(thread);
|
||||||
|
thread->start();
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(notifier, "notify", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <SerialKey.h>
|
#include <SerialKey.h>
|
||||||
|
#include <ActivationNotifier.h>
|
||||||
|
|
||||||
class AppConfig;
|
class AppConfig;
|
||||||
|
|
||||||
|
@ -29,6 +30,10 @@ class SubscriptionManager: public QObject
|
||||||
public:
|
public:
|
||||||
SubscriptionManager (AppConfig* appConfig);
|
SubscriptionManager (AppConfig* appConfig);
|
||||||
void setSerialKey (QString serialKey);
|
void setSerialKey (QString serialKey);
|
||||||
|
void notifySkip ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void notifyActivation (QString identity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
|
@ -36,4 +41,5 @@ private:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void serialKeyChanged (SerialKey);
|
void serialKeyChanged (SerialKey);
|
||||||
|
void editionChanged (Edition);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue