File indexing completed on 2024-05-26 05:10:23
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * A plugin to advice 0008 * 0009 * @author Stephane MANKOWSKI 0010 */ 0011 #include "skgadviceplugin.h" 0012 0013 #include <kaboutdata.h> 0014 #include <kactioncollection.h> 0015 #include <kpluginfactory.h> 0016 #include <kstandardaction.h> 0017 0018 #include "skgadviceboardwidget.h" 0019 #include "skgmainpanel.h" 0020 #include "skgtipofdayboardwidget.h" 0021 #include "skgtraces.h" 0022 0023 /** 0024 * This plugin factory. 0025 */ 0026 K_PLUGIN_CLASS_WITH_JSON(SKGAdvicePlugin, "metadata.json") 0027 0028 SKGAdvicePlugin::SKGAdvicePlugin(QWidget* iWidget, QObject* iParent, const QVariantList& /*iArg*/) : SKGInterfacePlugin(iParent), currentDocument(nullptr) 0029 { 0030 SKGTRACEINFUNC(10) 0031 Q_UNUSED(iWidget) 0032 } 0033 0034 SKGAdvicePlugin::~SKGAdvicePlugin() 0035 { 0036 SKGTRACEINFUNC(10) 0037 currentDocument = nullptr; 0038 } 0039 0040 bool SKGAdvicePlugin::setupActions(SKGDocument* iDocument) 0041 { 0042 SKGTRACEINFUNC(10) 0043 0044 currentDocument = iDocument; 0045 0046 setComponentName(QStringLiteral("skg_advice"), title()); 0047 setXMLFile(QStringLiteral("skg_advice.rc")); 0048 0049 // Create yours actions here 0050 return true; 0051 } 0052 0053 int SKGAdvicePlugin::getNbDashboardWidgets() 0054 { 0055 SKGTRACEINFUNC(1) 0056 return 2; 0057 } 0058 0059 QString SKGAdvicePlugin::getDashboardWidgetTitle(int iIndex) 0060 { 0061 SKGTRACEINFUNC(1) 0062 if (iIndex == 0) { 0063 return i18nc("Noun, a list of items", "Advice"); 0064 } 0065 return i18nc("Noun, a list of items", "Tip of the day"); 0066 } 0067 0068 SKGBoardWidget* SKGAdvicePlugin::getDashboardWidget(int iIndex) 0069 { 0070 if (iIndex == 0) { 0071 return new SKGAdviceBoardWidget(SKGMainPanel::getMainPanel(), currentDocument); 0072 } 0073 return new SKGTipOfDayBoardWidget(SKGMainPanel::getMainPanel(), currentDocument); 0074 } 0075 0076 QString SKGAdvicePlugin::title() const 0077 { 0078 return i18nc("The title", "Advice"); 0079 } 0080 0081 QString SKGAdvicePlugin::icon() const 0082 { 0083 return QStringLiteral("help-hint"); 0084 } 0085 0086 QString SKGAdvicePlugin::toolTip() const 0087 { 0088 return i18nc("The tool tip", "Advice"); 0089 } 0090 0091 int SKGAdvicePlugin::getOrder() const 0092 { 0093 return 1; 0094 } 0095 0096 QStringList SKGAdvicePlugin::tips() const 0097 { 0098 QStringList output; 0099 output.push_back(i18nc("Description of a tip", "<p>… Skrooge can give you advice on how to manage your accounts. See the <a href=\"skg://dashboard_plugin\">dashboard</a>.</p>")); 0100 output.push_back(i18nc("Description of a tip", "<p>… Skrooge can automatically apply recommended corrections. See the <a href=\"skg://dashboard_plugin\">dashboard</a>.</p>")); 0101 return output; 0102 } 0103 0104 #include <skgadviceplugin.moc>