From 1fa9034acaf6ace8f0e62186e145303642709459 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 16 Feb 2022 16:55:49 +0100 Subject: [PATCH] StudioWelcome: Avoid opening two projects on double click MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This issue was introdced because we do not go to the edit mode after opening a project. We stay in the WelcomeMode until the project is loaded. Since the recent project list did change a second click (aka double click) will open a second project. We now block the update of the model for 1000ms and also block opening another project for the same duration. Task-number: QDS-6286 Change-Id: I52ed6aa3686594b63fe4a6134c6db1287bca1dcb Reviewed-by: Qt CI Bot Reviewed-by: Henning Gründl --- src/plugins/studiowelcome/studiowelcomeplugin.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index c004b146691..0e4e1996fb6 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -224,9 +224,15 @@ public: Q_INVOKABLE void openProjectAt(int row) { + if (m_blockOpenRecent) + return; + + m_blockOpenRecent = true; const QString projectFile = data(index(row, 0), ProjectModel::FilePathRole).toString(); if (QFileInfo::exists(projectFile)) ProjectExplorer::ProjectExplorerPlugin::openProjectWelcomePage(projectFile); + + resetProjects(); } Q_INVOKABLE int get(int) { return -1; } @@ -311,6 +317,7 @@ private: bool m_communityVersion = true; bool m_enterpriseVersion = false; + bool m_blockOpenRecent = false; }; void ProjectModel::setupVersion() @@ -520,8 +527,11 @@ QHash ProjectModel::roleNames() const void ProjectModel::resetProjects() { - beginResetModel(); - endResetModel(); + QTimer::singleShot(2000, this, [this]() { + beginResetModel(); + endResetModel(); + m_blockOpenRecent = false; + }); } class WelcomeMode : public Core::IMode