ui: add menu entry to close the current project (issue #722)

This commit is contained in:
mlangkabel
2019-10-18 13:05:27 +02:00
committed by Eberhard Graether
parent dc24bae943
commit 6b692ff0e9
13 changed files with 70 additions and 14 deletions
+1
View File
@@ -527,6 +527,7 @@ add_files(
utility/messaging/type/MessageChangeFileView.h
utility/messaging/type/MessageClearLogView.h
utility/messaging/type/MessageClearStatusView.h
utility/messaging/type/MessageCloseProject.h
utility/messaging/type/MessageCodeReference.h
utility/messaging/type/MessageDeactivateEdge.h
utility/messaging/type/MessageFind.h
+14 -1
View File
@@ -146,7 +146,7 @@ Application::~Application()
}
}
const std::shared_ptr<Project> Application::getCurrentProject() const
std::shared_ptr<const Project> Application::getCurrentProject() const
{
return m_project;
}
@@ -213,6 +213,19 @@ void Application::handleMessage(MessageActivateWindow* message)
}
}
void Application::handleMessage(MessageCloseProject* message)
{
if (m_project && m_project->isIndexing())
{
MessageStatus(L"Cannot close the project while indexing.", true, false).dispatch();
return;
}
m_project.reset();
updateTitle();
m_mainView->clear();
}
void Application::handleMessage(MessageIndexingFinished* message)
{
logStorageStats();
+4 -1
View File
@@ -7,6 +7,7 @@
#include "MessageListener.h"
#include "MessageIndexingFinished.h"
#include "MessageActivateWindow.h"
#include "MessageCloseProject.h"
#include "MessageLoadProject.h"
#include "MessageRefresh.h"
#include "MessageRefreshUI.h"
@@ -26,6 +27,7 @@ class ViewFactory;
class Application
: public MessageListener<MessageActivateWindow>
, public MessageListener<MessageCloseProject>
, public MessageListener<MessageIndexingFinished>
, public MessageListener<MessageLoadProject>
, public MessageListener<MessageRefresh>
@@ -48,7 +50,7 @@ public:
~Application();
const std::shared_ptr<Project> getCurrentProject() const;
std::shared_ptr<const Project> getCurrentProject() const;
FilePath getCurrentProjectPath() const;
bool isProjectLoaded() const;
@@ -68,6 +70,7 @@ private:
Application(bool withGUI = true);
void handleMessage(MessageActivateWindow* message) override;
void handleMessage(MessageCloseProject* message) override;
void handleMessage(MessageIndexingFinished* message) override;
void handleMessage(MessageLoadProject* message) override;
void handleMessage(MessageRefresh* message) override;
@@ -33,7 +33,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
saveOrRestoreViewMode(message);
Project* currentProject = Application::getInstance()->getCurrentProject().get();
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
if (!currentProject || message->acceptedNodeTypes != NodeTypeSet::all())
{
clear();
@@ -804,7 +804,7 @@ const SourceLocation* CodeController::getSourceLocationOfParentScope(
std::vector<std::string> CodeController::getProjectDescription(SourceLocationFile* locationFile) const
{
Project* currentProject = Application::getInstance()->getCurrentProject().get();
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
if (!currentProject)
{
return std::vector<std::string>();
@@ -124,7 +124,7 @@ void ErrorController::handleMessage(MessageErrorsAll* message)
void ErrorController::handleMessage(MessageErrorsForFile* message)
{
Project* project = Application::getInstance()->getCurrentProject().get();
std::shared_ptr<const Project> project = Application::getInstance()->getCurrentProject();
if (project && project->isIndexing())
{
Application::getInstance()->handleDialog(
@@ -524,8 +524,8 @@ void UndoRedoController::replayCommand(std::list<Command>::iterator it)
}
else if (m->getType() == MessageActivateErrors::getStaticType())
{
Project* project = Application::getInstance()->getCurrentProject().get();
if (project && project->isIndexing())
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
if (currentProject && currentProject->isIndexing())
{
Application::getInstance()->handleDialog(L"Errors cannot be activated while indexing.");
@@ -27,7 +27,7 @@ void SqliteBookmarkStorage::migrateIfNecessary()
std::string separator = "::";
if (Application::getInstance())
{
if (std::shared_ptr<Project> currentProject = Application::getInstance()->getCurrentProject())
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
{
LanguageType currentLanguage = ProjectSettings::getLanguageOfProject(currentProject->getProjectSettingsFilePath());
if (currentLanguage == LANGUAGE_JAVA)
@@ -0,0 +1,27 @@
#ifndef MESSAGE_CLOSE_PROJECT_H
#define MESSAGE_CLOSE_PROJECT_H
#include "RefreshInfo.h"
#include "FilePath.h"
#include "Message.h"
class MessageCloseProject
: public Message<MessageCloseProject>
{
public:
MessageCloseProject()
{
}
static const std::string getStaticType()
{
return "MessageCloseProject";
}
virtual void print(std::wostream& os) const
{
}
};
#endif // MESSAGE_CLOSE_PROJECT_H
@@ -125,7 +125,7 @@ void QtCodeFileTitleBar::setIsComplete(bool isComplete)
m_titleButton->setIsComplete(isComplete);
m_showErrorsButton->setVisible(!isComplete);
Project* project = Application::getInstance()->getCurrentProject().get();
std::shared_ptr<const Project> project = Application::getInstance()->getCurrentProject();
if (project && project->isIndexing())
{
m_showErrorsButton->setVisible(false);
@@ -1186,10 +1186,10 @@ void QtProjectWizard::createProject()
bool settingsChanged = false;
if (m_editing)
{
Application* application = Application::getInstance().get();
if (application->getCurrentProject() != nullptr)
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
if (currentProject)
{
settingsChanged = !(application->getCurrentProject()->settingsEqualExceptNameAndLocation(*(m_projectSettings.get())));
settingsChanged = !(currentProject->settingsEqualExceptNameAndLocation(*(m_projectSettings.get())));
}
settingsChanged |= !(m_appSettings == *ApplicationSettings::getInstance().get());
+12 -1
View File
@@ -39,6 +39,7 @@
#include "MessageBookmarkActivate.h"
#include "MessageBookmarkBrowse.h"
#include "MessageBookmarkCreate.h"
#include "MessageCloseProject.h"
#include "MessageCodeReference.h"
#include "MessageCustomTrailShow.h"
#include "MessageFind.h"
@@ -712,7 +713,7 @@ void QtMainWindow::openProject()
void QtMainWindow::editProject()
{
Project* currentProject = Application::getInstance()->getCurrentProject().get();
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
if (currentProject)
{
QtProjectWizard* wizard = createWindow<QtProjectWizard>();
@@ -721,6 +722,15 @@ void QtMainWindow::editProject()
}
}
void QtMainWindow::closeProject()
{
if (Application::getInstance()->getCurrentProject())
{
MessageCloseProject().dispatch();
showStartScreen();
}
}
void QtMainWindow::find()
{
MessageFind().dispatch();
@@ -932,6 +942,7 @@ void QtMainWindow::setupProjectMenu()
menu->addAction(tr("&Edit Project..."), this, &QtMainWindow::editProject);
menu->addSeparator();
menu->addAction(tr("Close Project"), this, &QtMainWindow::closeProject);
menu->addAction(tr("E&xit"), QCoreApplication::instance(), &QCoreApplication::quit, QKeySequence::Quit);
}
+1
View File
@@ -129,6 +129,7 @@ public slots:
void newProjectFromCDB(const FilePath& filePath);
void openProject();
void editProject();
void closeProject();
void find();
void findFulltext();
@@ -101,7 +101,7 @@ void QtPreferencesWindow::handleNext()
if (appSettingsChanged)
{
Project* currentProject = app->getCurrentProject().get();
std::shared_ptr<const Project> currentProject = Application::getInstance()->getCurrentProject();
if (currentProject)
{
MessageLoadProject(currentProject->getProjectSettingsFilePath(), true).dispatch();