logic: Rewrote license checking logic for trial and app merge

This commit is contained in:
Eberhard Graether
2016-10-08 13:42:40 +02:00
parent ee7bf4e9b7
commit 1b8736a6e1
26 changed files with 228 additions and 176 deletions
+13 -13
View File
@@ -14,23 +14,23 @@ function(ReadLicense licenseFile licenseVariable)
set(LICENSES "${LICENSES}${var}${tempVariable}\"\;" PARENT_SCOPE)
endfunction(ReadLicense)
function(AddLicense licenseName licenseURL licenseFile isNotInTrial)
function(AddLicense licenseName licenseURL licenseFile)
ReadLicense(${licenseFile} ${licenseName}_license)
set(LICENSES ${LICENSES} PARENT_SCOPE)
set(LICENSE_ARRAY "${LICENSE_ARRAY}\n\tThirdPartyLicense(\"${licenseName}\", \"${licenseURL}\", ${licenseName}_license, ${isNotInTrial})," PARENT_SCOPE)
set(LICENSE_ARRAY "${LICENSE_ARRAY}\n\tThirdPartyLicense(\"${licenseName}\", \"${licenseURL}\", ${licenseName}_license)," PARENT_SCOPE)
endfunction(AddLicense)
AddLicense("Qt" "http://qt.io" "${LICENSEFOLDER}/qt_LICENSE.TXT" false)
AddLicense("Clang" "http://clang.llvm.org/" "${LICENSEFOLDER}/clang_LICENSE.TXT" true)
AddLicense("Boost" "http://www.boost.org" "${LICENSEFOLDER}/boost_LICENSE.TXT" false)
AddLicense("TinyXMl" "http://www.grinninglizard.com/tinyxml2/" "${LICENSEFOLDER}/tinyxml_LICENSE.TXT" false)
AddLicense("CppSQLite" "http://www.codeproject.com/Articles/6343/CppSQLite-C-Wrapper-for-SQLite" "${LICENSEFOLDER}/CppSQLite_LICENSE.TXT" false)
AddLicense("Botan" "http://botan.randombit.net/" "${LICENSEFOLDER}/botan_LICENSE.TXT" true)
AddLicense("Guava" "https://github.com/google/guava" "${LICENSEFOLDER}/guava_LICENSE.TXT" true)
AddLicense("Javaparser" "http://javaparser.org/" "${LICENSEFOLDER}/javaparser_LICENSE.TXT" true)
AddLicense("Javaslang" "http://www.javaslang.io/" "${LICENSEFOLDER}/javaslang_LICENSE.TXT" true)
AddLicense("Javassist" "http://www.javassist.org/" "${LICENSEFOLDER}/javassist_LICENSE.TXT" true)
AddLicense("JavaSymbolSolver" "https://github.com/ftomassetti/java-symbol-solver" "${LICENSEFOLDER}/JavaSymbolSolver_LICENSE.TXT" true)
AddLicense("Qt" "http://qt.io" "${LICENSEFOLDER}/qt_LICENSE.TXT")
AddLicense("Clang" "http://clang.llvm.org/" "${LICENSEFOLDER}/clang_LICENSE.TXT")
AddLicense("Boost" "http://www.boost.org" "${LICENSEFOLDER}/boost_LICENSE.TXT")
AddLicense("TinyXMl" "http://www.grinninglizard.com/tinyxml2/" "${LICENSEFOLDER}/tinyxml_LICENSE.TXT")
AddLicense("CppSQLite" "http://www.codeproject.com/Articles/6343/CppSQLite-C-Wrapper-for-SQLite" "${LICENSEFOLDER}/CppSQLite_LICENSE.TXT")
AddLicense("Botan" "http://botan.randombit.net/" "${LICENSEFOLDER}/botan_LICENSE.TXT")
AddLicense("Guava" "https://github.com/google/guava" "${LICENSEFOLDER}/guava_LICENSE.TXT")
AddLicense("Javaparser" "http://javaparser.org/" "${LICENSEFOLDER}/javaparser_LICENSE.TXT")
AddLicense("Javaslang" "http://www.javaslang.io/" "${LICENSEFOLDER}/javaslang_LICENSE.TXT")
AddLicense("Javassist" "http://www.javassist.org/" "${LICENSEFOLDER}/javassist_LICENSE.TXT")
AddLicense("JavaSymbolSolver" "https://github.com/ftomassetti/java-symbol-solver" "${LICENSEFOLDER}/JavaSymbolSolver_LICENSE.TXT")
set(LICENSE_ARRAY "${LICENSE_ARRAY}\n")
+16 -5
View File
@@ -7,12 +7,23 @@ struct ThirdPartyLicense {
const char* name;
const char* url;
const char* license;
const bool isNotInTrial;
ThirdPartyLicense() : name(0), url(0), license(0), isNotInTrial(false) {}
ThirdPartyLicense(const char* name, const char* url, const char* license, const bool isNotInTrial)
: name(name), url(url), license(license), isNotInTrial(isNotInTrial) {}
bool isEmpty() const { return (name == 0 && url == 0 && license == 0); }
ThirdPartyLicense()
: name(0)
, url(0)
, license(0)
{}
ThirdPartyLicense(const char* name, const char* url, const char* license)
: name(name)
, url(url)
, license(license)
{}
bool isEmpty() const
{
return (name == 0 && url == 0 && license == 0);
}
};
// License Textfiles
-1
View File
@@ -1,6 +1,5 @@
add_files(
APP_FILES
isTrial.cpp
main.cpp
)
-6
View File
@@ -1,6 +0,0 @@
#include "isTrial.h"
bool isTrial()
{
return false;
}
+13 -4
View File
@@ -5,7 +5,6 @@
#include "utility/logging/logging.h"
#include "utility/logging/LogManager.h"
#include "utility/messaging/MessageQueue.h"
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/messaging/type/MessageShowStartScreen.h"
#include "utility/scheduling/TaskScheduler.h"
@@ -20,7 +19,6 @@
#include "component/view/MainView.h"
#include "component/view/ViewFactory.h"
#include "data/StorageCache.h"
#include "isTrial.h"
#include "LicenseChecker.h"
#include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h"
@@ -46,10 +44,10 @@ void Application::createInstance(
s_instance->m_mainView = viewFactory->createMainView();
s_instance->m_mainView->setTitle("Coati");
MessageDispatchWhenLicenseValid(std::make_shared<MessageShowStartScreen>()).dispatch();
s_instance->m_componentManager->setup(s_instance->m_mainView.get());
s_instance->m_mainView->loadLayout();
MessageShowStartScreen().dispatch();
}
if (networkFactory != nullptr)
@@ -107,6 +105,7 @@ std::shared_ptr<Application> Application::s_instance;
Application::Application(bool withGUI)
: m_hasGUI(withGUI)
, m_isInTrial(false)
{
LicenseChecker::createInstance();
}
@@ -151,6 +150,11 @@ void Application::setTitle(const std::string& title)
m_mainView->setTitle(title);
}
bool Application::isInTrial() const
{
return m_isInTrial;
}
void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
{
MessageStatus("Loading Project: " + projectSettingsFilePath.str(), false, true).dispatch();
@@ -210,6 +214,11 @@ void Application::handleMessage(MessageActivateWindow* message)
}
}
void Application::handleMessage(MessageEnteredLicense* message)
{
m_isInTrial = false;
}
void Application::handleMessage(MessageFinishedParsing* message)
{
m_project->logStats();
+7
View File
@@ -6,6 +6,7 @@
#include "component/ComponentManager.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageActivateWindow.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRefresh.h"
@@ -24,6 +25,7 @@ class ProjectFactoryModule;
class Application
: public MessageListener<MessageActivateWindow>
, public MessageListener<MessageEnteredLicense>
, public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageLoadProject>
, public MessageListener<MessageRefresh>
@@ -52,12 +54,15 @@ public:
void setTitle(const std::string& title);
bool isInTrial() const;
private:
static std::shared_ptr<Application> s_instance;
Application(bool withGUI=true);
virtual void handleMessage(MessageActivateWindow* message);
virtual void handleMessage(MessageEnteredLicense* message);
virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageLoadProject* message);
virtual void handleMessage(MessageRefresh* message);
@@ -78,6 +83,8 @@ private:
std::shared_ptr<ComponentManager> m_componentManager;
std::shared_ptr<IDECommunicationController> m_ideCommunicationController;
bool m_isInTrial;
};
#endif // APPLICATION_H
-1
View File
@@ -366,7 +366,6 @@ add_files(
Application.cpp
Application.h
isTrial.h
LicenseChecker.cpp
LicenseChecker.h
Project.cpp
+15 -19
View File
@@ -4,7 +4,6 @@
#include "utility/messaging/type/MessageForceEnterLicense.h"
#include "utility/messaging/type/MessageStatus.h"
#include "isTrial.h"
#include "License.h"
#include "PublicKey.h"
#include "settings/ApplicationSettings.h"
@@ -118,29 +117,26 @@ LicenseChecker::LicenseChecker()
void LicenseChecker::handleMessage(MessageDispatchWhenLicenseValid* message)
{
if (!isTrial())
MessageStatus("preparing...", false, true).dispatch();
LicenseState state = checkCurrentLicense();
MessageStatus("ready").dispatch();
if (state == LICENSE_VALID || message->allowTrial)
{
MessageStatus("preparing...", false, true).dispatch();
message->content->dispatch();
}
else
{
m_pendingMessage = message->content;
LicenseState state = checkCurrentLicense();
MessageStatus("ready").dispatch();
if (state != LICENSE_VALID)
if (!m_forcedLicenseEntering)
{
m_pendingMessage = message->content;
if (!m_forcedLicenseEntering)
{
m_forcedLicenseEntering = true;
MessageForceEnterLicense(state == LICENSE_EXPIRED).dispatch();
}
return;
m_forcedLicenseEntering = true;
MessageForceEnterLicense(state == LICENSE_EXPIRED).dispatch();
}
}
message->content->dispatch();
}
void LicenseChecker::handleMessage(MessageEnteredLicense* message)
+1 -1
View File
@@ -2,8 +2,8 @@
#define LICENSE_CHECKER_H
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
class License;
+1 -2
View File
@@ -28,7 +28,6 @@
#include "Application.h"
#include "CxxProject.h"
#include "JavaProject.h"
#include "isTrial.h"
Project::~Project()
{
@@ -86,7 +85,7 @@ bool Project::refresh(bool forceRefresh)
}
}
if (forceRefresh && question.size() && Application::getInstance()->hasGUI() && !isTrial())
if (forceRefresh && question.size() && Application::getInstance()->hasGUI())
{
std::vector<std::string> options;
options.push_back("Yes");
-6
View File
@@ -1,6 +0,0 @@
#ifndef IS_TRIAL_H
#define IS_TRIAL_H
bool isTrial();
#endif // IS_TRIAL_H
@@ -7,8 +7,9 @@ class MessageDispatchWhenLicenseValid
: public Message<MessageDispatchWhenLicenseValid>
{
public:
MessageDispatchWhenLicenseValid(std::shared_ptr<MessageBase> content)
MessageDispatchWhenLicenseValid(std::shared_ptr<MessageBase> content, bool allowTrial = false)
: content(content)
, allowTrial(allowTrial)
{
}
@@ -18,6 +19,7 @@ public:
}
std::shared_ptr<MessageBase> content;
const bool allowTrial;
};
#endif // MESSAGE_DISPATCH_WHEN_LICENSE_VALID_H
+3 -3
View File
@@ -11,9 +11,9 @@
#include "utility/messaging/type/MessageChangeFileView.h"
#include "utility/messaging/type/MessageProjectEdit.h"
#include "Application.h"
#include "data/location/TokenLocation.h"
#include "data/location/TokenLocationFile.h"
#include "isTrial.h"
#include "qt/element/QtCodeNavigator.h"
#include "qt/element/QtCodeSnippet.h"
#include "qt/utility/utilityQt.h"
@@ -144,7 +144,7 @@ QtCodeSnippet* QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
title->setFixedHeight(std::max(title->fontMetrics().height() * 1.2, 28.0));
title->setSizePolicy(title->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
if (isTrial())
if (Application::getInstance()->isInTrial())
{
title->setEnabled(false);
}
@@ -404,7 +404,7 @@ void QtCodeFile::updateSnippets()
void QtCodeFile::updateTitleBar()
{
if (isTrial())
if (Application::getInstance()->isInTrial())
{
return;
}
+11 -5
View File
@@ -10,7 +10,6 @@
#include "qt/utility/utilityQt.h"
#include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h"
#include "isTrial.h"
QtRefreshBar::QtRefreshBar()
{
@@ -28,10 +27,7 @@ QtRefreshBar::QtRefreshBar()
m_refreshButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
layout->addWidget(m_refreshButton);
if (isTrial())
{
m_refreshButton->setEnabled(false);
}
m_refreshButton->setEnabled(false);
connect(m_refreshButton, SIGNAL(clicked()), this, SLOT(refreshClicked()));
@@ -59,3 +55,13 @@ void QtRefreshBar::refreshStyle()
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
));
}
void QtRefreshBar::handleMessage(MessageEnteredLicense* message)
{
m_onQtThread(
[=]()
{
m_refreshButton->setEnabled(true);
}
);
}
+9
View File
@@ -3,10 +3,15 @@
#include <QFrame>
#include "qt/utility/QtThreadedFunctor.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
#include "utility/messaging/MessageListener.h"
class QPushButton;
class QtRefreshBar
: public QFrame
, public MessageListener<MessageEnteredLicense>
{
Q_OBJECT
@@ -20,6 +25,10 @@ private slots:
void refreshClicked();
private:
virtual void handleMessage(MessageEnteredLicense* message);
QtThreadedLambdaFunctor m_onQtThread;
QPushButton* m_refreshButton;
};
+1 -1
View File
@@ -144,7 +144,7 @@ void QtMainView::doSetTitle(const std::string& title)
void QtMainView::doActivateWindow()
{
// It's platform dependent which of these commands does the right thing, for now we just use them all at once.
m_window->activateWindow();
m_window->setEnabled(true);
m_window->raise();
m_window->setFocus(Qt::ActiveWindowFocusReason);
}
+18 -22
View File
@@ -9,7 +9,6 @@
#include <QTextEdit>
#include "licenses.h"
#include "isTrial.h"
QtAboutLicense::QtAboutLicense(QWidget *parent)
: QtWindow(parent)
@@ -30,30 +29,27 @@ void QtAboutLicense::populateWindow(QWidget* widget)
for (ThirdPartyLicense license : licenses3rdParties)
{
if( !(isTrial() && license.isNotInTrial) )
{
QLabel* licenseName = new QLabel();
licenseName->setText( QString::fromLatin1(license.name));
QFont _font = licenseName->font();
_font.setPixelSize(36);
_font.setBold(true);
licenseName->setFont(_font);
layout->addWidget(licenseName);
QLabel* licenseName = new QLabel();
licenseName->setText( QString::fromLatin1(license.name));
QFont _font = licenseName->font();
_font.setPixelSize(36);
_font.setBold(true);
licenseName->setFont(_font);
layout->addWidget(licenseName);
QLabel* licenseURL = new QLabel();
licenseURL->setText(QString::fromLatin1("(<a href=\"%1\">Website</a>)")
.arg(QString::fromLatin1(license.url)));
licenseURL->setOpenExternalLinks(true);
layout->addWidget(licenseURL);
QLabel* licenseURL = new QLabel();
licenseURL->setText(QString::fromLatin1("(<a href=\"%1\">Website</a>)")
.arg(QString::fromLatin1(license.url)));
licenseURL->setOpenExternalLinks(true);
layout->addWidget(licenseURL);
QLabel* licenseText = new QLabel();
licenseText->setFixedWidth(450);
licenseText->setWordWrap(true);
licenseText->setText(QString::fromLatin1(license.license));
layout->addWidget(licenseText);
QLabel* licenseText = new QLabel();
licenseText->setFixedWidth(450);
licenseText->setWordWrap(true);
licenseText->setText(QString::fromLatin1(license.license));
layout->addWidget(licenseText);
layout->addSpacing(50);
}
layout->addSpacing(50);
}
widget->setLayout(layout);
-24
View File
@@ -8,12 +8,10 @@
#include "LicenseChecker.h"
#include "qt/utility/utilityQt.h"
#include "utility/file/FilePath.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
#include "utility/ResourcePaths.h"
QtLicense::QtLicense(QWidget *parent)
: QtWindow(parent)
, m_forced(false)
{
raise();
}
@@ -47,16 +45,9 @@ void QtLicense::load()
m_licenseText->setText(licenseString.c_str());
}
m_forced = false;
updateCloseButton("Cancel");
}
void QtLicense::loadForced()
{
m_forced = true;
updateCloseButton("Quit Coati");
}
void QtLicense::setErrorMessage(const QString& errorMessage)
{
if (m_errorLabel)
@@ -135,18 +126,6 @@ void QtLicense::windowReady()
m_title->hide();
}
void QtLicense::handleClose()
{
if (m_forced)
{
QApplication::quit();
}
else
{
emit canceled();
}
}
void QtLicense::handleNext()
{
std::string licenseString = m_licenseText->toPlainText().toStdString();
@@ -174,9 +153,6 @@ void QtLicense::handleNext()
case LicenseChecker::LICENSE_VALID:
{
checker->saveCurrentLicenseString(licenseString);
MessageEnteredLicense().dispatch();
setCancelAble(true);
m_errorLabel->setText(" ");
emit finished();
-4
View File
@@ -18,7 +18,6 @@ public:
void clear();
void load();
void loadForced();
void setErrorMessage(const QString& errorMessage);
@@ -28,13 +27,10 @@ protected:
virtual void windowReady() override;
virtual void handleNext() override;
virtual void handleClose() override;
private:
QTextEdit* m_licenseText;
QLabel* m_errorLabel;
bool m_forced;
};
#endif // QT_LICENSE_H
+74 -47
View File
@@ -13,6 +13,7 @@
#include "Application.h"
#include "component/view/View.h"
#include "component/view/CompositeView.h"
#include "LicenseChecker.h"
#include "qt/utility/QtContextMenu.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
@@ -26,6 +27,7 @@
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageCodeReference.h"
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
#include "utility/messaging/type/MessageEnteredLicense.h"
#include "utility/messaging/type/MessageFind.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
#include "utility/messaging/type/MessageLoadProject.h"
@@ -40,7 +42,6 @@
#include "utility/tracing.h"
#include "utility/UserPaths.h"
#include "version.h"
#include "isTrial.h"
QtViewToggle::QtViewToggle(View* view, QWidget *parent)
: QWidget(parent)
@@ -278,16 +279,11 @@ void QtMainWindow::forceEnterLicense(bool expired)
{
enterLicenseWindow->clear();
}
enterLicenseWindow->loadForced();
this->setEnabled(false);
enterLicenseWindow->setEnabled(true);
}
bool QtMainWindow::event(QEvent* event)
{
if (isEnabled() && event->type() == QEvent::WindowActivate)
if (event->type() == QEvent::WindowActivate)
{
MessageWindowFocus().dispatch();
}
@@ -318,12 +314,6 @@ void QtMainWindow::contextMenuEvent(QContextMenuEvent* event)
QtContextMenu::getInstance()->showDefault(event, this);
}
void QtMainWindow::activateWindow()
{
this->setEnabled(true);
m_windowStack.popWindow();
}
void QtMainWindow::about()
{
QtAbout* aboutWindow = createWindow<QtAbout>();
@@ -358,11 +348,30 @@ void QtMainWindow::enterLicense()
enterLicenseWindow->setup();
disconnect(enterLicenseWindow, SIGNAL(finished()), &m_windowStack, SLOT(clearWindows()));
connect(enterLicenseWindow, SIGNAL(finished()), this, SLOT(activateWindow()));
connect(enterLicenseWindow, SIGNAL(finished()), this, SLOT(enteredLicense()));
enterLicenseWindow->load();
}
void QtMainWindow::enteredLicense()
{
bool showStartWindow = false;
if (m_windowStack.getWindowCount() > 0 && dynamic_cast<QtStartScreen*>(m_windowStack.getBottomWindow()))
{
showStartWindow = true;
}
m_windowStack.clearWindows();
setTrialActionsEnabled(true);
MessageEnteredLicense().dispatch();
if (showStartWindow)
{
showStartScreen();
}
}
void QtMainWindow::showDataFolder()
{
QDesktopServices::openUrl(QUrl(("file:///" + UserPaths::getUserDataPath()).c_str(), QUrl::TolerantMode));
@@ -376,10 +385,31 @@ void QtMainWindow::showLogFolder()
void QtMainWindow::showStartScreen()
{
QtStartScreen* startScreen = createWindow<QtStartScreen>();
startScreen->setupStartScreen();
LicenseChecker::LicenseState state = LicenseChecker::getInstance()->checkCurrentLicense();
bool licenseValid = (state == LicenseChecker::LICENSE_VALID);
startScreen->setupStartScreen(licenseValid);
setTrialActionsEnabled(licenseValid);
if (licenseValid)
{
MessageEnteredLicense().dispatch();
}
connect(startScreen, SIGNAL(openOpenProjectDialog()), this, SLOT(openProject()));
connect(startScreen, SIGNAL(openNewProjectDialog()), this, SLOT(newProject()));
connect(startScreen, SIGNAL(openEnterLicenseDialog()), this, SLOT(enterLicense()));
if (state == LicenseChecker::LICENSE_MOVED)
{
ApplicationSettings::getInstance()->setLicenseString("");
}
if (state != LicenseChecker::LICENSE_VALID && state != LicenseChecker::LICENSE_EMPTY)
{
forceEnterLicense(state == LicenseChecker::LICENSE_EXPIRED);
}
}
void QtMainWindow::hideStartScreen()
@@ -411,7 +441,8 @@ void QtMainWindow::openProject(const QString &path)
if (!fileName.isEmpty())
{
MessageDispatchWhenLicenseValid(
std::make_shared<MessageLoadProject>(fileName.toStdString(), false)
std::make_shared<MessageLoadProject>(fileName.toStdString(), false),
true
).dispatch();
m_windowStack.clearWindows();
}
@@ -551,11 +582,8 @@ void QtMainWindow::setupProjectMenu()
QMenu *menu = new QMenu(tr("&Project"), this);
menuBar()->addMenu(menu);
if(!isTrial())
{
menu->addAction(tr("&New Project..."), this, SLOT(newProject()), QKeySequence::New);
menu->addAction(tr("&Open Project..."), this, SLOT(openProject()), QKeySequence::Open);
}
m_trialDisabledActions.push_back(menu->addAction(tr("&New Project..."), this, SLOT(newProject()), QKeySequence::New));
m_trialDisabledActions.push_back(menu->addAction(tr("&Open Project..."), this, SLOT(openProject()), QKeySequence::Open));
QMenu *recentProjectMenu = new QMenu(tr("Recent Projects"));
menu->addMenu(recentProjectMenu);
@@ -574,12 +602,8 @@ void QtMainWindow::setupProjectMenu()
menu->addSeparator();
if(!isTrial())
{
menu->addAction(tr("&Edit Project..."), this, SLOT(editProject()));
menu->addSeparator();
}
m_trialDisabledActions.push_back(menu->addAction(tr("&Edit Project..."), this, SLOT(editProject())));
m_trialDisabledActions.push_back(menu->addSeparator());
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
}
@@ -593,22 +617,21 @@ void QtMainWindow::setupEditMenu()
menu->addAction(tr("Forward"), this, SLOT(redo()), QKeySequence::Redo);
menu->addSeparator();
if(!isTrial())
m_trialDisabledActions.push_back(menu->addAction(tr("&Refresh"), this, SLOT(refresh()), QKeySequence::Refresh));
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
menu->addAction(tr("&Refresh"), this, SLOT(refresh()), QKeySequence::Refresh);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5));
}
else
{
menu->addAction(
tr("&Force Refresh"),
this,
SLOT(forceRefresh()),
QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R)
);
}
m_trialDisabledActions.push_back(
menu->addAction(tr("&Force Refresh"), this, SLOT(forceRefresh()), QKeySequence(Qt::SHIFT + Qt::Key_F5))
);
}
else
{
m_trialDisabledActions.push_back(menu->addAction(
tr("&Force Refresh"),
this,
SLOT(forceRefresh()),
QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_R)
));
}
menu->addSeparator();
@@ -661,11 +684,7 @@ void QtMainWindow::setupHelpMenu()
menu->addAction(tr("Documentation"), this, SLOT(showDocumentation()));
menu->addAction(tr("Bug Tracker"), this, SLOT(showBugtracker()));
menu->addAction(tr("Licences"), this, SLOT(showLicenses()));
if(!isTrial())
{
menu->addAction(tr("Enter License..."), this, SLOT(enterLicense()));
}
menu->addAction(tr("Enter License..."), this, SLOT(enterLicense()));
menu->addSeparator();
@@ -673,6 +692,14 @@ void QtMainWindow::setupHelpMenu()
menu->addAction(tr("Show Log Folder"), this, SLOT(showLogFolder()));
}
void QtMainWindow::setTrialActionsEnabled(bool enabled)
{
for (QAction* action : m_trialDisabledActions)
{
action->setEnabled(enabled);
}
}
QtMainWindow::DockWidget* QtMainWindow::getDockWidgetForView(View* view)
{
for (DockWidget& dock : m_dockWidgets)
+5 -2
View File
@@ -93,14 +93,13 @@ protected:
void contextMenuEvent(QContextMenuEvent* event);
public slots:
void activateWindow();
void about();
void openSettings();
void showBugtracker();
void showDocumentation();
void showLicenses();
void enterLicense();
void enteredLicense();
void showDataFolder();
void showLogFolder();
@@ -151,6 +150,8 @@ private:
void setupViewMenu();
void setupHelpMenu();
void setTrialActionsEnabled(bool enabled);
DockWidget* getDockWidgetForView(View* view);
void setShowDockWidgetTitleBars(bool showTitleBars);
@@ -166,6 +167,8 @@ private:
bool m_showDockWidgetTitleBars;
std::vector<QAction*> m_trialDisabledActions;
QtWindowStack m_windowStack;
};
+22 -5
View File
@@ -16,7 +16,6 @@
#include "qt/utility/utilityQt.h"
#include "utility/logging/logging.h"
#include "utility/Version.h"
#include "isTrial.h"
QtRecentProjectButton::QtRecentProjectButton(QWidget* parent)
: QPushButton(parent)
@@ -49,7 +48,8 @@ void QtRecentProjectButton::handleButtonClick()
if (m_projectExists)
{
MessageDispatchWhenLicenseValid(
std::make_shared<MessageLoadProject>(m_projectFilePath.str(), false)
std::make_shared<MessageLoadProject>(m_projectFilePath.str(), false),
true
).dispatch();
}
else
@@ -121,7 +121,7 @@ void QtStartScreen::updateButtons()
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str());
}
void QtStartScreen::setupStartScreen()
void QtStartScreen::setupStartScreen(bool unlocked)
{
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "startscreen/startscreen.css").c_str());
addLogo();
@@ -135,7 +135,7 @@ void QtStartScreen::setupStartScreen()
QVBoxLayout* col = new QVBoxLayout();
layout->addLayout(col, 2);
if (isTrial())
if (!unlocked)
{
col->addSpacing(50);
@@ -153,6 +153,18 @@ void QtStartScreen::setupStartScreen()
col->addWidget(welcomeLabel, 0, Qt::AlignHCenter | Qt::AlignTop);
col->addStretch();
QPushButton* unlockButton = new QPushButton("Unlock", this);
unlockButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
unlockButton->setObjectName("projectButton");
unlockButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
connect(unlockButton, SIGNAL(clicked()), this, SLOT(handleUnlockButton()));
col->addWidget(unlockButton);
QHBoxLayout* row = new QHBoxLayout();
row->addWidget(unlockButton);
row->addStretch();
col->addLayout(row);
layout->addStretch(1);
}
else
@@ -194,7 +206,7 @@ void QtStartScreen::setupStartScreen()
layout->addLayout(col, 1);
QLabel* recentProjectsLabel = new QLabel("Recent Projects: ", this);
if (isTrial())
if (!unlocked)
{
recentProjectsLabel->setText("Projects:");
}
@@ -243,6 +255,11 @@ void QtStartScreen::handleOpenProjectButton()
emit openOpenProjectDialog();
}
void QtStartScreen::handleUnlockButton()
{
emit openEnterLicenseDialog();
}
void QtStartScreen::handleRecentButton()
{
emit finished();
+3 -1
View File
@@ -34,15 +34,17 @@ public:
QtStartScreen(QWidget* parent = 0);
QSize sizeHint() const override;
void setupStartScreen();
void setupStartScreen(bool unlocked);
signals:
void openOpenProjectDialog();
void openNewProjectDialog();
void openEnterLicenseDialog();
private slots:
void handleNewProjectButton();
void handleOpenProjectButton();
void handleUnlockButton();
void handleRecentButton();
void updateButtons();
+10
View File
@@ -21,6 +21,16 @@ QtWindowStackElement* QtWindowStack::getTopWindow()
return nullptr;
}
QtWindowStackElement* QtWindowStack::getBottomWindow()
{
if (m_stack.size())
{
return m_stack.front();
}
return nullptr;
}
size_t QtWindowStack::getWindowCount()
{
return m_stack.size();
+1
View File
@@ -30,6 +30,7 @@ public:
QtWindowStack(QObject* parent = nullptr);
QtWindowStackElement* getTopWindow();
QtWindowStackElement* getBottomWindow();
size_t getWindowCount();
public slots:
+2 -3
View File
@@ -10,7 +10,6 @@
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
#include "Application.h"
#include "isTrial.h"
JavaProject::JavaProject(
std::shared_ptr<JavaProjectSettings> projectSettings, StorageAccessProxy* storageAccessProxy, DialogView* dialogView
@@ -39,7 +38,7 @@ bool JavaProject::prepareIndexing()
m_rootDirectories.reset();
std::string errorString;
if (!JavaEnvironmentFactory::getInstance() && !isTrial())
if (!JavaEnvironmentFactory::getInstance())
{
#ifdef _WIN32
const std::string separator = ";";
@@ -65,7 +64,7 @@ bool JavaProject::prepareIndexing()
MessageStatus(errorString, true, false).dispatch();
}
if (!JavaEnvironmentFactory::getInstance() && !isTrial())
if (!JavaEnvironmentFactory::getInstance())
{
std::string dialogMessage =
"Coati was unable to locate Java on this machine.\nPlease make sure to provide the correct Java Path in the preferences.";