[office/kmymoney] kmymoney/plugins/views/reports: Fix availability of report actions

Thomas Baumgart <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 3b3d9f8a8832ac7e44b27d6830ba729706891bf0 by Thomas Baumgart.
Committed on 06/08/2026 at 07:54.
Pushed by tbaumgart into branch 'master'.

Fix availability of report actions

M  +3    -5    kmymoney/plugins/views/reports/kreportsview.cpp
M  +9    -0    kmymoney/plugins/views/reports/kreportsview_p.h
M  +0    -10   kmymoney/plugins/views/reports/kreporttab.cpp
M  +0    -1    kmymoney/plugins/views/reports/kreporttab.h

https://invent.kde.org/office/kmymoney/-/commit/3b3d9f8a8832ac7e44b27d6830ba729706891bf0

diff --git a/kmymoney/plugins/views/reports/kreportsview.cpp b/kmymoney/plugins/views/reports/kreportsview.cpp
index 76ad18944..740b00204 100644
--- a/kmymoney/plugins/views/reports/kreportsview.cpp
+++ b/kmymoney/plugins/views/reports/kreportsview.cpp
@@ -197,6 +197,7 @@ void KReportsView::showEvent(QShowEvent* event)
             if (d->m_configurationSidebarOpen) {
                 doConfigure(NoConfigureOption);
             }
+            updateActions({});
         });
 
         // remove close button from list tab
@@ -297,11 +298,8 @@ void KReportsView::updateActions(const SelectedObjects& selections)
     pActions[eMenu::Action::ReportAccountTransactions]->setEnabled(enable);
 
     // only access the widgets if they are initialized
-    if (!d->m_needLoad) {
-        if (auto tab = dynamic_cast<KReportTab*>(d->ui.m_reportTabWidget->currentWidget())) {
-            tab->enableAllReportActions();
-        }
-    }
+    const bool enabled = !d->m_needLoad && (d->ui.m_reportTabWidget->currentIndex() > 0) && isVisible();
+    d->enableAllReportActions(enabled);
 }
 
 void KReportsView::slotOpenUrl(const QUrl& url)
diff --git a/kmymoney/plugins/views/reports/kreportsview_p.h b/kmymoney/plugins/views/reports/kreportsview_p.h
index 81282cd11..406a6c08d 100644
--- a/kmymoney/plugins/views/reports/kreportsview_p.h
+++ b/kmymoney/plugins/views/reports/kreportsview_p.h
@@ -955,6 +955,15 @@ public:
         }
     }
 
+    void enableAllReportActions(bool enabled)
+    {
+        pActions[eMenu::Action::ReportNew]->setEnabled(enabled);
+        pActions[eMenu::Action::ReportConfigure]->setEnabled(enabled);
+        pActions[eMenu::Action::ReportExport]->setEnabled(enabled);
+        pActions[eMenu::Action::ReportDelete]->setEnabled(enabled);
+        pActions[eMenu::Action::ReportClose]->setEnabled(enabled);
+    }
+
     /**
       * This member holds the load state of page
       */
diff --git a/kmymoney/plugins/views/reports/kreporttab.cpp b/kmymoney/plugins/views/reports/kreporttab.cpp
index 168171049..a26022f80 100644
--- a/kmymoney/plugins/views/reports/kreporttab.cpp
+++ b/kmymoney/plugins/views/reports/kreporttab.cpp
@@ -99,7 +99,6 @@ KReportTab::KReportTab(QTabWidget* parent, const MyMoneyReport& report, const KR
     for (auto* button : std::as_const(buttons)) {
         button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
     }
-    enableAllReportActions();
 
     connect(m_tableView, &KMMTextBrowser::anchorClicked, eventHandler, &KReportsView::slotOpenUrl);
 
@@ -288,15 +287,6 @@ void KReportTab::updateReport()
     toggleChart();
 }
 
-void KReportTab::enableAllReportActions()
-{
-    pActions[eMenu::Action::ReportNew]->setEnabled(true);
-    pActions[eMenu::Action::ReportConfigure]->setEnabled(true);
-    pActions[eMenu::Action::ReportExport]->setEnabled(true);
-    pActions[eMenu::Action::ReportDelete]->setEnabled(true);
-    pActions[eMenu::Action::ReportClose]->setEnabled(true);
-}
-
 void KReportTab::showConfigurationSidebar(QWidget* widget)
 {
     if (!widget && !m_configurationWidget) {
diff --git a/kmymoney/plugins/views/reports/kreporttab.h b/kmymoney/plugins/views/reports/kreporttab.h
index 7d9d1deb6..5eaf4e56f 100644
--- a/kmymoney/plugins/views/reports/kreporttab.h
+++ b/kmymoney/plugins/views/reports/kreporttab.h
@@ -99,7 +99,6 @@ public:
         updateReport();
     }
 
-    void enableAllReportActions();
     void showConfigurationSidebar(QWidget* widget = nullptr);
     void closeConfigurationSidebar();
     QWidget* configurationSidebar() const;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.