StudioWelcome: Avoid opening two projects on double click

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 <qt_ci_bot@qt-project.org>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Thomas Hartmann
2022-02-16 16:55:49 +01:00
parent 0d319ac3a1
commit 1fa9034aca

View File

@@ -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<int, QByteArray> ProjectModel::roleNames() const
void ProjectModel::resetProjects()
{
beginResetModel();
endResetModel();
QTimer::singleShot(2000, this, [this]() {
beginResetModel();
endResetModel();
m_blockOpenRecent = false;
});
}
class WelcomeMode : public Core::IMode