ui: Don't show start window when opening project with double-click
* added menu option to show start window
This commit is contained in:
+34
-28
@@ -23,6 +23,7 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
@@ -123,6 +124,25 @@ void prefillCxxFrameworkPaths()
|
||||
}
|
||||
}
|
||||
|
||||
void prefillPaths()
|
||||
{
|
||||
prefillJavaRuntimePath();
|
||||
prefillMavenExecutablePath();
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
}
|
||||
|
||||
void addLanguageModules()
|
||||
{
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleC>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCpp>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleJava>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxCdb>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxManual>());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setApplicationName("Sourcetrail");
|
||||
@@ -164,18 +184,8 @@ int main(int argc, char *argv[])
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
prefillJavaRuntimePath();
|
||||
prefillMavenExecutablePath();
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleC>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCpp>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleJava>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxCdb>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxManual>());
|
||||
prefillPaths();
|
||||
addLanguageModules();
|
||||
|
||||
std::shared_ptr<LicenseChecker> checker = LicenseChecker::getInstance();
|
||||
|
||||
@@ -202,7 +212,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
commandLineParser.projectLoad();
|
||||
MessageLoadProject(
|
||||
commandLineParser.getProjectFilePath(),
|
||||
commandLineParser.getFullProjectRefresh()
|
||||
).dispatch();
|
||||
}
|
||||
return qtApp.exec();
|
||||
}
|
||||
@@ -226,18 +239,11 @@ int main(int argc, char *argv[])
|
||||
Application::destroyInstance();
|
||||
});
|
||||
|
||||
prefillJavaRuntimePath();
|
||||
prefillMavenExecutablePath();
|
||||
prefillCxxHeaderPaths();
|
||||
prefillCxxFrameworkPaths();
|
||||
prefillPaths();
|
||||
addLanguageModules();
|
||||
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleC>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCpp>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleJava>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxCdb>());
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleCxxManual>());
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf");
|
||||
|
||||
if (commandLineParser.hasError())
|
||||
{
|
||||
@@ -245,12 +251,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
commandLineParser.projectLoad();
|
||||
MessageLoadProject(
|
||||
commandLineParser.getProjectFilePath(),
|
||||
commandLineParser.getFullProjectRefresh()
|
||||
).dispatch();
|
||||
}
|
||||
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf");
|
||||
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf");
|
||||
|
||||
return qtApp.exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,13 +183,13 @@ void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
|
||||
if (m_project)
|
||||
{
|
||||
m_project->load();
|
||||
|
||||
if (m_hasGUI)
|
||||
{
|
||||
updateTitle();
|
||||
m_mainView->hideStartScreen();
|
||||
}
|
||||
|
||||
m_project->load();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -403,7 +403,6 @@ add_files(
|
||||
utility/messaging/type/MessageShowErrors.h
|
||||
utility/messaging/type/MessageShowReference.h
|
||||
utility/messaging/type/MessageShowScope.h
|
||||
utility/messaging/type/MessageShowStartScreen.h
|
||||
utility/messaging/type/MessageShowStatus.h
|
||||
utility/messaging/type/MessageStatus.h
|
||||
utility/messaging/type/MessageStatusFilterChanged.h
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageShowStartScreen.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "License.h"
|
||||
@@ -151,7 +149,7 @@ bool CommandLineParser::startedWithLicense()
|
||||
|
||||
void CommandLineParser::processProjectfile(const std::string& file)
|
||||
{
|
||||
FilePath projectfile(file);
|
||||
FilePath projectfile = FilePath(file).absolute();
|
||||
const std::string errorstring =
|
||||
"Provided Projectfile is not valid:\n* Provided Projectfile('" + projectfile.fileName() + "') ";
|
||||
if (!projectfile.exists())
|
||||
@@ -173,21 +171,7 @@ void CommandLineParser::processProjectfile(const std::string& file)
|
||||
return;
|
||||
}
|
||||
|
||||
m_projectFile = projectfile.absolute();
|
||||
}
|
||||
|
||||
void CommandLineParser::projectLoad()
|
||||
{
|
||||
if (m_projectFile.exists() &&
|
||||
(m_projectFile.extension() == ".srctrlprj" || m_projectFile.extension() == ".coatiproject"))
|
||||
{
|
||||
MessageLoadProject(m_projectFile, m_force).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageShowStartScreen().dispatch();
|
||||
}
|
||||
|
||||
m_projectFile = projectfile;
|
||||
}
|
||||
|
||||
License CommandLineParser::getLicense()
|
||||
@@ -195,3 +179,12 @@ License CommandLineParser::getLicense()
|
||||
return m_license;
|
||||
}
|
||||
|
||||
const FilePath& CommandLineParser::getProjectFilePath() const
|
||||
{
|
||||
return m_projectFile;
|
||||
}
|
||||
|
||||
bool CommandLineParser::getFullProjectRefresh() const
|
||||
{
|
||||
return m_force;
|
||||
}
|
||||
|
||||
@@ -13,11 +13,15 @@ public:
|
||||
|
||||
bool runWithoutGUI();
|
||||
bool exitApplication();
|
||||
void projectLoad();
|
||||
bool startedWithLicense();
|
||||
bool hasError();
|
||||
|
||||
std::string getError();
|
||||
License getLicense();
|
||||
|
||||
const FilePath& getProjectFilePath() const;
|
||||
bool getFullProjectRefresh() const;
|
||||
|
||||
private:
|
||||
void processProjectfile(const std::string& file);
|
||||
void processLicense(const bool isLoaded);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef MESSAGE_SHOW_START_SCREEN_H
|
||||
#define MESSAGE_SHOW_START_SCREEN_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageShowStartScreen
|
||||
: public Message<MessageShowStartScreen>
|
||||
{
|
||||
public:
|
||||
MessageShowStartScreen()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowStartScreen";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_START_SCREEN_H
|
||||
@@ -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();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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:");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
QtStartScreen(QWidget* parent = 0);
|
||||
QSize sizeHint() const override;
|
||||
|
||||
void setupStartScreen(bool unlocked);
|
||||
void setupStartScreen();
|
||||
|
||||
signals:
|
||||
void openOpenProjectDialog();
|
||||
|
||||
Reference in New Issue
Block a user