From c7c0c43d7644740cfd341c57d70c1e64e3e64d7f Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 9 Oct 2024 15:57:42 +0200 Subject: [PATCH] Axivion: Provide usage hint If the user opens the Axivion perspective without configuring dashboards inside the settings the perspective now gives at least a hint where to start. Change-Id: I7c4d171d52122be6fc7310a09eb86eb64270e4b2 Reviewed-by: hjk --- src/plugins/axivion/axivionperspective.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/plugins/axivion/axivionperspective.cpp b/src/plugins/axivion/axivionperspective.cpp index f77dec72f91..f0f0596e013 100644 --- a/src/plugins/axivion/axivionperspective.cpp +++ b/src/plugins/axivion/axivionperspective.cpp @@ -189,7 +189,8 @@ public: const std::optional currentTableInfo() const { return m_currentTableInfo; } IssueListSearch searchFromUi() const; - void showOverlay(const QString &errorMessage = {}); + enum OverlayIconType { EmptyIcon, ErrorIcon, SettingsIcon }; + void showOverlay(const QString &message = {}, OverlayIconType type = EmptyIcon); protected: void showEvent(QShowEvent *event) override; private: @@ -426,8 +427,10 @@ void IssuesWidget::initDashboardList(const QString &preferredProject) m_dashboardProjects->clear(); } updateBasicProjectInfo(std::nullopt); + showOverlay(Tr::tr("Configure dashboards in Preferences > Axivion > General."), SettingsIcon); return; } + hideOverlay(); GuardLocker lock(m_signalBlocker); m_dashboards->addItem(Tr::tr("None")); @@ -803,7 +806,7 @@ void IssuesWidget::onFetchRequested(int startRow, int limit) fetchIssues(search); } -void IssuesWidget::showOverlay(const QString &errorMessage) +void IssuesWidget::showOverlay(const QString &message, OverlayIconType type) { if (!m_overlay) { QTC_ASSERT(m_issuesView, return); @@ -811,22 +814,26 @@ void IssuesWidget::showOverlay(const QString &errorMessage) m_overlay->attachToWidget(m_issuesView); } - m_overlay->setPaintFunction([errorMessage](QWidget *that, QPainter &p, QPaintEvent *) { + m_overlay->setPaintFunction([message, type](QWidget *that, QPainter &p, QPaintEvent *) { static const QIcon noData = Icon({{":/axivion/images/nodata.png", Theme::IconsDisabledColor}}, Utils::Icon::Tint).icon(); static const QIcon error = Icon({{":/axivion/images/error.png", Theme::IconsErrorColor}}, Utils::Icon::Tint).icon(); + static const QIcon settings = Icon({{":/utils/images/settings.png", Theme::IconsDisabledColor}}, + Utils::Icon::Tint).icon(); QRect iconRect(0, 0, 32, 32); iconRect.moveCenter(that->rect().center()); - if (errorMessage.isEmpty()) + if (type == EmptyIcon) noData.paint(&p, iconRect); - else + else if (type == ErrorIcon) error.paint(&p, iconRect); + else if (type == SettingsIcon) + settings.paint(&p, iconRect); p.save(); p.setPen(Utils::creatorColor(Theme::TextColorDisabled)); const QFontMetrics &fm = p.fontMetrics(); p.drawText(iconRect.bottomRight() + QPoint{10, fm.height() / 2 - 16 - fm.descent()}, - errorMessage.isEmpty() ? Tr::tr("No Data") : errorMessage); + message.isEmpty() ? Tr::tr("No Data") : message); p.restore(); }); @@ -939,7 +946,7 @@ void AxivionPerspective::handleShowIssues(const QString &kind) void AxivionPerspective::handleShowFilterException(const QString &errorMessage) { - m_issuesWidget->showOverlay(errorMessage); + m_issuesWidget->showOverlay(errorMessage, IssuesWidget::ErrorIcon); } void AxivionPerspective::reinitDashboardList(const QString &preferredProject)