Do not enter edit mode when opening a .qmlproject as QDS

If the user opens a .qmlproject in QDS mode we do not want to
enter the edit mode by default.
We check the startup project after opening and calling
openEditMode() will determine if we keep the default of opening
the edit mode or not.

Change-Id: Ic8a7fbefa007d487ec680099544c07fe007c0b29
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Thomas Hartmann
2022-02-07 10:06:16 +01:00
parent 9185875677
commit 454682ea3f
5 changed files with 18 additions and 3 deletions

View File

@@ -1078,6 +1078,11 @@ bool Project::isModified() const
return !modifiedDocuments().isEmpty();
}
bool Project::isEditModePreferred() const
{
return true;
}
#if defined(WITH_TESTS)
static FilePath constructTestPath(const char *basePath)

View File

@@ -183,6 +183,8 @@ public:
QList<Core::IDocument *> modifiedDocuments() const;
bool isModified() const;
virtual bool isEditModePreferred() const;
signals:
void projectFileIsDirty(const Utils::FilePath &path);

View File

@@ -2512,12 +2512,13 @@ ProjectExplorerPlugin::OpenProjectResult ProjectExplorerPlugin::openProjects(con
}
dd->updateActions();
bool switchToProjectsMode = Utils::anyOf(openedPro, &Project::needsConfiguration);
const bool switchToProjectsMode = Utils::anyOf(openedPro, &Project::needsConfiguration);
const bool switchToEditMode = Utils::allOf(openedPro,
[](Project *p) { return p->isEditModePreferred(); });
if (!openedPro.isEmpty()) {
if (switchToProjectsMode)
ModeManager::activateMode(Constants::MODE_SESSION);
else
else if (switchToEditMode)
ModeManager::activateMode(Core::Constants::MODE_EDIT);
ModeManager::setFocusToCurrentMode();
}

View File

@@ -456,6 +456,11 @@ Tasks QmlProject::projectIssues(const Kit *k) const
return result;
}
bool QmlProject::isEditModePreferred() const
{
return !isQtDesignStudio();
}
Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *errorMessage)
{
RestoreResult result = Project::fromMap(map, errorMessage);

View File

@@ -148,6 +148,8 @@ public:
static bool isQtDesignStudio();
bool isEditModePreferred() const override;
protected:
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;