From 41d276eb6f3ee823e850ef4ad96d078e330d644d Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 9 Oct 2024 13:51:50 +0200 Subject: [PATCH] Axivion: Allow None item for dashboard This allows to explicitly disable the accesses of possibly configured dashboards. The old approach with the hard linking is gone and if the user now accesses the Axivion perspective intentional or not the session is tied to the dashboard until this is changed to a different one. That also means accessing any file inside the session may try to request information about the file from the current dashboard server. Make it possible to undo the loose linking by introducing a None item which in turn disables accessing the dashboard. Change-Id: I04a960baad102663c4d97e652d44c86a04563416 Reviewed-by: Jarek Kobus --- src/plugins/axivion/axivionperspective.cpp | 27 ++++++++++++++++------ src/plugins/axivion/axivionplugin.cpp | 8 ++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/plugins/axivion/axivionperspective.cpp b/src/plugins/axivion/axivionperspective.cpp index 2527e44fced..f77dec72f91 100644 --- a/src/plugins/axivion/axivionperspective.cpp +++ b/src/plugins/axivion/axivionperspective.cpp @@ -244,8 +244,15 @@ IssuesWidget::IssuesWidget(QWidget *parent) if (data.isValid()) { const AxivionServer server = data.value(); switchActiveDashboardId(server.id); + reinitProjectList(m_dashboardProjects->currentText()); + } else { + switchActiveDashboardId({}); + { + GuardLocker lock(m_signalBlocker); + m_dashboardProjects->clear(); + } + updateBasicProjectInfo(std::nullopt); } - reinitProjectList(m_dashboardProjects->currentText()); }); m_dashboardProjects = new QComboBox(this); @@ -411,28 +418,34 @@ void IssuesWidget::initDashboardList(const QString &preferredProject) : preferredProject; resetDashboard(); m_dashboardListUninitialized = false; - GuardLocker lock(m_signalBlocker); const QList servers = settings().allAvailableServers(); if (servers.isEmpty()) { switchActiveDashboardId({}); + { + GuardLocker lock(m_signalBlocker); + m_dashboardProjects->clear(); + } + updateBasicProjectInfo(std::nullopt); return; } + + GuardLocker lock(m_signalBlocker); + m_dashboards->addItem(Tr::tr("None")); for (const AxivionServer &server : servers) m_dashboards->addItem(server.displayString(), QVariant::fromValue(server)); Id activeId = activeDashboardId(); - if (!activeId.isValid()) - activeId = settings().defaultDashboardId(); if (activeId.isValid()) { int index = Utils::indexOf(servers, Utils::equal(&AxivionServer::id, activeId)); if (index < 0) { activeId = settings().defaultDashboardId(); index = Utils::indexOf(servers, Utils::equal(&AxivionServer::id, activeId)); } - m_dashboards->setCurrentIndex(index); + m_dashboards->setCurrentIndex(index + 1); + reinitProjectList(currentProject); + } else { + m_dashboards->setCurrentIndex(0); } - switchActiveDashboardId(activeId); - reinitProjectList(currentProject); } void IssuesWidget::reinitProjectList(const QString ¤tProject) diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index f72379c7528..a45ee591476 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -1026,13 +1026,9 @@ void AxivionPluginPrivate::onSessionLoaded(const QString &sessionName) const QString projectName = SessionManager::sessionValue(SV_PROJECTNAME).toString(); const Id dashboardId = Id::fromSetting(SessionManager::sessionValue(SV_DASHBOARDID)); - if (!dashboardId.isValid()) { + if (!dashboardId.isValid()) switchActiveDashboardId({}); - resetDashboard(); - return; - } - - if (activeDashboardId() != dashboardId) + else if (activeDashboardId() != dashboardId) switchActiveDashboardId(dashboardId); reinitDashboard(projectName); }