build,logic : Key/License Generator
Generator using the Botan Cyrptography library
This commit is contained in:
committed by
Eberhard Graether
parent
743f91e882
commit
23257a3071
@@ -107,6 +107,8 @@ add_files(
|
||||
qt/window/QtAboutLicense.h
|
||||
qt/window/QtApplicationSettingsScreen.cpp
|
||||
qt/window/QtApplicationSettingsScreen.h
|
||||
qt/window/QtLicense.cpp
|
||||
qt/window/QtLicense.h
|
||||
qt/window/QtMainWindow.cpp
|
||||
qt/window/QtMainWindow.h
|
||||
qt/window/QtProjectSetupScreen.cpp
|
||||
|
||||
@@ -95,12 +95,7 @@ void QtAbout::setup()
|
||||
closeButton->setObjectName("closeButton");
|
||||
closeButton->move(320, 20);
|
||||
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(handleCloseButtonPress()));
|
||||
}
|
||||
|
||||
void QtAbout::handleCloseButtonPress()
|
||||
{
|
||||
emit finished();
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(handleUpdateButtonPress()));
|
||||
}
|
||||
|
||||
void QtAbout::handleCancelButtonPress()
|
||||
@@ -109,4 +104,5 @@ void QtAbout::handleCancelButtonPress()
|
||||
|
||||
void QtAbout::handleUpdateButtonPress()
|
||||
{
|
||||
emit finished();
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ public:
|
||||
virtual void setup() override;
|
||||
|
||||
private slots:
|
||||
void handleCloseButtonPress();
|
||||
|
||||
void handleCancelButtonPress();
|
||||
void handleUpdateButtonPress();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "qt/window/QtLicense.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QTextBrowser>
|
||||
#include <QTextBlock>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include "License.h"
|
||||
#include "PublicKey.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
QtLicense::QtLicense(QWidget *parent)
|
||||
: QtSettingsWindow(parent)
|
||||
{
|
||||
raise();
|
||||
}
|
||||
|
||||
QSize QtLicense::sizeHint() const
|
||||
{
|
||||
return QSize(600,600);
|
||||
}
|
||||
|
||||
void QtLicense::setup()
|
||||
{
|
||||
setupForm();
|
||||
|
||||
updateTitle("Enter License");
|
||||
updateDoneButton("Ok");
|
||||
}
|
||||
|
||||
void QtLicense::populateForm(QFormLayout* layout)
|
||||
{
|
||||
QLabel* licenseName = new QLabel();
|
||||
licenseName->setText( QString::fromLatin1("Enter License:"));
|
||||
QFont _font = licenseName->font();
|
||||
_font.setPixelSize(36);
|
||||
licenseName->setFont(_font);
|
||||
layout->addWidget(licenseName);
|
||||
|
||||
m_licenseText = new QTextEdit();
|
||||
m_licenseText->setMinimumHeight(300);
|
||||
layout->addWidget(m_licenseText);
|
||||
}
|
||||
|
||||
void QtLicense::handleCancelButtonPress()
|
||||
{
|
||||
emit canceled();
|
||||
}
|
||||
|
||||
void QtLicense::handleUpdateButtonPress()
|
||||
{
|
||||
License license;
|
||||
bool isLoaded = license.loadFromString(m_licenseText->toPlainText().toStdString());
|
||||
if(!isLoaded)
|
||||
{
|
||||
LOG_WARNING("Failed Loading License");
|
||||
return;
|
||||
}
|
||||
license.loadPublicKeyFromString(PublicKey);
|
||||
license.print();
|
||||
|
||||
if(license.isValid())
|
||||
{
|
||||
ApplicationSettings::getInstance()->setLicenseString(license.getLicenseString());
|
||||
FilePath p("");
|
||||
ApplicationSettings::getInstance()->setLicenseCheck(license.hashLocation(p.absolute().str()));
|
||||
ApplicationSettings::getInstance()->save();
|
||||
LOG_WARNING("License saved");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("License is not valid");
|
||||
}
|
||||
emit finished();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef QT_LICENSE_H
|
||||
#define QT_LICENSE_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QtWidgets/qtextedit.h>
|
||||
|
||||
#include "qt/window/QtSettingsWindow.h"
|
||||
|
||||
class QtLicense
|
||||
: public QtSettingsWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtLicense(QWidget* parent = 0);
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void setup() override;
|
||||
protected:
|
||||
virtual void populateForm(QFormLayout* layout) override;
|
||||
|
||||
private slots:
|
||||
void handleCancelButtonPress();
|
||||
void handleUpdateButtonPress();
|
||||
|
||||
private:
|
||||
QPushButton* m_cancelButton;
|
||||
QPushButton* m_updateButton;
|
||||
|
||||
QTextEdit* m_licenseText;
|
||||
|
||||
};
|
||||
|
||||
#endif //QT_LICENSE_H
|
||||
@@ -338,6 +338,20 @@ void QtMainWindow::showLicenses()
|
||||
pushWindow(m_licenseWindow.get());
|
||||
}
|
||||
|
||||
void QtMainWindow::enterLicense()
|
||||
{
|
||||
if (!m_enterLicenseWindow)
|
||||
{
|
||||
m_enterLicenseWindow = std::make_shared<QtLicense>(this);
|
||||
m_enterLicenseWindow->setup();
|
||||
|
||||
connect(m_enterLicenseWindow.get(), SIGNAL(finished()), this, SLOT(popWindow()));
|
||||
connect(m_enterLicenseWindow.get(), SIGNAL(canceled()), this, SLOT(popWindow()));
|
||||
}
|
||||
|
||||
pushWindow(m_enterLicenseWindow)
|
||||
}
|
||||
|
||||
void QtMainWindow::showStartScreen()
|
||||
{
|
||||
if (!m_startScreen)
|
||||
@@ -625,10 +639,11 @@ void QtMainWindow::setupHelpMenu()
|
||||
|
||||
menu->addAction(tr("&About"), this, SLOT(about()));
|
||||
menu->addAction(tr("Licences"), this, SLOT(showLicenses()));
|
||||
|
||||
if(!isTrial())
|
||||
{
|
||||
menu->addAction(tr("Enter License..."), this, SLOT(enterLicense()));
|
||||
menu->addAction(tr("Preferences..."), this, SLOT(openSettings()));
|
||||
//Todo: Enter License Window
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "qt/window/QtProjectSetupScreen.h"
|
||||
#include "qt/window/QtAboutLicense.h"
|
||||
#include "qt/window/QtAbout.h"
|
||||
#include "qt/window/QtLicense.h"
|
||||
|
||||
class QDockWidget;
|
||||
class View;
|
||||
@@ -94,6 +95,7 @@ public slots:
|
||||
void about();
|
||||
void openSettings();
|
||||
void showLicenses();
|
||||
void enterLicense();
|
||||
|
||||
void showStartScreen();
|
||||
void newProject();
|
||||
@@ -109,7 +111,6 @@ public slots:
|
||||
void saveProject();
|
||||
void saveAsProject();
|
||||
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
void zoomIn();
|
||||
@@ -161,6 +162,7 @@ private:
|
||||
std::shared_ptr<QtProjectSetupScreen> m_newProjectDialog;
|
||||
std::shared_ptr<QtAboutLicense> m_licenseWindow;
|
||||
std::shared_ptr<QtAbout> m_aboutWindow;
|
||||
std::shared_ptr<QtLicense> m_enterLicenseWindow;
|
||||
|
||||
std::vector<QWidget*> m_windowStack;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user