Git commit 215398f3c89735444ef4b7ed67fa3ce1768bf1e5 by Stephane MANKOWSKI. Committed on 04/03/2023 at 22:22. Pushed by smankowski into branch 'master'.
Remove all dashboard to keep only the qml version M +2 -0 .gitignore M +1 -0 CHANGELOG M +1 -1 doc/index.docbook M +0 -4 plugins/generic/skg_dashboard/CMakeLists.txt M +0 -14 plugins/generic/skg_dashboard/skgdashboardplugin.cpp M +0 -15 plugins/generic/skg_dashboard/skgdashboardplugin.h D +0 -43 plugins/generic/skg_dashboard/skgdashboardpluginwidget_pref.ui A +61 -0 plugins/skrooge/default/account_table_light.qml [License: GPL(v3.0+)] M +30 -11 plugins/skrooge/skrooge_bank/skgbankplugin.cpp M +1 -5 plugins/skrooge/skrooge_calculator/skgcalculatorplugin.cpp M +4 -9 plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp M +1 -2 plugins/skrooge/skrooge_operation/CMakeLists.txt D +0 -377 plugins/skrooge/skrooge_operation/skgoperationboardwidget.cpp D +0 -83 plugins/skrooge/skrooge_operation/skgoperationboardwidget.h M +1 -10 plugins/skrooge/skrooge_operation/skgoperationplugin.cpp D +0 -248 plugins/skrooge/skrooge_operation/skgoperationpluginwidget_board.ui M +1 -6 plugins/skrooge/skrooge_report/skgreportplugin.cpp M +1 -2 plugins/skrooge/skrooge_scheduled/skgscheduledboardwidget.cpp M +1 -2 plugins/skrooge/skrooge_search/CMakeLists.txt D +0 -186 plugins/skrooge/skrooge_search/skgalarmboardwidget.cpp D +0 -64 plugins/skrooge/skrooge_search/skgalarmboardwidget.h M +4 -12 plugins/skrooge/skrooge_search/skgsearchplugin.cpp M +1 -1 plugins/skrooge/skrooge_unit/skgunitplugin.cpp https://invent.kde.org/office/skrooge/commit/215398f3c89735444ef4b7ed67fa3ce1768bf1e5 diff --git a/.gitignore b/.gitignore index c34f3da68..0f4ff3fe2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ mxe *~ *.txt.user *.wrk +.vscode/c_cpp_properties.json +.vscode/tasks.json diff --git a/CHANGELOG b/CHANGELOG index 3acb2da1c..690d73553 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ skrooge (2.30.0) *Correction bug 435762: Income&Expenditure widget don't match with Income&Expense report + *Correction: Remove all dashboard to keep only the qml version -- Stephane MANKOWSKI <[email protected]> xxx diff --git a/doc/index.docbook b/doc/index.docbook index 7ceec494b..d0ee4e949 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -918,7 +918,7 @@ <listitem><para><guimenuitem>Next</guimenuitem>: Change the content of the current page with the content of the next one. (like in a web browser)</para></listitem> <listitem><para><guimenuitem>Open highlights...</guimenuitem>: Open highlighted operations</para></listitem> <listitem><para><guimenuitem>Open last modified...</guimenuitem>: Open operations modified by the last action done</para></listitem> - <listitem><para><guimenuitem>Open potential duplicates...</guimenuitem>: Open operations opens a page with operations that have the same amounts and same dates</para></listitem> + <listitem><para><guimenuitem>Open potential duplicates...</guimenuitem>: Open a page with operations that have the same amounts and same dates</para></listitem> <listitem><para><guimenuitem>Open sub operations...</guimenuitem>: Open sub operations of the selected operation. Similar to a double click</para></listitem> <listitem><para><guimenuitem>Open report...</guimenuitem>: Open a report based on the selection. This is really useful. For example: if you select two accounts and launch this action then the <link linkend="reports">report</link> page will be opened but only for operations of those accounts</para></listitem> <listitem><para><guimenuitem>Open imported operations not yet validated...</guimenuitem>: nothing to add</para></listitem> diff --git a/plugins/generic/skg_dashboard/CMakeLists.txt b/plugins/generic/skg_dashboard/CMakeLists.txt index 3f3e30d7b..6e8004448 100644 --- a/plugins/generic/skg_dashboard/CMakeLists.txt +++ b/plugins/generic/skg_dashboard/CMakeLists.txt @@ -15,12 +15,8 @@ SET(skg_dashboard_SRCS skgdashboardwidget.cpp skgdashboardboardwidget.cpp) -ki18n_wrap_ui(skg_dashboard_SRCS skgdashboardpluginwidget_pref.ui) -kconfig_add_kcfg_files(skg_dashboard_SRCS skgdashboard_settings.kcfgc ) - KCOREADDONS_ADD_PLUGIN(skg_dashboard SOURCES ${skg_dashboard_SRCS} INSTALL_NAMESPACE "skg_gui" JSON "metadata.json") TARGET_LINK_LIBRARIES(skg_dashboard Qt5::Gui KF5::Parts skgbasemodeler skgbasegui) ########### install files ############### INSTALL(FILES ${PROJECT_SOURCE_DIR}/skg_dashboard.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/skg_dashboard ) -INSTALL(FILES ${PROJECT_SOURCE_DIR}/skgdashboard_settings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} ) diff --git a/plugins/generic/skg_dashboard/skgdashboardplugin.cpp b/plugins/generic/skg_dashboard/skgdashboardplugin.cpp index c8d5ecf80..6840932a3 100644 --- a/plugins/generic/skg_dashboard/skgdashboardplugin.cpp +++ b/plugins/generic/skg_dashboard/skgdashboardplugin.cpp @@ -15,7 +15,6 @@ #include <kpluginfactory.h> #include <kstandardaction.h> -#include "skgdashboard_settings.h" #include "skgdashboardboardwidget.h" #include "skgdashboardpluginwidget.h" #include "skgmainpanel.h" @@ -76,19 +75,6 @@ SKGTabPage* SKGDashboardPlugin::getWidget() return new SKGDashboardPluginWidget(SKGMainPanel::getMainPanel(), m_currentDocument); } -QWidget* SKGDashboardPlugin::getPreferenceWidget() -{ - SKGTRACEINFUNC(10) - auto w = new QWidget(); - ui.setupUi(w); - return w; -} - -KConfigSkeleton* SKGDashboardPlugin::getPreferenceSkeleton() -{ - return skgdashboard_settings::self(); -} - QString SKGDashboardPlugin::title() const { return i18nc("Noun, a summary of your financial situation", "Dashboard"); diff --git a/plugins/generic/skg_dashboard/skgdashboardplugin.h b/plugins/generic/skg_dashboard/skgdashboardplugin.h index 87b1e803c..dbc631e21 100644 --- a/plugins/generic/skg_dashboard/skgdashboardplugin.h +++ b/plugins/generic/skg_dashboard/skgdashboardplugin.h @@ -11,7 +11,6 @@ * @author Stephane MANKOWSKI */ #include "skginterfaceplugin.h" -#include "ui_skgdashboardpluginwidget_pref.h" /** @@ -66,18 +65,6 @@ public: */ SKGTabPage* getWidget() override; - /** - * The preference widget of the plugin. - * @return The preference widget of the plugin - */ - QWidget* getPreferenceWidget() override; - - /** - * The preference skeleton of the plugin. - * @return The preference skeleton of the plugin - */ - KConfigSkeleton* getPreferenceSkeleton() override; - /** * The title of the plugin. * @return The title of the plugin @@ -120,8 +107,6 @@ private: Q_DISABLE_COPY(SKGDashboardPlugin) SKGDocument* m_currentDocument; - - Ui::skgdashboardplugin_pref ui{}; }; #endif // SKGDASHBOARDPLUGIN_H diff --git a/plugins/generic/skg_dashboard/skgdashboardpluginwidget_pref.ui b/plugins/generic/skg_dashboard/skgdashboardpluginwidget_pref.ui deleted file mode 100644 index b08d3d2c8..000000000 --- a/plugins/generic/skg_dashboard/skgdashboardpluginwidget_pref.ui +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <author> -SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] -SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] -SPDX-License-Identifier: GPL-3.0-or-later - </author> - <class>skgdashboardplugin_pref</class> - <widget class="QWidget" name="skgdashboardplugin_pref"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>367</width> - <height>184</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="kcfg_qmlmode"> - <property name="text"> - <string>Dashboard in QML mode (Experimental)</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>126</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/plugins/skrooge/default/account_table_light.qml b/plugins/skrooge/default/account_table_light.qml new file mode 100644 index 000000000..67e4f009f --- /dev/null +++ b/plugins/skrooge/default/account_table_light.qml @@ -0,0 +1,61 @@ +/*************************************************************************** + * SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] + * SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] + * SPDX-License-Identifier: GPL-3.0-or-later + ***************************************************************************/ +import QtQuick 2.0 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 + +RowLayout { + id: grid + property var m: report==null ? null : report.account_table + property var pixel_size: report==null ? 0 : report.point_size + spacing: 2 + + function maxValues(m, id) { + var output = 0 + for (var i = 1; i < m.length; i++) { + if (!m[i][0] && Math.abs(m[i][id]) > output) + output = Math.abs(m[i][id]) + } + return output + } + + ColumnLayout { + spacing: 0 + + // Set titles + Repeater { + model: m + Label { + Layout.fillWidth: true + font.bold: index == 0 || modelData[0] + font.pixelSize: pixel_size + text: modelData[1] + horizontalAlignment: index == 0 ? Text.AlignHCenter : Text.AlignLeft + } + } + } + + ColumnLayout { + spacing: 0 + + // Set values + Repeater { + model: m + SKGValue { + font.pixelSize: pixel_size + Layout.fillWidth: true + horizontalAlignment: index == 0 ? Text.AlignHCenter : Text.AlignRight + font.bold: index == 0 || modelData[0] + + value: index == 0 ? null : modelData[6] + max: modelData[0] ? null : maxValues(m, 6) + backgroundColor: '#' + (value == null || value < 0 ? color_negativetext : color_positivetext) + text: index == 0 ? modelData[6] : document.formatPrimaryMoney(modelData[6]) + url: font.bold || parent.modelId != 6 ? "" : "skg://Skrooge_operation_plugin/?operationWhereClause=t_ACCOUNT='"+ modelData[1] + "'&title="+ modelData[1] + "&title_icon=view-bank-account" + } + } + } +} diff --git a/plugins/skrooge/skrooge_bank/skgbankplugin.cpp b/plugins/skrooge/skrooge_bank/skgbankplugin.cpp index 9b82b57a9..5f560d82e 100644 --- a/plugins/skrooge/skrooge_bank/skgbankplugin.cpp +++ b/plugins/skrooge/skrooge_bank/skgbankplugin.cpp @@ -69,13 +69,13 @@ bool SKGBankPlugin::setupActions(SKGDocument* iDocument) int SKGBankPlugin::getNbDashboardWidgets() { - return 4; + return 5; } QString SKGBankPlugin::getDashboardWidgetTitle(int iIndex) { if (iIndex == 0) { - return i18nc("Noun, a list of bank accounts", "Accounts (Light)"); + return i18nc("Noun, a list of bank accounts", "Accounts (Medium)"); } if (iIndex == 1) { return i18nc("Noun, a list of bank accounts", "Accounts (Full)"); @@ -83,7 +83,10 @@ QString SKGBankPlugin::getDashboardWidgetTitle(int iIndex) if (iIndex == 2) { return i18nc("Noun, a list of banks", "Banks (Light)"); } - return i18nc("Noun, a list of banks", "Banks (Full)"); + if (iIndex == 3) { + return i18nc("Noun, a list of banks", "Banks (Full)"); + } + return i18nc("Noun, a list of bank accounts", "Accounts (Light)"); } SKGBoardWidget* SKGBankPlugin::getDashboardWidget(int iIndex) @@ -98,18 +101,13 @@ SKGBoardWidget* SKGBankPlugin::getDashboardWidget(int iIndex) << QStringLiteral("t_TYPENLS") << QStringLiteral("t_BANK") << QStringLiteral("t_BANK_NUMBER"); - // Get QML mode for dashboard - KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton(); - KConfigSkeletonItem* sklItem = skl->findItem(QStringLiteral("qmlmode")); - bool qml = sklItem->property().toBool(); - if (iIndex == 0) { return new SKGAccountBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument); } if (iIndex == 1) { return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/account_table.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/account_table.qml")), QStringList() << QStringLiteral("v_account_display"), SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS, listForFilter); @@ -117,7 +115,7 @@ SKGBoardWidget* SKGBankPlugin::getDashboardWidget(int iIndex) if (iIndex == 2) { auto w = new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/bank_table_light.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/bank_table_light.qml")), QStringList() << QStringLiteral("v_account_display"), SKGSimplePeriodEdit::NONE, listForFilter); @@ -135,9 +133,30 @@ SKGBoardWidget* SKGBankPlugin::getDashboardWidget(int iIndex) w->addAction(open); return w; } + if (iIndex == 3) { + return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, + getDashboardWidgetTitle(iIndex), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/bank_table.qml")), + QStringList() << QStringLiteral("v_account_display"), + SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS, + listForFilter); + } + + listForFilter = QStringList() + << QStringLiteral("t_name") + << QStringLiteral("t_number") + << QStringLiteral("t_agency_number") + << QStringLiteral("t_agency_address") + << QStringLiteral("t_comment") + << QStringLiteral("t_TYPENLS") + << QStringLiteral("t_BANK") + << QStringLiteral("t_BANK_NUMBER") + << QStringLiteral("t_close") + << QStringLiteral("t_type") + << QStringLiteral("t_bookmarked"); return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/bank_table.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/account_table_light.qml")), QStringList() << QStringLiteral("v_account_display"), SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS, listForFilter); diff --git a/plugins/skrooge/skrooge_calculator/skgcalculatorplugin.cpp b/plugins/skrooge/skrooge_calculator/skgcalculatorplugin.cpp index b06e9ec29..fbc53b185 100644 --- a/plugins/skrooge/skrooge_calculator/skgcalculatorplugin.cpp +++ b/plugins/skrooge/skrooge_calculator/skgcalculatorplugin.cpp @@ -68,10 +68,6 @@ QString SKGCalculatorPlugin::getDashboardWidgetTitle(int iIndex) SKGBoardWidget* SKGCalculatorPlugin::getDashboardWidget(int iIndex) { Q_UNUSED(iIndex) - // Get QML mode for dashboard - KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton(); - KConfigSkeletonItem* sklItem = skl->findItem(QStringLiteral("qmlmode")); - bool qml = sklItem->property().toBool(); auto listForFilter = QStringList() << QStringLiteral("t_name") << QStringLiteral("t_number") @@ -85,7 +81,7 @@ SKGBoardWidget* SKGCalculatorPlugin::getDashboardWidget(int iIndex) return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/interests.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/interests.qml")), QStringList() << QStringLiteral("v_account_display") << QStringLiteral("interest"), SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_YEARS, listForFilter); diff --git a/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp b/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp index 6aef84dae..0c8b39c1c 100644 --- a/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp +++ b/plugins/skrooge/skrooge_categories/skgcategoriesplugin.cpp @@ -140,32 +140,27 @@ QString SKGCategoriesPlugin::getDashboardWidgetTitle(int iIndex) SKGBoardWidget* SKGCategoriesPlugin::getDashboardWidget(int iIndex) { SKGTRACEINFUNC(1) - // Get QML mode for dashboard - KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton(); - KConfigSkeletonItem* sklItem = skl->findItem(QStringLiteral("qmlmode")); - bool qml = sklItem->property().toBool(); - if (iIndex == 0) { return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/categories_period_table.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/categories_period_table.qml")), QStringList() << QStringLiteral("v_suboperation_consolidated"), SKGSimplePeriodEdit::ALL_PERIODS); } if (iIndex == 1) { return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex) % " - %1", - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/categories_variations.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/categories_variations.qml")), QStringList() << QStringLiteral("v_suboperation_consolidated"), SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS); } if (iIndex == 2) { return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex) % " - %1", - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/budget_table.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/budget_table.qml")), QStringList() << QStringLiteral("v_budget"), SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_MONTHS); } return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex) % " - %1", - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/categories_variations_issues.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/categories_variations_issues.qml")), QStringList() << QStringLiteral("v_suboperation_consolidated"), SKGSimplePeriodEdit::PREVIOUS_AND_CURRENT_PERIODS); } diff --git a/plugins/skrooge/skrooge_operation/CMakeLists.txt b/plugins/skrooge/skrooge_operation/CMakeLists.txt index 097edc555..10ff15414 100644 --- a/plugins/skrooge/skrooge_operation/CMakeLists.txt +++ b/plugins/skrooge/skrooge_operation/CMakeLists.txt @@ -13,11 +13,10 @@ SET(skrooge_operation_SRCS skgsplittabledelegate.cpp skgoperationplugin.cpp skgoperationpluginwidget.cpp - skgoperationboardwidget.cpp skgoperationboardwidgetqml.cpp ) -ki18n_wrap_ui(skrooge_operation_SRCS skgoperationpluginwidget_base.ui skgoperationpluginwidget_pref.ui skgoperationpluginwidget_board.ui ) +ki18n_wrap_ui(skrooge_operation_SRCS skgoperationpluginwidget_base.ui skgoperationpluginwidget_pref.ui) kconfig_add_kcfg_files(skrooge_operation_SRCS skgoperation_settings.kcfgc ) KCOREADDONS_ADD_PLUGIN(skrooge_operation SOURCES ${skrooge_operation_SRCS} INSTALL_NAMESPACE "skg_gui" JSON "metadata.json") diff --git a/plugins/skrooge/skrooge_operation/skgoperationboardwidget.cpp b/plugins/skrooge/skrooge_operation/skgoperationboardwidget.cpp deleted file mode 100644 index dcfd3fc2b..000000000 --- a/plugins/skrooge/skrooge_operation/skgoperationboardwidget.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/*************************************************************************** - * SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] - * SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] - * SPDX-License-Identifier: GPL-3.0-or-later - ***************************************************************************/ -/** @file - * This file is Skrooge plugin for operation management. - * - * @author Stephane MANKOWSKI / Guillaume DE BURE - */ -#include "skgoperationboardwidget.h" - -#include <qdom.h> -#include <qparallelanimationgroup.h> -#include <qpropertyanimation.h> -#include <qaction.h> -#include <qwidgetaction.h> - -#include <kcolorscheme.h> - -#include "skgdocumentbank.h" -#include "skgmainpanel.h" -#include "skgobjectbase.h" -#include "skgperiodedit.h" -#include "skgreportbank.h" -#include "skgservices.h" -#include "skgtraces.h" - -SKGOperationBoardWidget::SKGOperationBoardWidget(QWidget* iParent, SKGDocument* iDocument) - : SKGBoardWidget(iParent, iDocument, i18nc("Dashboard widget title", "Income & Expenditure")), - m_periodEdit1(nullptr), m_periodEdit2(nullptr), m_anim(nullptr) -{ - SKGTRACEINFUNC(10) - - m_timer.setSingleShot(true); - connect(&m_timer, &QTimer::timeout, this, [ = ]() { - this->dataModified(); - }, Qt::QueuedConnection); - - // Initialize animation group - m_anim = new QParallelAnimationGroup(this); - - auto f = new QFrame(); - ui.setupUi(f); - setMainWidget(f); - KColorScheme scheme(QPalette::Normal, KColorScheme::Window); - auto color = scheme.foreground(KColorScheme::NormalText).color().name().right(6); - - ui.kIncomeLabel->setText("<a href=\"IC\" style=\"color: #" % color % "\">" % ui.kIncomeLabel->text() % "</a>"); - ui.kExpenseLabel->setText("<a href=\"EC\" style=\"color: #" % color % "\">" % ui.kExpenseLabel->text() % "</a>"); - ui.kSavingLabel->setText("<a href=\"SC\" style=\"color: #" % color % "\">" % ui.kSavingLabel->text() % "</a>"); - ui.kIncome_previousLabel->setText("<a href=\"IP\" style=\"color: #" % color % "\">" % ui.kIncome_previousLabel->text() % "</a>"); - ui.kExpense_previousLabel->setText("<a href=\"EP\" style=\"color: #" % color % "\">" % ui.kExpense_previousLabel->text() % "</a>"); - ui.kSaving_previousLabel->setText("<a href=\"SP\" style=\"color: #" % color % "\">" % ui.kSaving_previousLabel->text() % "</a>"); - - connect(ui.kIncomeLabel, &QLabel::linkActivated, this, &SKGOperationBoardWidget::onOpen); - connect(ui.kExpenseLabel, &QLabel::linkActivated, this, &SKGOperationBoardWidget::onOpen); - connect(ui.kSavingLabel, &QLabel::linkActivated, this, &SKGOperationBoardWidget::onOpen); - connect(ui.kIncome_previousLabel, &QLabel::linkActivated, this, &SKGOperationBoardWidget::onOpen); - connect(ui.kExpense_previousLabel, &QLabel::linkActivated, this, &SKGOperationBoardWidget::onOpen); - connect(ui.kSaving_previousLabel, &QLabel::linkActivated, this, &SKGOperationBoardWidget::onOpen); - - // Create menu - setContextMenuPolicy(Qt::ActionsContextMenu); - - QStringList overlayopen; - overlayopen.push_back(QStringLiteral("quickopen")); - m_menuOpen = new QAction(SKGServices::fromTheme(QStringLiteral("view-statistics"), overlayopen), i18nc("Verb", "Open report..."), this); - connect(m_menuOpen, &QAction::triggered, SKGMainPanel::getMainPanel(), [ = ]() { - SKGMainPanel::getMainPanel()->SKGMainPanel::openPage(); - }); - addAction(m_menuOpen); - - { - auto sep = new QAction(this); - sep->setSeparator(true); - addAction(sep); - } - m_menuGroup = new QAction(i18nc("Noun, a type of operations", "Grouped"), this); - m_menuGroup->setCheckable(true); - m_menuGroup->setChecked(false); - connect(m_menuGroup, &QAction::triggered, this, &SKGOperationBoardWidget::refreshDelayed); - addAction(m_menuGroup); - - m_menuTransfer = new QAction(i18nc("Noun, a type of operations", "Transfers"), this); - m_menuTransfer->setCheckable(true); - m_menuTransfer->setChecked(false); - connect(m_menuTransfer, &QAction::triggered, this, &SKGOperationBoardWidget::refreshDelayed); - addAction(m_menuTransfer); - - connect(m_menuGroup, &QAction::toggled, m_menuTransfer, &QAction::setEnabled); - - m_menuTracked = new QAction(i18nc("Noun, a type of operations", "Tracked"), this); - m_menuTracked->setCheckable(true); - m_menuTracked->setChecked(true); - connect(m_menuTracked, &QAction::triggered, this, &SKGOperationBoardWidget::refreshDelayed); - addAction(m_menuTracked); - - m_menuSuboperation = new QAction(i18nc("Noun, a type of operations", "On suboperations"), this); - m_menuSuboperation->setCheckable(true); - m_menuSuboperation->setChecked(false); - connect(m_menuSuboperation, &QAction::triggered, this, &SKGOperationBoardWidget::refreshDelayed); - addAction(m_menuSuboperation); - - { - auto sep = new QAction(this); - sep->setSeparator(true); - addAction(sep); - } - - m_periodEdit1 = new SKGPeriodEdit(this, true); - m_periodEdit1->setObjectName(QStringLiteral("m_periodEdit1")); - { - // Set default - QDomDocument doc(QStringLiteral("SKGML")); - QDomElement root = doc.createElement(QStringLiteral("parameters")); - doc.appendChild(root); - root.setAttribute(QStringLiteral("period"), SKGServices::intToString(static_cast<int>(SKGPeriodEdit::CURRENT))); - m_periodEdit1->setState(doc.toString()); - - // Add widget in menu - auto periodEditWidget = new QWidgetAction(this); - periodEditWidget->setObjectName(QStringLiteral("m_periodEdit1Action")); - periodEditWidget->setDefaultWidget(m_periodEdit1); - - addAction(periodEditWidget); - } - - { - auto sep = new QAction(this); - sep->setSeparator(true); - addAction(sep); - } - - m_periodEdit2 = new SKGPeriodEdit(this, true); - m_periodEdit2->setObjectName(QStringLiteral("m_periodEdit2")); - { - // Set default - QDomDocument doc(QStringLiteral("SKGML")); - QDomElement root = doc.createElement(QStringLiteral("parameters")); - doc.appendChild(root); - root.setAttribute(QStringLiteral("period"), SKGServices::intToString(static_cast<int>(SKGPeriodEdit::PREVIOUS))); - m_periodEdit2->setState(doc.toString()); - - // Add widget in menu - auto periodEditWidget = new QWidgetAction(this); - periodEditWidget->setObjectName(QStringLiteral("m_periodEdit2Action")); - periodEditWidget->setDefaultWidget(m_periodEdit2); - - addAction(periodEditWidget); - } - - // Refresh - connect(m_periodEdit1, &SKGPeriodEdit::changed, this, &SKGOperationBoardWidget::refreshDelayed, Qt::QueuedConnection); - connect(m_periodEdit2, &SKGPeriodEdit::changed, this, &SKGOperationBoardWidget::refreshDelayed, Qt::QueuedConnection); - connect(getDocument(), &SKGDocument::tableModified, this, &SKGOperationBoardWidget::dataModified, Qt::QueuedConnection); -} - -SKGOperationBoardWidget::~SKGOperationBoardWidget() -{ - SKGTRACEINFUNC(10) - m_menuGroup = nullptr; - m_menuTransfer = nullptr; - m_menuTracked = nullptr; - m_anim = nullptr; -} - -QString SKGOperationBoardWidget::getState() -{ - QDomDocument doc(QStringLiteral("SKGML")); - doc.setContent(SKGBoardWidget::getState()); - QDomElement root = doc.documentElement(); - - root.setAttribute(QStringLiteral("menuGroup"), (m_menuGroup != nullptr) && m_menuGroup->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")); - root.setAttribute(QStringLiteral("menuTransfert"), (m_menuTransfer != nullptr) && m_menuTransfer->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")); - root.setAttribute(QStringLiteral("menuTracked"), (m_menuTracked != nullptr) && m_menuTracked->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")); - root.setAttribute(QStringLiteral("menuSuboperation"), (m_menuSuboperation != nullptr) && m_menuSuboperation->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")); - root.setAttribute(QStringLiteral("period1"), m_periodEdit1 != nullptr ? m_periodEdit1->getState() : QLatin1String("")); - root.setAttribute(QStringLiteral("period2"), m_periodEdit2 != nullptr ? m_periodEdit2->getState() : QLatin1String("")); - return doc.toString(); -} - -void SKGOperationBoardWidget::setState(const QString& iState) -{ - SKGBoardWidget::setState(iState); - - QDomDocument doc(QStringLiteral("SKGML")); - doc.setContent(iState); - QDomElement root = doc.documentElement(); - if (m_menuGroup != nullptr) { - QString val = root.attribute(QStringLiteral("menuGroup")); - if (val.isEmpty()) { - val = root.attribute(QStringLiteral("menuTransfert")); - } - m_menuGroup->setChecked(val == QStringLiteral("Y")); - } - if (m_menuTransfer != nullptr) { - m_menuTransfer->setChecked(root.attribute(QStringLiteral("menuTransfert")) == QStringLiteral("Y")); - } - if (m_menuTracked != nullptr) { - m_menuTracked->setChecked(root.attribute(QStringLiteral("menuTracked")) != QStringLiteral("N")); - } - if (m_menuSuboperation != nullptr) { - m_menuSuboperation->setChecked(root.attribute(QStringLiteral("menuSuboperation")) == QStringLiteral("Y")); - } - QString period1 = root.attribute(QStringLiteral("period1")); - if ((m_periodEdit1 != nullptr) && !period1.isEmpty()) { - m_periodEdit1->setState(period1); - } - QString period2 = root.attribute(QStringLiteral("period2")); - if ((m_periodEdit2 != nullptr) && !period2.isEmpty()) { - m_periodEdit2->setState(period2); - } - refreshDelayed(); -} - -void SKGOperationBoardWidget::onOpen(const QString& iLink) -{ - bool onSubOperation = ((m_menuSuboperation != nullptr) && m_menuSuboperation->isChecked()); - - // Call operation plugin - QString wc; - if (iLink.endsWith(QLatin1String("C"))) { - wc = m_periodEdit1->getWhereClause() % " AND t_TYPEACCOUNT<>'L'"; - } else { - wc = m_periodEdit2->getWhereClause() % " AND t_TYPEACCOUNT<>'L'"; - } - - if (iLink.startsWith(QLatin1String("I"))) { - wc = wc % " AND t_TYPEEXPENSE='+'"; - } else if (iLink.startsWith(QLatin1String("E"))) { - wc = wc % " AND t_TYPEEXPENSE='-'"; - } - - wc = wc % ((m_menuGroup != nullptr) && m_menuGroup->isChecked() ? "" : " AND i_group_id=0") % ((m_menuTransfer != nullptr) && m_menuTransfer->isChecked() ? "" : " AND t_TRANSFER='N'") % ((m_menuTracked != nullptr) && m_menuTracked->isChecked() ? "" : (onSubOperation ? " AND t_REALREFUND=''" : " AND t_REFUND=''")); - - QString title; - if (iLink == QStringLiteral("IC")) { - title = i18nc("Title of a list of operations", "Incomes of %1", ui.kLabel->text()); - } else if (iLink == QStringLiteral("EC")) { - title = i18nc("Title of a list of operations", "Expenses of %1", ui.kLabel->text()); - } else if (iLink == QStringLiteral("SC")) { - title = i18nc("Title of a list of operations", "Savings of %1", ui.kLabel->text()); - } else if (iLink == QStringLiteral("IP")) { - title = i18nc("Title of a list of operations", "Incomes of %1", ui.kLabel_previous->text()); - } else if (iLink == QStringLiteral("EP")) { - title = i18nc("Title of a list of operations", "Expenses of %1", ui.kLabel_previous->text()); - } else if (iLink == QStringLiteral("SP")) { - title = i18nc("Title of a list of operations", "Savings of %1", ui.kLabel_previous->text()); - } - SKGMainPanel::getMainPanel()->openPage("skg://skrooge_operation_plugin/" % QString(onSubOperation ? QStringLiteral("SKGOPERATION_CONSOLIDATED_DEFAULT_PARAMETERS/") : QString()) % "?operationTable=" % SKGServices::encodeForUrl(onSubOperation ? QStringLiteral("v_suboperation_consolidated") : QStringLiteral("v_operation_display")) % "&title_icon=view-bank-account¤tPage=-1&title=" % SKGServices::encodeForUrl(title) % - "&operationWhereClause=" % SKGServices::encodeForUrl(wc)); -} - -void SKGOperationBoardWidget::refreshDelayed() -{ - m_timer.start(300); -} - -void SKGOperationBoardWidget::dataModified(const QString& iTableName, int iIdTransaction) -{ - SKGTRACEINFUNC(10) - Q_UNUSED(iIdTransaction) - QString table = ((m_menuSuboperation != nullptr) && m_menuSuboperation->isChecked() ? QStringLiteral("v_suboperation_consolidated") : QStringLiteral("v_operation_display")); - if ((m_periodEdit1 != nullptr) && (m_periodEdit2 != nullptr) && (iTableName == table || iTableName.isEmpty())) { - // Set titles - ui.kLabel->setText(m_periodEdit1->text()); - ui.kLabel_previous->setText(m_periodEdit2->text()); - - auto* doc = qobject_cast<SKGDocumentBank*>(getDocument()); - if (doc != nullptr) { - if (m_menuOpen != nullptr) { - QString url = QStringLiteral("skg://skrooge_report_plugin/?grouped=") % ((m_menuGroup != nullptr) && m_menuGroup->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")) % "&transfers=" - % ((m_menuTransfer != nullptr) && m_menuTransfer->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")) % "&tracked=" - % ((m_menuTracked != nullptr) && m_menuTracked->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")) % "&expenses=Y&incomes=Y&lines2=t_TYPEEXPENSENLS&columns=d_DATEMONTH¤tPage=-1" % - "&mode=0&interval=3&period=3" % - "&tableAndGraphState.graphMode=1&tableAndGraphState.allPositive=Y&tableAndGraphState.show=graph&title=" % - SKGServices::encodeForUrl(i18nc("Noun, the title of a section", "Income & Expenditure")); - m_menuOpen->setData(url); - } - - SKGServices::SKGUnitInfo primary = doc->getPrimaryUnit(); - SKGServices::SKGUnitInfo secondary = doc->getSecondaryUnit(); - - auto* bk = qobject_cast< SKGReportBank* >(doc->getReport()); - if (bk != nullptr) { - QVariantList table2 = bk->getIncomeVsExpenditure((m_menuSuboperation != nullptr) && m_menuSuboperation->isChecked(), - (m_menuGroup != nullptr) && m_menuGroup->isChecked(), - (m_menuTransfer != nullptr) && m_menuTransfer->isChecked(), - (m_menuTracked != nullptr) && m_menuTracked->isChecked(), - m_periodEdit1->getWhereClause(), - m_periodEdit2->getWhereClause()); - delete bk; - - QVariantList l1 = table2.value(1).toList(); - QVariantList l2 = table2.value(2).toList(); - double income_previous_month = l1.value(2).toDouble(); - double expense_previous_month = l2.value(2).toDouble(); - double income_month = l1.value(3).toDouble(); - double expense_month = l2.value(3).toDouble(); - - // Set Maximum - int max = qMax(income_previous_month, qMax(expense_previous_month, qMax(income_month, expense_month))); - if (max == 0) { - max = 100.0; - } - ui.kIncome->setMaximum(max); - ui.kIncome_previous->setMaximum(max); - ui.kExpense->setMaximum(max); - ui.kExpense_previous->setMaximum(max); - ui.kSaving->setMaximum(max); - ui.kSaving_previous->setMaximum(max); - - // Set texts and tool tips - ui.kIncome->setFormat(doc->formatMoney(income_month, primary, false)); - ui.kIncome_previous->setFormat(doc->formatMoney(income_previous_month, primary, false)); - ui.kExpense->setFormat(doc->formatMoney(expense_month, primary, false)); - ui.kExpense_previous->setFormat(doc->formatMoney(expense_previous_month, primary, false)); - ui.kSaving->setFormat(doc->formatMoney(income_month - expense_month, primary, false)); - ui.kSaving_previous->setFormat(doc->formatMoney(income_previous_month - expense_previous_month, primary, false)); - if (!secondary.Symbol.isEmpty() && (secondary.Value != 0.0)) { - ui.kIncome->setToolTip(doc->formatMoney(income_month, secondary, false)); - ui.kIncome_previous->setToolTip(doc->formatMoney(income_previous_month, secondary, false)); - ui.kExpense->setToolTip(doc->formatMoney(expense_month, secondary, false)); - ui.kExpense_previous->setToolTip(doc->formatMoney(expense_previous_month, secondary, false)); - ui.kSaving->setToolTip(doc->formatMoney(income_month - expense_month, secondary, false)); - ui.kSaving_previous->setToolTip(doc->formatMoney(income_previous_month - expense_previous_month, secondary, false)); - } - - // Change colors - ui.kIncome->setLimits(0, 0, max); - ui.kIncome_previous->setLimits(0, 0, max); - ui.kExpense->setLimits(max, -1, -1); - ui.kExpense_previous->setLimits(max, -1, -1); - ui.kSaving->setLimits(income_month - expense_month < 0 ? max : 0, 0.1 * income_month, max); - ui.kSaving_previous->setLimits(income_previous_month - expense_previous_month < 0 ? max : 0, 0.1 * income_previous_month, max); - - // Set values - if (m_anim != nullptr) { - m_anim->clear(); - } - SKGOperationBoardWidget::setValue(ui.kIncome, income_month); - SKGOperationBoardWidget::setValue(ui.kIncome_previous, income_previous_month); - SKGOperationBoardWidget::setValue(ui.kExpense, expense_month); - SKGOperationBoardWidget::setValue(ui.kExpense_previous, expense_previous_month); - SKGOperationBoardWidget::setValue(ui.kSaving, qAbs(income_month - expense_month)); - SKGOperationBoardWidget::setValue(ui.kSaving_previous, qAbs(income_previous_month - expense_previous_month)); - if (m_anim != nullptr) { - QTimer::singleShot(1000, Qt::CoarseTimer, m_anim, [ = ]() { - m_anim->start(); - }); - } - } - - // No widget if no account - bool exist = false; - doc->existObjects(QStringLiteral("account"), QLatin1String(""), exist); - if (parentWidget() != nullptr) { - setVisible(exist); - } - } - } -} - -void SKGOperationBoardWidget::setValue(SKGProgressBar* iWidget, double iValue) -{ - if (m_anim != nullptr) { - auto panim = new QPropertyAnimation(iWidget, "value"); - panim->setDuration(1000); - panim->setStartValue(0); - panim->setEndValue(static_cast<int>(iValue)); - m_anim->addAnimation(panim); - } else { - iWidget->setValue(iValue); - } -} - diff --git a/plugins/skrooge/skrooge_operation/skgoperationboardwidget.h b/plugins/skrooge/skrooge_operation/skgoperationboardwidget.h deleted file mode 100644 index 63cbca979..000000000 --- a/plugins/skrooge/skrooge_operation/skgoperationboardwidget.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] - * SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] - * SPDX-License-Identifier: GPL-3.0-or-later - ***************************************************************************/ -#ifndef SKGOPERATIONBOARDWIDGET_H -#define SKGOPERATIONBOARDWIDGET_H -/** @file -* This file is Skrooge plugin for operation management. -* -* @author Stephane MANKOWSKI / Guillaume DE BURE -*/ -#include <qtimer.h> - -#include "skgboardwidget.h" -#include "ui_skgoperationpluginwidget_board.h" - -class QAction; -class SKGPeriodEdit; -class QParallelAnimationGroup; - -/** - * This file is Skrooge plugin for operation management - */ -class SKGOperationBoardWidget : public SKGBoardWidget -{ - Q_OBJECT - -public: - /** - * Default Constructor - * @param iParent the parent widget - * @param iDocument the document - */ - explicit SKGOperationBoardWidget(QWidget* iParent, SKGDocument* iDocument); - - /** - * Default Destructor - */ - ~SKGOperationBoardWidget() override; - - /** - * Get the current state - * MUST BE OVERWRITTEN - * @return a string containing all information needed to set the same state. - * Could be an XML stream - */ - QString getState() override; - - /** - * Set the current state - * MUST BE OVERWRITTEN - * @param iState must be interpreted to set the state of the widget - */ - void setState(const QString& iState) override; - -private Q_SLOTS: - void refreshDelayed(); - void dataModified(const QString& iTableName = QString(), int iIdTransaction = 0); - void onOpen(const QString& iLink); - -private: - Q_DISABLE_COPY(SKGOperationBoardWidget) - - void setValue(SKGProgressBar* iWidget, double iValue); - - Ui::skgoperationplugin_board ui{}; - - QAction* m_menuOpen; - QAction* m_menuGroup; - QAction* m_menuTransfer; - QAction* m_menuTracked; - QAction* m_menuSuboperation; - - SKGPeriodEdit* m_periodEdit1; - SKGPeriodEdit* m_periodEdit2; - - QParallelAnimationGroup* m_anim; - - QTimer m_timer; -}; - -#endif // SKGOPERATIONBOARDWIDGET_H diff --git a/plugins/skrooge/skrooge_operation/skgoperationplugin.cpp b/plugins/skrooge/skrooge_operation/skgoperationplugin.cpp index b8c31bff5..d745a9414 100644 --- a/plugins/skrooge/skrooge_operation/skgoperationplugin.cpp +++ b/plugins/skrooge/skrooge_operation/skgoperationplugin.cpp @@ -28,7 +28,6 @@ #include "skghtmlboardwidget.h" #include "skgmainpanel.h" #include "skgoperation_settings.h" -#include "skgoperationboardwidget.h" #include "skgoperationboardwidgetqml.h" #include "skgoperationobject.h" #include "skgoperationpluginwidget.h" @@ -454,16 +453,8 @@ QString SKGOperationPlugin::getDashboardWidgetTitle(int iIndex) SKGBoardWidget* SKGOperationPlugin::getDashboardWidget(int iIndex) { - // Get QML mode for dashboard - KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton(); - KConfigSkeletonItem* sklItem = skl->findItem(QStringLiteral("qmlmode")); - bool qml = sklItem->property().toBool(); - if (iIndex == 0) { - if (qml) { - return new SKGOperationBoardWidgetQml(SKGMainPanel::getMainPanel(), m_currentBankDocument); - } - return new SKGOperationBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument); + return new SKGOperationBoardWidgetQml(SKGMainPanel::getMainPanel(), m_currentBankDocument); } return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), diff --git a/plugins/skrooge/skrooge_operation/skgoperationpluginwidget_board.ui b/plugins/skrooge/skrooge_operation/skgoperationpluginwidget_board.ui deleted file mode 100644 index 9fb7a77fc..000000000 --- a/plugins/skrooge/skrooge_operation/skgoperationpluginwidget_board.ui +++ /dev/null @@ -1,248 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <author> -SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] -SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] -SPDX-License-Identifier: GPL-3.0-or-later - </author> - <class>skgoperationplugin_board</class> - <widget class="QWidget" name="skgoperationplugin_board"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>217</width> - <height>208</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="margin"> - <number>0</number> - </property> - <item> - <widget class="QFrame" name="kGroup"> - <layout class="QGridLayout" name="gridLayout"> - <property name="margin"> - <number>0</number> - </property> - <property name="spacing"> - <number>2</number> - </property> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="kLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - <underline>true</underline> - </font> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="SKGProgressBar" name="kIncome"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="format"> - <string>%p</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="kExpenseLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Expenditure:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="SKGProgressBar" name="kExpense"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="format"> - <string>%p</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QLabel" name="kLabel_previous"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - <underline>true</underline> - </font> - </property> - <property name="text"> - <string notr="true"/> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="kIncome_previousLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Income:</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="SKGProgressBar" name="kIncome_previous"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="format"> - <string>%p</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="kExpense_previousLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Expenditure:</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="SKGProgressBar" name="kExpense_previous"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="format"> - <string>%p</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="kIncomeLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Income:</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="kSavingLabel"> - <property name="text"> - <string>Saving:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="SKGProgressBar" name="kSaving"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="format"> - <string>%p</string> - </property> - </widget> - </item> - <item row="8" column="1"> - <widget class="SKGProgressBar" name="kSaving_previous"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="format"> - <string>%p</string> - </property> - </widget> - </item> - <item row="8" column="0"> - <widget class="QLabel" name="kSaving_previousLabel"> - <property name="text"> - <string>Saving:</string> - </property> - </widget> - </item> - <item row="9" column="1"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>SKGProgressBar</class> - <extends>QProgressBar</extends> - <header>skgprogressbar.h</header> - </customwidget> - </customwidgets> - <resources/> - <connections/> - <slots> - <slot>onOpen(QString)</slot> - </slots> -</ui> diff --git a/plugins/skrooge/skrooge_report/skgreportplugin.cpp b/plugins/skrooge/skrooge_report/skgreportplugin.cpp index ba3eab6e0..99c80b178 100644 --- a/plugins/skrooge/skrooge_report/skgreportplugin.cpp +++ b/plugins/skrooge/skrooge_report/skgreportplugin.cpp @@ -132,14 +132,9 @@ SKGBoardWidget* SKGReportPlugin::getDashboardWidget(int iIndex) return new SKGReportBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument); } if (iIndex == 1) { - // Get QML mode for dashboard - KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton(); - KConfigSkeletonItem* sklItem = skl->findItem(QStringLiteral("qmlmode")); - bool qml = sklItem->property().toBool(); - return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex) % " - %1", - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/personal_finance_score.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/personal_finance_score.qml")), QStringList() << QStringLiteral("v_suboperation_consolidated"), SKGSimplePeriodEdit::PREVIOUS_MONTHS); } SKGObjectBase::SKGListSKGObjectBase objs; diff --git a/plugins/skrooge/skrooge_scheduled/skgscheduledboardwidget.cpp b/plugins/skrooge/skrooge_scheduled/skgscheduledboardwidget.cpp index 54e1d9b3d..ebea59318 100644 --- a/plugins/skrooge/skrooge_scheduled/skgscheduledboardwidget.cpp +++ b/plugins/skrooge/skrooge_scheduled/skgscheduledboardwidget.cpp @@ -27,8 +27,7 @@ SKGScheduledBoardWidget::SKGScheduledBoardWidget(QWidget* iParent, SKGDocument* iDocument) : SKGHtmlBoardWidget(iParent, iDocument, i18nc("Noun, the title of a section", "Scheduled operations"), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/scheduled_operations.") % - (SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton()->findItem(QStringLiteral("qmlmode"))->property().toBool() ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/scheduled_operations.qml")), QStringList() << QStringLiteral("v_recurrentoperation_display")) { SKGTRACEINFUNC(10) diff --git a/plugins/skrooge/skrooge_search/CMakeLists.txt b/plugins/skrooge/skrooge_search/CMakeLists.txt index e3d4c74f5..de85893f9 100644 --- a/plugins/skrooge/skrooge_search/CMakeLists.txt +++ b/plugins/skrooge/skrooge_search/CMakeLists.txt @@ -11,8 +11,7 @@ LINK_DIRECTORIES (${LIBRARY_OUTPUT_PATH}) SET(skrooge_search_SRCS skgsearchplugin.cpp - skgsearchpluginwidget.cpp - skgalarmboardwidget.cpp) + skgsearchpluginwidget.cpp) ki18n_wrap_ui(skrooge_search_SRCS skgsearchpluginwidget_base.ui skgsearchpluginwidget_pref.ui) kconfig_add_kcfg_files(skrooge_search_SRCS skgsearch_settings.kcfgc ) diff --git a/plugins/skrooge/skrooge_search/skgalarmboardwidget.cpp b/plugins/skrooge/skrooge_search/skgalarmboardwidget.cpp deleted file mode 100644 index 59615191e..000000000 --- a/plugins/skrooge/skrooge_search/skgalarmboardwidget.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/*************************************************************************** - * SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] - * SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] - * SPDX-License-Identifier: GPL-3.0-or-later - ***************************************************************************/ -/** @file - * This file is Skrooge plugin for bank management. - * - * @author Stephane MANKOWSKI / Guillaume DE BURE - */ -#include "skgalarmboardwidget.h" - -#include <qaction.h> - -#include <qdom.h> - -#include "skgaccountobject.h" -#include "skgdocumentbank.h" -#include "skgmainpanel.h" -#include "skgprogressbar.h" -#include "skgruleobject.h" -#include "skgservices.h" -#include "skgtraces.h" -#include "skgunitobject.h" - -SKGAlarmBoardWidget::SKGAlarmBoardWidget(QWidget* iParent, SKGDocument* iDocument) - : SKGBoardWidget(iParent, iDocument, i18nc("Dashboard widget title", "Alarms")) -{ - SKGTRACEINFUNC(10) - - // Create widget - m_frame = new QFrame(); - m_layout = new QVBoxLayout(m_frame); - m_layout->setSpacing(2); - m_layout->setContentsMargins(0, 0, 0, 0); - setMainWidget(m_frame); - - // Create menu - setContextMenuPolicy(Qt::ActionsContextMenu); - - auto open = new QAction(SKGServices::fromTheme(QStringLiteral("quickopen")), i18nc("Verb, open a page", "Open..."), this); - open->setData(QStringLiteral("skg://skrooge_search_plugin")); - connect(open, &QAction::triggered, SKGMainPanel::getMainPanel(), [ = ]() { - SKGMainPanel::getMainPanel()->SKGMainPanel::openPage(); - }); - addAction(open); - - m_menuFavorite = new QAction(SKGServices::fromTheme(QStringLiteral("bookmarks")), i18nc("Noun, an option in contextual menu", "Highlighted only"), this); - m_menuFavorite->setCheckable(true); - m_menuFavorite->setChecked(false); - connect(m_menuFavorite, &QAction::triggered, this, [ = ]() { - this->dataModified(); - }); - addAction(m_menuFavorite); - - // Refresh - connect(getDocument(), &SKGDocument::tableModified, this, &SKGAlarmBoardWidget::dataModified, Qt::QueuedConnection); -} - -SKGAlarmBoardWidget::~SKGAlarmBoardWidget() -{ - SKGTRACEINFUNC(10) - - m_menuFavorite = nullptr; -} - -QString SKGAlarmBoardWidget::getState() -{ - QDomDocument doc(QStringLiteral("SKGML")); - doc.setContent(SKGBoardWidget::getState()); - QDomElement root = doc.documentElement(); - - root.setAttribute(QStringLiteral("menuFavorite"), (m_menuFavorite != nullptr) && m_menuFavorite->isChecked() ? QStringLiteral("Y") : QStringLiteral("N")); - return doc.toString(); -} - -void SKGAlarmBoardWidget::setState(const QString& iState) -{ - SKGBoardWidget::setState(iState); - - QDomDocument doc(QStringLiteral("SKGML")); - doc.setContent(iState); - QDomElement root = doc.documentElement(); - - if (m_menuFavorite != nullptr) { - m_menuFavorite->setChecked(root.attribute(QStringLiteral("menuFavorite")) == QStringLiteral("Y")); - } - - dataModified(QLatin1String(""), 0); -} - -void SKGAlarmBoardWidget::dataModified(const QString& iTableName, int iIdTransaction) -{ - SKGTRACEINFUNC(10) - Q_UNUSED(iIdTransaction) - - if (iTableName == QStringLiteral("operation") || iTableName == QStringLiteral("rule") || iTableName.isEmpty()) { - // Remove all item of the layout - while (m_layout->count() != 0) { - QLayoutItem* child = m_layout->takeAt(0); - if (child != nullptr) { - QWidget* w = child->widget(); - delete w; - delete child; - } - } - - // Fill layout - auto* doc = qobject_cast<SKGDocumentBank*>(getDocument()); - if (doc != nullptr) { - SKGServices::SKGUnitInfo primary = doc->getPrimaryUnit(); - SKGServices::SKGUnitInfo secondary = doc->getSecondaryUnit(); - - // Build where clause - QString wc = QStringLiteral("t_action_type='A'"); - if ((m_menuFavorite != nullptr) && m_menuFavorite->isChecked()) { - wc = "t_bookmarked='Y' AND (" % wc % ')'; - } - - SKGObjectBase::SKGListSKGObjectBase rules; - SKGError err = doc->getObjects(QStringLiteral("v_rule"), wc % " ORDER BY i_ORDER", rules); - int nb = rules.count(); - if (nb != 0) { - for (int i = 0; !err && i < nb; ++i) { - SKGRuleObject rule(rules.at(i)); - SKGRuleObject::SKGAlarmInfo alarm = rule.getAlarmInfo(); - - // Create progress bar - auto progressBar = new SKGProgressBar(m_frame); - progressBar->setObjectName(QStringLiteral("progressBar")); - progressBar->setMaximum(qMax(alarm.Amount, alarm.Limit)); - progressBar->setValue(alarm.Amount); - - QSizePolicy newSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - newSizePolicy.setHorizontalStretch(0); - newSizePolicy.setVerticalStretch(0); - newSizePolicy.setHeightForWidth(progressBar->sizePolicy().hasHeightForWidth()); - progressBar->setSizePolicy(newSizePolicy); - - // Set tooltip - QString msg = alarm.Message; - // Build the message - if (alarm.Message.contains(QLatin1String("%3"))) { - msg = alarm.Message.arg(doc->formatMoney(alarm.Amount, primary, false), doc->formatMoney(alarm.Limit, primary, false), doc->formatMoney(alarm.Amount - alarm.Limit, primary, false)); - } else if (alarm.Message.contains(QLatin1String("%2"))) { - msg = alarm.Message.arg(doc->formatMoney(alarm.Amount, primary, false), doc->formatMoney(alarm.Limit, primary, false)); - } else if (alarm.Message.contains(QLatin1String("%1"))) { - msg = alarm.Message.arg(doc->formatMoney(alarm.Amount, primary, false)); - } - - QString txt = msg % "<br>"; - txt += doc->formatMoney(alarm.Amount, primary, false) % " / " % doc->formatMoney(alarm.Limit, primary, false); - if (!secondary.Symbol.isEmpty() && (secondary.Value != 0.0)) { - txt += "<br>" % doc->formatMoney(alarm.Amount, secondary, false) % " / " % doc->formatMoney(alarm.Limit, secondary, false); - } - progressBar->setToolTip(txt); - - // Change color - progressBar->setLimits(qMax(alarm.Amount, alarm.Limit), 0.9 * alarm.Limit, 0.7 * alarm.Limit); - - // Add progress bar - m_layout->addWidget(progressBar); - } - } else { - auto lab = new QLabel(m_frame); - lab->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByMouse); - lab->setText(i18nc("Message", R"(No alarm defined<br>on the <a href="%1">"Search and process"</a> page.)", "skg://Skrooge_search_plugin")); - connect(lab, &QLabel::linkActivated, this, [ = ](const QString & val) { - SKGMainPanel::getMainPanel()->openPage(val); - }); - - // Add progress bar - m_layout->addWidget(lab); - } - - // No widget if no account - bool exist = false; - getDocument()->existObjects(QStringLiteral("account"), QLatin1String(""), exist); - if (parentWidget() != nullptr) { - setVisible(exist); - } - } - } -} - - diff --git a/plugins/skrooge/skrooge_search/skgalarmboardwidget.h b/plugins/skrooge/skrooge_search/skgalarmboardwidget.h deleted file mode 100644 index 432a519e6..000000000 --- a/plugins/skrooge/skrooge_search/skgalarmboardwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * SPDX-FileCopyrightText: 2022 S. MANKOWSKI [email protected] - * SPDX-FileCopyrightText: 2022 G. DE BURE [email protected] - * SPDX-License-Identifier: GPL-3.0-or-later - ***************************************************************************/ -#ifndef SKGALARMBOARDWIDGET_H -#define SKGALARMBOARDWIDGET_H -/** @file -* This file is Skrooge dashbord plugin for alarms. -* -* @author Stephane MANKOWSKI / Guillaume DE BURE -*/ -#include "skgboardwidget.h" - -class QVBoxLayout; -class QFrame; -class QAction; - -/** - * This file is Skrooge dashbord plugin for alarms - */ -class SKGAlarmBoardWidget : public SKGBoardWidget -{ - Q_OBJECT - -public: - /** - * Default Constructor - * @param iParent the parent widget - * @param iDocument the document - */ - explicit SKGAlarmBoardWidget(QWidget* iParent, SKGDocument* iDocument); - - /** - * Default Destructor - */ - ~SKGAlarmBoardWidget() override; - - /** - * Get the current state - * MUST BE OVERWRITTEN - * @return a string containing all information needed to set the same state. - * Could be an XML stream - */ - QString getState() override; - - /** - * Set the current state - * MUST BE OVERWRITTEN - * @param iState must be interpreted to set the state of the widget - */ - void setState(const QString& iState) override; - -private Q_SLOTS: - void dataModified(const QString& iTableName = QString(), int iIdTransaction = 0); - -private: - Q_DISABLE_COPY(SKGAlarmBoardWidget) - QAction* m_menuFavorite; - QFrame* m_frame; - QVBoxLayout* m_layout; -}; - -#endif // SKGALARMBOARDWIDGET_H diff --git a/plugins/skrooge/skrooge_search/skgsearchplugin.cpp b/plugins/skrooge/skrooge_search/skgsearchplugin.cpp index 3e0c820a3..e8cb94620 100644 --- a/plugins/skrooge/skrooge_search/skgsearchplugin.cpp +++ b/plugins/skrooge/skrooge_search/skgsearchplugin.cpp @@ -17,7 +17,6 @@ #include <qdom.h> -#include "skgalarmboardwidget.h" #include "skgcategoryobject.h" #include "skgdocumentbank.h" #include "skgerror.h" @@ -63,17 +62,10 @@ QString SKGSearchPlugin::getDashboardWidgetTitle(int iIndex) SKGBoardWidget* SKGSearchPlugin::getDashboardWidget(int iIndex) { Q_UNUSED(iIndex) - // Get QML mode for dashboard - KConfigSkeleton* skl = SKGMainPanel::getMainPanel()->getPluginByName(QStringLiteral("Dashboard plugin"))->getPreferenceSkeleton(); - KConfigSkeletonItem* sklItem = skl->findItem(QStringLiteral("qmlmode")); - bool qml = sklItem->property().toBool(); - if (qml) { - return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, - getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/alarm.qml")), - QStringList() << QStringLiteral("operation") << QStringLiteral("rule")); - } - return new SKGAlarmBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument); + return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, + getDashboardWidgetTitle(iIndex), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/alarm.qml")), + QStringList() << QStringLiteral("operation") << QStringLiteral("rule")); } bool SKGSearchPlugin::setupActions(SKGDocument* iDocument) diff --git a/plugins/skrooge/skrooge_unit/skgunitplugin.cpp b/plugins/skrooge/skrooge_unit/skgunitplugin.cpp index cee935b90..2f78bd19d 100644 --- a/plugins/skrooge/skrooge_unit/skgunitplugin.cpp +++ b/plugins/skrooge/skrooge_unit/skgunitplugin.cpp @@ -105,7 +105,7 @@ SKGBoardWidget* SKGUnitPlugin::getDashboardWidget(int iIndex) return new SKGHtmlBoardWidget(SKGMainPanel::getMainPanel(), m_currentBankDocument, getDashboardWidgetTitle(iIndex), - QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/portfolio.") % (qml ? QStringLiteral("qml") : QStringLiteral("html"))), + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("skrooge/html/default/portfolio.qml")), QStringList() << QStringLiteral("v_operation_display"), SKGSimplePeriodEdit::NONE, listForFilter);
