logic: iterated on license checking
- moved LicenseChecker from App to Lib project - added MessageDispatchWhenLicenseValid. This message takes another message as an argument which is dispatched once the LicenseChecher confirms the current license key or (if the key is invalid) once the user entered a valid key. This message is used when messages are sent that should not be working when no license key has been entered (LoadProject or ActivateTokenLocation via the IDE communication). - added MessageShowStartScreen which makes the MainView display this screen. This message is also sent via the MessageDispatchWhenLicenseValid. - removed startup project from appsettings.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <QFileOpenEvent>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
|
||||
QtApplication::QtApplication(int& argc, char** argv)
|
||||
@@ -21,7 +22,9 @@ bool QtApplication::event(QEvent *event)
|
||||
|
||||
if (path.exists() && path.extension() == ".coatiproject")
|
||||
{
|
||||
MessageLoadProject(path.str(), false).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(path.str(), false)
|
||||
).dispatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
|
||||
QtMainView::QtMainView()
|
||||
: m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this))
|
||||
: m_createNewProjectFromSolutionFunctor(std::bind(&QtMainView::doCreateNewProjectFromSolution, this, std::placeholders::_1, std::placeholders::_2))
|
||||
, m_showStartScreenFunctor(std::bind(&QtMainView::doShowStartScreen, this))
|
||||
, m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this))
|
||||
, m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1))
|
||||
, m_activateWindowFunctor(std::bind(&QtMainView::doActivateWindow, this))
|
||||
, m_updateRecentProjectMenuFunctor(std::bind(&QtMainView::doUpdateRecentProjectMenu, this))
|
||||
, m_showLicenseScreenFunctor(std::bind(&QtMainView::doShowLicenseScreen, this))
|
||||
, m_forceLicenseScreenFunctor(std::bind(&QtMainView::doForceLicenseScreen, this))
|
||||
{
|
||||
m_window = std::make_shared<QtMainWindow>();
|
||||
m_window->show();
|
||||
m_window->init();
|
||||
}
|
||||
|
||||
QtMainView::~QtMainView()
|
||||
@@ -88,14 +89,32 @@ void QtMainView::updateRecentProjectMenu()
|
||||
m_updateRecentProjectMenuFunctor();
|
||||
}
|
||||
|
||||
void QtMainView::showLicenseScreen()
|
||||
void QtMainView::forceLicenseScreen()
|
||||
{
|
||||
m_showLicenseScreenFunctor();
|
||||
m_forceLicenseScreenFunctor();
|
||||
}
|
||||
|
||||
void QtMainView::doUpdateRecentProjectMenu()
|
||||
void QtMainView::handleMessage(MessageProjectNew* message)
|
||||
{
|
||||
m_window->updateRecentProjectMenu();
|
||||
if (message->ideId.size() != 0 && message->solutionPath.size() != 0)
|
||||
{
|
||||
m_createNewProjectFromSolutionFunctor(message->ideId, message->solutionPath);
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainView::handleMessage(MessageShowStartScreen* message)
|
||||
{
|
||||
m_showStartScreenFunctor();
|
||||
}
|
||||
|
||||
void QtMainView::doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
{
|
||||
m_window->newProjectFromSolution(ideId, solutionPath);
|
||||
}
|
||||
|
||||
void QtMainView::doShowStartScreen()
|
||||
{
|
||||
m_window->showStartScreen();
|
||||
}
|
||||
|
||||
void QtMainView::doHideStartScreen()
|
||||
@@ -116,7 +135,12 @@ void QtMainView::doActivateWindow()
|
||||
m_window->setFocus(Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
void QtMainView::doShowLicenseScreen()
|
||||
void QtMainView::doUpdateRecentProjectMenu()
|
||||
{
|
||||
m_window->updateRecentProjectMenu();
|
||||
}
|
||||
|
||||
void QtMainView::doForceLicenseScreen()
|
||||
{
|
||||
m_window->forceEnterLicense();
|
||||
}
|
||||
|
||||
@@ -9,11 +9,17 @@
|
||||
#include "component/view/MainView.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
#include "utility/messaging/type/MessageShowStartScreen.h"
|
||||
|
||||
class QtMainWindow;
|
||||
class View;
|
||||
|
||||
class QtMainView
|
||||
: public MainView
|
||||
, public MessageListener<MessageProjectNew>
|
||||
, public MessageListener<MessageShowStartScreen>
|
||||
{
|
||||
public:
|
||||
QtMainView();
|
||||
@@ -37,23 +43,30 @@ public:
|
||||
virtual void setTitle(const std::string& title);
|
||||
virtual void activateWindow();
|
||||
virtual void updateRecentProjectMenu();
|
||||
virtual void showLicenseScreen();
|
||||
virtual void forceLicenseScreen();
|
||||
|
||||
private:
|
||||
void handleMessage(MessageProjectNew* message);
|
||||
void handleMessage(MessageShowStartScreen* message);
|
||||
|
||||
void doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void doShowStartScreen();
|
||||
void doHideStartScreen();
|
||||
void doSetTitle(const std::string& title);
|
||||
void doActivateWindow();
|
||||
void doUpdateRecentProjectMenu();
|
||||
void doShowLicenseScreen();
|
||||
void doForceLicenseScreen();
|
||||
|
||||
std::shared_ptr<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
QtThreadedFunctor<const std::string&, const std::string&> m_createNewProjectFromSolutionFunctor;
|
||||
QtThreadedFunctor<> m_showStartScreenFunctor;
|
||||
QtThreadedFunctor<> m_hideStartScreenFunctor;
|
||||
QtThreadedFunctor<const std::string&> m_setTitleFunctor;
|
||||
QtThreadedFunctor<> m_activateWindowFunctor;
|
||||
QtThreadedFunctor<> m_updateRecentProjectMenuFunctor;
|
||||
QtThreadedFunctor<> m_showLicenseScreenFunctor;
|
||||
QtThreadedFunctor<> m_forceLicenseScreenFunctor;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_VIEW_H
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
@@ -130,7 +131,6 @@ void MouseWheelFilter::stopWaiting()
|
||||
QtMainWindow::QtMainWindow()
|
||||
: m_showDockWidgetTitleBars(true)
|
||||
, m_windowStack(this)
|
||||
, m_createNewProjectFunctor(std::bind(&QtMainWindow::doCreateNewProject, this, std::placeholders::_1))
|
||||
{
|
||||
setObjectName("QtMainWindow");
|
||||
setCentralWidget(nullptr);
|
||||
@@ -161,11 +161,6 @@ QtMainWindow::QtMainWindow()
|
||||
loadLayout();
|
||||
}
|
||||
|
||||
void QtMainWindow::init()
|
||||
{
|
||||
showStartScreen();
|
||||
}
|
||||
|
||||
QtMainWindow::~QtMainWindow()
|
||||
{
|
||||
if (m_recentProjectAction)
|
||||
@@ -285,12 +280,6 @@ void QtMainWindow::forceEnterLicense()
|
||||
enterLicenseWindow->setEnabled(true);
|
||||
}
|
||||
|
||||
void QtMainWindow::handleMessage(MessageProjectNew* message)
|
||||
{
|
||||
MessageProjectNew msg(*message);
|
||||
m_createNewProjectFunctor(msg);
|
||||
}
|
||||
|
||||
bool QtMainWindow::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowActivate)
|
||||
@@ -374,6 +363,12 @@ void QtMainWindow::newProject()
|
||||
wizzard->newProject();
|
||||
}
|
||||
|
||||
void QtMainWindow::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
|
||||
{
|
||||
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
|
||||
wizzard->newProjectFromSolution(ideId, solutionPath);
|
||||
}
|
||||
|
||||
void QtMainWindow::openProject(const QString &path)
|
||||
{
|
||||
QString fileName = path;
|
||||
@@ -385,7 +380,9 @@ void QtMainWindow::openProject(const QString &path)
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
MessageLoadProject(fileName.toStdString(), false).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(fileName.toStdString(), false)
|
||||
).dispatch();
|
||||
m_windowStack.clearWindows();
|
||||
}
|
||||
}
|
||||
@@ -573,20 +570,6 @@ void QtMainWindow::toggleShowDockWidgetTitleBars()
|
||||
setShowDockWidgetTitleBars(!m_showDockWidgetTitleBars);
|
||||
}
|
||||
|
||||
void QtMainWindow::doCreateNewProject(MessageProjectNew message)
|
||||
{
|
||||
QtProjectWizzard* wizzard = createWindow<QtProjectWizzard>();
|
||||
|
||||
if (message.fromSolution())
|
||||
{
|
||||
wizzard->newProjectFromSolution(message.ideId ,message.solutionPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
wizzard->newProject();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::setupEditMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(tr("&Edit"), this);
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#include <QMainWindow>
|
||||
#include <QShortcut>
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageProjectNew.h"
|
||||
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "qt/window/QtWindowStack.h"
|
||||
|
||||
@@ -72,7 +69,6 @@ private:
|
||||
|
||||
class QtMainWindow
|
||||
: public QMainWindow
|
||||
, public MessageListener<MessageProjectNew>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -80,8 +76,6 @@ public:
|
||||
QtMainWindow();
|
||||
~QtMainWindow();
|
||||
|
||||
void init();
|
||||
|
||||
void addView(View* view);
|
||||
void removeView(View* view);
|
||||
|
||||
@@ -93,8 +87,6 @@ public:
|
||||
|
||||
void forceEnterLicense();
|
||||
|
||||
void handleMessage(MessageProjectNew* message);
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
@@ -113,6 +105,7 @@ public slots:
|
||||
void hideStartScreen();
|
||||
|
||||
void newProject();
|
||||
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void openProject(const QString &path = QString());
|
||||
void editProject();
|
||||
void openRecentProject();
|
||||
@@ -152,8 +145,6 @@ private:
|
||||
QtViewToggle* toggle;
|
||||
};
|
||||
|
||||
void doCreateNewProject(MessageProjectNew message);
|
||||
|
||||
void setupEditMenu();
|
||||
void setupProjectMenu();
|
||||
void setupViewMenu();
|
||||
@@ -178,8 +169,6 @@ private:
|
||||
QtWindowStack m_windowStack;
|
||||
|
||||
QShortcut* m_escapeShortcut;
|
||||
|
||||
QtThreadedFunctor<MessageProjectNew> m_createNewProjectFunctor;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_WINDOW_H
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
@@ -31,7 +32,7 @@ void QtRecentProjectButton::setProjectPath(const FilePath& projectFilePath)
|
||||
m_projectFilePath = projectFilePath;
|
||||
m_projectExists = projectFilePath.exists();
|
||||
this->setText(m_projectFilePath.withoutExtension().fileName().c_str());
|
||||
if ( m_projectExists )
|
||||
if (m_projectExists)
|
||||
{
|
||||
this->setToolTip(m_projectFilePath.str().c_str());
|
||||
}
|
||||
@@ -44,9 +45,11 @@ void QtRecentProjectButton::setProjectPath(const FilePath& projectFilePath)
|
||||
|
||||
void QtRecentProjectButton::handleButtonClick()
|
||||
{
|
||||
if ( m_projectExists )
|
||||
if (m_projectExists)
|
||||
{
|
||||
MessageLoadProject(m_projectFilePath.str(), false).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(m_projectFilePath.str(), false)
|
||||
).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,14 +57,13 @@ void QtRecentProjectButton::handleButtonClick()
|
||||
+ " in your filesystem. Delete it from this recent Proejct list?";
|
||||
int ret = QMessageBox::question(this, "Missing Project File", text.c_str(), QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if ( ret == QMessageBox::Yes )
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
for (int i = 0
|
||||
; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount()
|
||||
; i++)
|
||||
const int maxRecentProjectsCount = ApplicationSettings::getInstance()->getMaxRecentProjectsCount();
|
||||
for (int i = 0; i < maxRecentProjectsCount; i++)
|
||||
{
|
||||
if (recentProjects[i].str() == m_projectFilePath.str() )
|
||||
if (recentProjects[i].str() == m_projectFilePath.str())
|
||||
{
|
||||
recentProjects.erase(recentProjects.begin()+i);
|
||||
ApplicationSettings::getInstance()->setRecentProjects(recentProjects);
|
||||
@@ -90,7 +92,7 @@ void QtStartScreen::updateButtons()
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
size_t i = 0;
|
||||
for ( QtRecentProjectButton* button : m_recentProjectsButtons )
|
||||
for (QtRecentProjectButton* button : m_recentProjectsButtons)
|
||||
{
|
||||
button->disconnect();
|
||||
if (i < recentProjects.size())
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceList.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
|
||||
// #include "utility/solution/SolutionParserCompilationDatabase.h"
|
||||
#include "utility/solution/SolutionParserVisualStudio.h"
|
||||
#include "utility/solution/SolutionParserCodeBlocks.h"
|
||||
|
||||
@@ -597,7 +597,9 @@ void QtProjectWizzard::createProject()
|
||||
|
||||
bool forceRefresh = !(m_settings == *ProjectSettings::getInstance().get());
|
||||
|
||||
MessageLoadProject(path, forceRefresh).dispatch();
|
||||
MessageDispatchWhenLicenseValid(
|
||||
std::make_shared<MessageLoadProject>(path, forceRefresh)
|
||||
).dispatch();
|
||||
|
||||
m_windowStack.clearWindows();
|
||||
emit finished();
|
||||
|
||||
Reference in New Issue
Block a user