#5657 Raise activation dialog when key expires
This commit is contained in:
parent
f441c24a23
commit
e01d0ce4c7
|
@ -54,6 +54,57 @@ p, li { white-space: pre-wrap; }
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="m_trialWidget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="Synergy.qrc">:/res/icons/16x16/money.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_trialLabel">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Your trial has expired. <a href="http://symless.com/pricing?src=gui"><span style=" text-decoration: underline; color:#0000ff;">Buy now!</span></a></p></body></html></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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
|
@ -66,7 +117,9 @@ p, li { white-space: pre-wrap; }
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="Synergy.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
|
|
|
@ -23,6 +23,10 @@ ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig,
|
|||
{
|
||||
ui->setupUi(this);
|
||||
refreshSerialKey();
|
||||
time_t currentTime = ::time(0);
|
||||
if (!m_LicenseManager->serialKey().isExpired(currentTime)) {
|
||||
ui->m_trialWidget->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivationDialog::refreshSerialKey()
|
||||
|
|
|
@ -91,8 +91,10 @@ LicenseManager::serialKey() const
|
|||
|
||||
void LicenseManager::refresh(bool acceptExpired)
|
||||
{
|
||||
if (!m_AppConfig->serialKey().isEmpty()) {
|
||||
setSerialKey(m_AppConfig->serialKey(), acceptExpired);
|
||||
}
|
||||
}
|
||||
|
||||
void LicenseManager::skipActivation()
|
||||
{
|
||||
|
|
|
@ -420,8 +420,10 @@ void MainWindow::appendLogRaw(const QString& text)
|
|||
|
||||
void MainWindow::updateFromLogLine(const QString &line)
|
||||
{
|
||||
// TODO: this code makes Andrew cry
|
||||
checkConnected(line);
|
||||
checkFingerprint(line);
|
||||
checkLicense(line);
|
||||
}
|
||||
|
||||
void MainWindow::checkConnected(const QString& line)
|
||||
|
@ -449,7 +451,7 @@ void MainWindow::checkConnected(const QString& line)
|
|||
void MainWindow::checkLicense(const QString &line)
|
||||
{
|
||||
if (line.contains("trial has expired")) {
|
||||
m_LicenseManager->refresh(true);
|
||||
raiseActivationDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -541,6 +543,14 @@ void MainWindow::clearLog()
|
|||
|
||||
void MainWindow::startSynergy()
|
||||
{
|
||||
SerialKey serialKey = m_LicenseManager->serialKey();
|
||||
time_t currentTime = ::time(0);
|
||||
if (serialKey.isExpired(currentTime)) {
|
||||
if (QDialog::Rejected == raiseActivationDialog()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool desktopMode = appConfig().processMode() == Desktop;
|
||||
bool serviceMode = appConfig().processMode() == Service;
|
||||
|
||||
|
@ -1233,11 +1243,7 @@ void MainWindow::on_m_pButtonConfigureServer_clicked()
|
|||
|
||||
void MainWindow::on_m_pActivate_triggered()
|
||||
{
|
||||
ActivationDialog activationDialog(this, appConfig(), licenseManager());
|
||||
m_ActivationDialogRunning = true;
|
||||
connect (&activationDialog, SIGNAL(finished(int)),
|
||||
this, SLOT(on_activationDialogFinish()), Qt::QueuedConnection);
|
||||
activationDialog.exec();
|
||||
raiseActivationDialog();
|
||||
}
|
||||
|
||||
void MainWindow::on_m_pButtonApply_clicked()
|
||||
|
@ -1452,22 +1458,16 @@ void MainWindow::bonjourInstallFinished()
|
|||
m_pCheckBoxAutoConfig->setChecked(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_windowShown()
|
||||
int MainWindow::raiseActivationDialog()
|
||||
{
|
||||
time_t currentTime = ::time(0);
|
||||
if (!m_AppConfig->activationHasRun()
|
||||
&& ((m_AppConfig->edition() == kUnregistered) ||
|
||||
(m_LicenseManager->serialKey().isExpired(currentTime)))) {
|
||||
if (m_ActivationDialogRunning) {
|
||||
return QDialog::Rejected;
|
||||
}
|
||||
ActivationDialog activationDialog (this, appConfig(), licenseManager());
|
||||
m_ActivationDialogRunning = true;
|
||||
connect (&activationDialog, SIGNAL(finished(int)),
|
||||
this, SLOT(on_activationDialogFinish()), Qt::QueuedConnection);
|
||||
activationDialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_activationDialogFinish()
|
||||
{
|
||||
int result = activationDialog.exec();
|
||||
m_ActivationDialogRunning = false;
|
||||
if (!m_PendingClientNames.empty()) {
|
||||
foreach (const QString& name, m_PendingClientNames) {
|
||||
|
@ -1476,6 +1476,20 @@ void MainWindow::on_activationDialogFinish()
|
|||
|
||||
m_PendingClientNames.clear();
|
||||
}
|
||||
if (result == QDialog::Accepted) {
|
||||
restartSynergy();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void MainWindow::on_windowShown()
|
||||
{
|
||||
time_t currentTime = ::time(0);
|
||||
if (!m_AppConfig->activationHasRun()
|
||||
&& ((m_AppConfig->edition() == kUnregistered) ||
|
||||
(m_LicenseManager->serialKey().isExpired(currentTime)))) {
|
||||
raiseActivationDialog();
|
||||
}
|
||||
}
|
||||
|
||||
QString MainWindow::getProfileRootForArg()
|
||||
|
|
|
@ -120,6 +120,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
|||
void updateLocalFingerprint();
|
||||
LicenseManager& licenseManager() const;
|
||||
|
||||
int raiseActivationDialog();
|
||||
|
||||
public slots:
|
||||
void setEdition(Edition edition);
|
||||
void beginTrial(bool isExpiring);
|
||||
|
@ -230,7 +232,6 @@ private slots:
|
|||
void on_m_pButtonApply_clicked();
|
||||
void installBonjour();
|
||||
void on_windowShown();
|
||||
void on_activationDialogFinish();
|
||||
|
||||
signals:
|
||||
void windowShown();
|
||||
|
|
Loading…
Reference in New Issue