[office/kmymoney] kmymoney/dialogs: Improve online price update dialog

Thomas Baumgart null at kde.org
Sat Feb 5 10:19:46 GMT 2022


Git commit 6cbff10119df4e6edecb1066b126f655f7b77b06 by Thomas Baumgart.
Committed on 05/02/2022 at 10:19.
Pushed by tbaumgart into branch 'master'.

Improve online price update dialog

Don't show the status part before online activity started. Hide progress
bar once the update is finished. Add a close button to hide the status
part again.

GUI:

M  +30   -9    kmymoney/dialogs/kequitypriceupdatedlg.cpp
M  +68   -20   kmymoney/dialogs/kequitypriceupdatedlg.ui

https://invent.kde.org/office/kmymoney/commit/6cbff10119df4e6edecb1066b126f655f7b77b06

diff --git a/kmymoney/dialogs/kequitypriceupdatedlg.cpp b/kmymoney/dialogs/kequitypriceupdatedlg.cpp
index 40c65b488..2f8a62c63 100644
--- a/kmymoney/dialogs/kequitypriceupdatedlg.cpp
+++ b/kmymoney/dialogs/kequitypriceupdatedlg.cpp
@@ -11,10 +11,11 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QPushButton>
-#include <QTimer>
 #include <QList>
 #include <QPointer>
+#include <QPushButton>
+#include <QTimer>
+#include <QToolButton>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -33,15 +34,16 @@
 
 #include "ui_kequitypriceupdatedlg.h"
 
-#include "mymoneyfile.h"
-#include "mymoneyaccount.h"
-#include "mymoneysecurity.h"
-#include "mymoneyprice.h"
-#include "webpricequote.h"
+#include "dialogenums.h"
+#include "icons.h"
 #include "kequitypriceupdateconfdlg.h"
 #include "kmymoneyutils.h"
+#include "mymoneyaccount.h"
 #include "mymoneyexception.h"
-#include "dialogenums.h"
+#include "mymoneyfile.h"
+#include "mymoneyprice.h"
+#include "mymoneysecurity.h"
+#include "webpricequote.h"
 
 #define WEBID_COL       0
 #define NAME_COL        1
@@ -93,6 +95,12 @@ public:
 
         ui->btnUpdateAll->setEnabled(false);
 
+        ui->closeStatusButton->setIcon(Icons::get(Icons::Icon::DialogClose));
+        q->connect(ui->closeStatusButton, &QToolButton::clicked, ui->statusContainer, &QWidget::hide);
+
+        // hide the status widgets until there is activity
+        ui->statusContainer->hide();
+
         auto file = MyMoneyFile::instance();
 
         //
@@ -450,6 +458,11 @@ void KEquityPriceUpdateDlg::slotUpdateSelectedClicked()
     // disable sorting while the update is running to maintain the current order of items on which
     // the update process depends and which could be changed with sorting enabled due to the updated values
     d->ui->lvEquityList->setSortingEnabled(false);
+
+    // show the status widgets
+    d->ui->statusContainer->show();
+    d->ui->prgOnlineProgress->show();
+
     auto item = d->ui->lvEquityList->invisibleRootItem()->child(0);
     auto skipCnt = 1;
     while (item && !item->isSelected()) {
@@ -474,6 +487,11 @@ void KEquityPriceUpdateDlg::slotUpdateAllClicked()
     // disable sorting while the update is running to maintain the current order of items on which
     // the update process depends and which could be changed with sorting enabled due to the updated values
     d->ui->lvEquityList->setSortingEnabled(false);
+
+    // show the status widgets
+    d->ui->statusContainer->show();
+    d->ui->prgOnlineProgress->show();
+
     QTreeWidgetItem* item = d->ui->lvEquityList->invisibleRootItem()->child(0);
     if (item) {
         d->ui->prgOnlineProgress->setMaximum(1 + d->ui->lvEquityList->invisibleRootItem()->childCount());
@@ -786,8 +804,11 @@ void KEquityPriceUpdateDlg::finishUpdate()
     Q_D(KEquityPriceUpdateDlg);
     // we've run past the end, reset to the default value.
     d->m_fUpdateAll = false;
-    // force progress bar to show 100%
+
+    // force progress bar to show 100% and hide it after a while
     d->ui->prgOnlineProgress->setValue(d->ui->prgOnlineProgress->maximum());
+    QTimer::singleShot(500, d->ui->prgOnlineProgress, &QProgressBar::hide);
+
     // re-enable the sorting that was disabled during the update process
     d->ui->lvEquityList->setSortingEnabled(true);
 }
diff --git a/kmymoney/dialogs/kequitypriceupdatedlg.ui b/kmymoney/dialogs/kequitypriceupdatedlg.ui
index e1d2aae1a..2c79bf9c7 100644
--- a/kmymoney/dialogs/kequitypriceupdatedlg.ui
+++ b/kmymoney/dialogs/kequitypriceupdatedlg.ui
@@ -7,14 +7,14 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>537</width>
-    <height>482</height>
+    <width>696</width>
+    <height>526</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Update Stock and Currency Prices</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <widget class="QTreeWidget" name="lvEquityList">
      <property name="minimumSize">
@@ -117,25 +117,73 @@
     </layout>
    </item>
    <item>
-    <widget class="QLabel" name="textLabel1">
-     <property name="text">
-      <string>Status:</string>
-     </property>
-     <property name="wordWrap">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="KTextEdit" name="lbStatus">
-     <property name="readOnly">
-      <bool>true</bool>
-     </property>
+    <widget class="QWidget" name="statusContainer" native="true">
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <property name="spacing">
+       <number>0</number>
+      </property>
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <widget class="QLabel" name="textLabel1">
+          <property name="text">
+           <string>Status:</string>
+          </property>
+          <property name="wordWrap">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QToolButton" name="closeStatusButton">
+          <property name="text">
+           <string>...</string>
+          </property>
+          <property name="autoRaise">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="KTextEdit" name="lbStatus">
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QProgressBar" name="prgOnlineProgress"/>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item>
-    <widget class="QProgressBar" name="prgOnlineProgress"/>
-   </item>
    <item>
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="standardButtons">


More information about the kde-doc-english mailing list