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:
malte_langkabel
2016-04-14 15:25:40 +02:00
parent a2cba0b94f
commit 73ee3a27d9
29 changed files with 406 additions and 333 deletions
+10 -27
View File
@@ -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);
+1 -12
View File
@@ -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
+11 -9
View File
@@ -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();