1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 8 #ifndef SCGTPLUGIN_H 9 #define SCGTPLUGIN_H 10 11 #include "scribusapi.h" 12 #include "scplugin.h" 13 #include "ui/customfdialog.h" 14 15 class QString; 16 class QCheckBox; 17 class QStringList; 18 class QDir; 19 class QWidget; 20 21 /** 22 @brief Super class for all text importer plugins. 23 @sa ScPlugin 24 @date 2006-06-05 25 @author Riku Leino <riku@scribus.info> 26 @note KK2006 27 */ 28 class SCRIBUS_API ScGTPlugin : public ScPlugin 29 { 30 Q_OBJECT 31 public: 32 ScGTPlugin(); 33 ~ScGTPlugin() = default; 34 35 /** 36 @brief Returns the file format's name that this plugin can import or QString() 37 @brief if this plugin doesn't handle files. 38 @return file format's name or QString() if this plugin doesn't handle files 39 */ 40 virtual QString fileFormatName() const = 0; 41 42 /** 43 @brief Returns file extensions this plugin can handle or an empty list if 44 @brief this plugin is a text/style formatter plugin. 45 @return file extensions this plugin can handle 46 */ 47 virtual QStringList fileExtensions() const = 0; 48 49 /** 50 @brief Run the plugin and import from the file <code>filename</code> 51 52 This function is ment to be overriden by all file format plugins. 53 Once the file decoding and text and style has been sorted out use the 54 function forward() to pass the text and it's style forward to a text frame 55 or to another plugin. 56 @sa forward() 57 @param filename name of the file that is wanted to be imported 58 @param encoding encoding as selected by a user in the import file dialog 59 */ 60 virtual void run(const QString&filename, const QString&encoding = QString()) {}; 61 62 /** 63 @brief Run the plugin and do the magic with the <code>text</code> and 64 @brief <code>style</code>. 65 66 This function is ment to be overriden by all text and style handler plugins. 67 @param text text to work with 68 */ run(const QString & text)69 virtual void run(const QString&text /*, insert style stuff here */) {}; 70 71 }; 72 73 /***************************************************************************************/ 74 /***************************************************************************************/ 75 76 /** 77 @brief Manages the import process. 78 79 All ScGTPlugins must be registered to the ScGTPluginManager with the function 80 registerGTPlugin(). Only registered plugins will be used. 81 @date 2006-06-05 82 @author Riku Leino <riku@scribus.info> 83 @note KK2006 84 */ 85 class SCRIBUS_API ScGTPluginManager { 86 public: 87 static ScGTPluginManager* instance(); // singleton 88 static void deleteInstance(); 89 90 void registerGTPlugin(ScGTPlugin *plugin); 91 void unRegisterGTPlugin(ScGTPlugin *plugin); 92 93 /** @brief Run the Get Text importer. Attached to the Get Text action */ 94 void run(); 95 96 private: 97 static ScGTPluginManager *m_instance; 98 99 QList<ScGTPlugin*> m_plugins; 100 101 ScGTPluginManager(); 102 ~ScGTPluginManager(); 103 104 QString fileFilter(); 105 106 /** @brief User has requested options which will be launched from here */ 107 void options(); 108 }; 109 110 /***************************************************************************************/ 111 /***************************************************************************************/ 112 113 class SCRIBUS_API ScGTFileDialog : public CustomFDialog { 114 Q_OBJECT 115 public: 116 ScGTFileDialog(const QString& dirName, const QString& filters, 117 QWidget* parent = nullptr, const char* name = nullptr); 118 ~ScGTFileDialog(); 119 120 bool showOptions() const; 121 bool append() const; 122 123 private: 124 QWidget *m_diaExtension {nullptr}; 125 QCheckBox *m_showOptionsBox {nullptr}; 126 QCheckBox *m_appendBox {nullptr}; 127 void customize(); 128 }; 129 130 /***************************************************************************************/ 131 /***************************************************************************************/ 132 133 class SCRIBUS_API ScGTOptions { 134 135 }; 136 137 /***************************************************************************************/ 138 /***************************************************************************************/ 139 140 class SCRIBUS_API ScGTOptionsWindow { 141 142 }; 143 144 #endif 145