File indexing completed on 2024-06-16 04:47:16
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 #ifndef SKGFILEPLUGIN_H 0007 #define SKGFILEPLUGIN_H 0008 /** @file 0009 * This file is a plugin for file operation. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 #include <qurl.h> 0014 0015 #include "skginterfaceplugin.h" 0016 #include "ui_skgfilepluginwidget_pref.h" 0017 0018 class QAction; 0019 class KRecentFilesAction; 0020 0021 0022 /** 0023 * This file is a plugin for file operation 0024 */ 0025 class SKGFilePlugin : public SKGInterfacePlugin 0026 { 0027 Q_OBJECT 0028 Q_INTERFACES(SKGInterfacePlugin) 0029 0030 public: 0031 /** 0032 * Default Constructor 0033 */ 0034 explicit SKGFilePlugin(QWidget* iWidget, QObject* iParent, const QVariantList& iArg); 0035 0036 /** 0037 * Default Destructor 0038 */ 0039 ~SKGFilePlugin() override; 0040 0041 /** 0042 * Called to initialise the plugin 0043 * @param iDocument the main document 0044 * @return true if the plugin is compatible with the document 0045 */ 0046 bool setupActions(SKGDocument* iDocument) override; 0047 0048 /** 0049 * This function is called when the application is launched again with new arguments 0050 * @param iArgument the arguments 0051 * @return the rest of arguments to treat 0052 */ 0053 QStringList processArguments(const QStringList& iArgument) override; 0054 0055 /** 0056 * The preference widget of the plugin. 0057 * @return The preference widget of the plugin 0058 */ 0059 QWidget* getPreferenceWidget() override; 0060 0061 /** 0062 * The preference skeleton of the plugin. 0063 * @return The preference skeleton of the plugin 0064 */ 0065 KConfigSkeleton* getPreferenceSkeleton() override; 0066 0067 /** 0068 * This function is called when preferences have been modified. Must be used to save some parameters into the document. 0069 * A transaction is already opened 0070 * @return an object managing the error. 0071 * @see SKGError 0072 */ 0073 SKGError savePreferences() const override; 0074 0075 /** 0076 * Must be modified to refresh widgets after a modification. 0077 */ 0078 void refresh() override; 0079 0080 /** 0081 * The title of the plugin. 0082 * @return The title of the plugin 0083 */ 0084 QString title() const override; 0085 0086 /** 0087 * The icon of the plugin. 0088 * @return The icon of the plugin 0089 */ 0090 QString icon() const override; 0091 0092 /** 0093 * The toolTip of the plugin. 0094 * @return The toolTip of the plugin 0095 */ 0096 QString toolTip() const override; 0097 0098 /** 0099 * Must be implemented to set the position of the plugin. 0100 * @return integer value between 0 and 999 (default = 999) 0101 */ 0102 int getOrder() const override; 0103 0104 /** 0105 * The tips list of the plugin. 0106 * @return The tips list of the plugin 0107 */ 0108 QStringList tips() const override; 0109 0110 /** 0111 * The advice list of the plugin. 0112 * @return The advice list of the plugin 0113 */ 0114 SKGAdviceList advice(const QStringList& iIgnoredAdvice) override; 0115 0116 Q_SIGNALS: 0117 /** 0118 * request to load a file 0119 * @param iFile file name 0120 */ 0121 void loadFile(const QUrl& iFile); 0122 0123 private Q_SLOTS: 0124 /** 0125 * @brief Open a Url 0126 * @param iUrl The url to open. 0127 * If empty, then the URL is searched on the property "filename" of the QAction sending 0128 * If still empty, an open panel is displayed 0129 * @return void 0130 */ 0131 void onOpen(const QUrl& iUrl = QUrl()); 0132 void onSave(); 0133 void onSaveAs(); 0134 void onReOpen(); 0135 void onRecover(); 0136 void onNew(); 0137 void onChangePassword(); 0138 private: 0139 Q_DISABLE_COPY(SKGFilePlugin) 0140 0141 QAction* m_saveAction; 0142 KRecentFilesAction* m_recentFiles; 0143 0144 SKGDocument* m_currentDocument; 0145 0146 Ui::skgfileplugin_pref ui{}; 0147 }; 0148 0149 #endif // SKGFILEPLUGIN_H