ui: Don't show start window when opening project with double-click

* added menu option to show start window
This commit is contained in:
Eberhard Graether
2017-07-17 17:07:01 +02:00
parent 4bb88a51b7
commit 1982f4459a
12 changed files with 136 additions and 126 deletions
+12 -10
View File
@@ -150,6 +150,18 @@ void QtMainView::handleMessage(MessageForceEnterLicense* message)
);
}
void QtMainView::handleMessage(MessageLoadProject* message)
{
bool showStartWindow = message->projectSettingsFilePath.empty();
m_onQtThread(
[=]()
{
m_window->loadWindow(showStartWindow);
}
);
}
void QtMainView::handleMessage(MessageProjectEdit* message)
{
m_onQtThread(
@@ -172,13 +184,3 @@ void QtMainView::handleMessage(MessageProjectNew* message)
}
);
}
void QtMainView::handleMessage(MessageShowStartScreen* message)
{
m_onQtThread(
[=]()
{
m_window->showStartScreen();
}
);
}
+3 -3
View File
@@ -11,9 +11,9 @@
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageForceEnterLicense.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageProjectEdit.h"
#include "utility/messaging/type/MessageProjectNew.h"
#include "utility/messaging/type/MessageShowStartScreen.h"
class QtMainWindow;
class View;
@@ -21,9 +21,9 @@ class View;
class QtMainView
: public MainView
, public MessageListener<MessageForceEnterLicense>
, public MessageListener<MessageLoadProject>
, public MessageListener<MessageProjectEdit>
, public MessageListener<MessageProjectNew>
, public MessageListener<MessageShowStartScreen>
{
public:
QtMainView();
@@ -55,9 +55,9 @@ public:
private:
void handleMessage(MessageForceEnterLicense* message);
void handleMessage(MessageLoadProject* message);
void handleMessage(MessageProjectEdit* message);
void handleMessage(MessageProjectNew* message);
void handleMessage(MessageShowStartScreen* message);
std::shared_ptr<QtMainWindow> m_window;
std::vector<View*> m_views;
+48 -28
View File
@@ -99,7 +99,8 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
QtMainWindow::QtMainWindow()
: m_historyMenu(nullptr)
: m_loaded(false)
, m_historyMenu(nullptr)
, m_bookmarksMenu(nullptr)
, m_showDockWidgetTitleBars(true)
, m_windowStack(this)
@@ -224,7 +225,48 @@ void QtMainWindow::loadDockWidgetLayout()
{
dock.action->setChecked(!dock.widget->isHidden());
}
}
void QtMainWindow::loadWindow(bool showStartWindow)
{
if (m_loaded)
{
return;
}
m_loaded = true;
LicenseChecker::LicenseState state = LicenseChecker::getInstance()->checkCurrentLicense();
bool licenseValid = (state == LicenseChecker::LICENSE_VALID);
if (licenseValid)
{
MessageEnteredLicense(LicenseChecker::getInstance()->getCurrentLicenseType()).dispatch();
}
setTrialActionsEnabled(licenseValid);
if (state == LicenseChecker::LICENSE_MOVED)
{
ApplicationSettings::getInstance()->setLicenseString("");
}
if (showStartWindow)
{
showStartScreen();
}
if (state != LicenseChecker::LICENSE_VALID && state != LicenseChecker::LICENSE_EMPTY)
{
forceEnterLicense(state == LicenseChecker::LICENSE_EXPIRED);
}
#ifndef Q_OS_WIN
if (ApplicationSettings::getInstance()->getAcceptedEulaVersion() < QtEulaWindow::EULA_VERSION)
{
showEula(true);
}
#endif
}
void QtMainWindow::saveLayout()
@@ -446,41 +488,17 @@ void QtMainWindow::showLogFolder()
void QtMainWindow::showStartScreen()
{
LicenseChecker::LicenseState state = LicenseChecker::getInstance()->checkCurrentLicense();
bool licenseValid = (state == LicenseChecker::LICENSE_VALID);
if (licenseValid)
if (dynamic_cast<QtStartScreen*>(m_windowStack.getTopWindow()))
{
MessageEnteredLicense(LicenseChecker::getInstance()->getCurrentLicenseType()).dispatch();
return;
}
setTrialActionsEnabled(licenseValid);
if (state == LicenseChecker::LICENSE_MOVED)
{
ApplicationSettings::getInstance()->setLicenseString("");
}
QtStartScreen* startScreen = createWindow<QtStartScreen>();
startScreen->setupStartScreen(licenseValid);
startScreen->setupStartScreen();
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_VALID && state != LicenseChecker::LICENSE_EMPTY)
{
forceEnterLicense(state == LicenseChecker::LICENSE_EXPIRED);
}
#ifndef Q_OS_WIN
if (ApplicationSettings::getInstance()->getAcceptedEulaVersion() < QtEulaWindow::EULA_VERSION)
{
showEula(true);
}
#endif
}
void QtMainWindow::hideStartScreen()
@@ -769,6 +787,8 @@ void QtMainWindow::setupViewMenu()
QMenu *menu = new QMenu(tr("&View"), this);
menuBar()->addMenu(menu);
menu->addAction(tr("Show Start Window"), this, SLOT(showStartScreen()));
m_showTitleBarsAction = new QAction("Show Title Bars", this);
m_showTitleBarsAction->setCheckable(true);
m_showTitleBarsAction->setChecked(m_showDockWidgetTitleBars);
+4
View File
@@ -67,6 +67,7 @@ public:
void saveLayout();
void loadDockWidgetLayout();
void loadWindow(bool showStartWindow);
void forceEnterLicense(bool expired);
@@ -163,6 +164,9 @@ private:
T* createWindow();
std::vector<DockWidget> m_dockWidgets;
bool m_loaded;
QMenu* m_viewMenu;
QAction* m_viewSeparator;
+16 -14
View File
@@ -14,6 +14,7 @@
#include "qt/utility/utilityQt.h"
#include "utility/Version.h"
#include "License.h"
#include "PublicKey.h"
#include "utility/AppPath.h"
QtRecentProjectButton::QtRecentProjectButton(QWidget* parent)
@@ -138,8 +139,13 @@ size_t i = 0;
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str());
}
void QtStartScreen::setupStartScreen(bool unlocked)
void QtStartScreen::setupStartScreen()
{
License license;
license.loadFromEncodedString(ApplicationSettings::getInstance()->getLicenseString(), AppPath::getAppPath());
license.loadPublicKeyFromString(PUBLIC_KEY);
bool licenseValid = license.isValid();
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("startscreen/startscreen.css"))).c_str());
addLogo();
@@ -152,7 +158,7 @@ void QtStartScreen::setupStartScreen(bool unlocked)
QVBoxLayout* col = new QVBoxLayout();
layout->addLayout(col, 2);
if (!unlocked)
if (!licenseValid)
{
col->addSpacing(4);
@@ -207,19 +213,15 @@ void QtStartScreen::setupStartScreen(bool unlocked)
col->addSpacing(20);
License license;
license.loadFromEncodedString(
ApplicationSettings::getInstance()->getLicenseString(), AppPath::getAppPath());
std::string licenseString = license.getLicenseInfo();
std::string licenseString = license.getLicenseInfo();
QLabel* licenseHeader = new QLabel("Licensed to:");
licenseHeader->setObjectName("licenseHeaderLabel");
col->addWidget(licenseHeader);
col->addSpacing(2);
QLabel* licenseHeader = new QLabel("Licensed to:");
licenseHeader->setObjectName("licenseHeaderLabel");
col->addWidget(licenseHeader);
col->addSpacing(2);
QLabel* licenseLabel = new QLabel(licenseString.c_str());
licenseLabel->setObjectName("licenseLabel");
col->addWidget(licenseLabel);
licenseLabel->setObjectName("licenseLabel");
col->addWidget(licenseLabel);
col->addStretch();
@@ -248,7 +250,7 @@ void QtStartScreen::setupStartScreen(bool unlocked)
layout->addLayout(col, 1);
QLabel* recentProjectsLabel = new QLabel("Recent Projects: ", this);
if (!unlocked)
if (!licenseValid)
{
recentProjectsLabel->setText("Projects:");
}
+1 -1
View File
@@ -34,7 +34,7 @@ public:
QtStartScreen(QWidget* parent = 0);
QSize sizeHint() const override;
void setupStartScreen(bool unlocked);
void setupStartScreen();
signals:
void openOpenProjectDialog();