| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2001-2014 Christoph Cullmann <cullmann@kde.org> |
| 3 | SPDX-FileCopyrightText: 2005-2014 Dominik Haumann <dhaumann@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KTEXTEDITOR_CONFIGPAGE_H |
| 9 | #define KTEXTEDITOR_CONFIGPAGE_H |
| 10 | |
| 11 | #include <ktexteditor_export.h> |
| 12 | |
| 13 | #include <QWidget> |
| 14 | |
| 15 | namespace KTextEditor |
| 16 | { |
| 17 | /*! |
| 18 | * \class KTextEditor::ConfigPage |
| 19 | * \inmodule KTextEditor |
| 20 | * \inheaderfile KTextEditor/ConfigPage |
| 21 | * |
| 22 | * \brief Config page interface for the Editor and Plugin%s. |
| 23 | * |
| 24 | * Introduction |
| 25 | * |
| 26 | * The class ConfigPage represents a config page. |
| 27 | * The config pages are usually embedded into a dialog that shows |
| 28 | * buttons like \c Defaults, \c Reset and \c Apply. If one of the buttons is |
| 29 | * clicked and the config page sent the signal changed() beforehand the |
| 30 | * Editor will call the corresponding slot, either defaults(), reset() or |
| 31 | * apply(). |
| 32 | * |
| 33 | * To obtain a useful navigation information for displaying to a user see name(), |
| 34 | * fullName() and icon() functions. |
| 35 | * |
| 36 | * Saving and Loading Config Data |
| 37 | * |
| 38 | * Saving and loading the configuration data can either be achieved by using |
| 39 | * the host application's KSharedConfig::openConfig() object, or by using an |
| 40 | * own configuration file. |
| 41 | * |
| 42 | * \sa KTextEditor::Editor, KTextEditor::Plugin |
| 43 | */ |
| 44 | class KTEXTEDITOR_EXPORT ConfigPage : public QWidget |
| 45 | { |
| 46 | Q_OBJECT |
| 47 | |
| 48 | public: |
| 49 | /*! |
| 50 | * Constructor. |
| 51 | * |
| 52 | * Create a new config page with the specified parent. |
| 53 | * |
| 54 | * \a parent is the parent widget |
| 55 | */ |
| 56 | ConfigPage(QWidget *parent); |
| 57 | |
| 58 | ~ConfigPage() override; |
| 59 | |
| 60 | /*! |
| 61 | * Get a readable name for the config page. The name should be translated. |
| 62 | * Returns name of given page index |
| 63 | * \sa fullName(), icon() |
| 64 | */ |
| 65 | virtual QString name() const = 0; |
| 66 | |
| 67 | /*! |
| 68 | * Get a readable full name for the config page. The name |
| 69 | * should be translated. |
| 70 | * |
| 71 | * Example: If the name is "Filetypes", the full name could be |
| 72 | * "Filetype Specific Settings". For "Shortcuts" the full name would be |
| 73 | * something like "Shortcut Configuration". |
| 74 | * Returns full name of given page index, default implementation returns name() |
| 75 | * \sa name(), icon() |
| 76 | */ |
| 77 | virtual QString fullName() const; |
| 78 | |
| 79 | /*! |
| 80 | * Get an icon for the config page. |
| 81 | * Returns icon for the given page index |
| 82 | * \sa name(), fullName() |
| 83 | */ |
| 84 | virtual QIcon icon() const; |
| 85 | |
| 86 | public Q_SLOTS: |
| 87 | /*! |
| 88 | * This slot is called whenever the button \c Apply or \c OK was clicked. |
| 89 | * Apply the changed settings made in the config page now. |
| 90 | */ |
| 91 | virtual void apply() = 0; |
| 92 | |
| 93 | /*! |
| 94 | * This slot is called whenever the button \c Reset was clicked. |
| 95 | * Reset the config page settings to the initial state. |
| 96 | */ |
| 97 | virtual void reset() = 0; |
| 98 | |
| 99 | /*! |
| 100 | * Sets default options |
| 101 | * This slot is called whenever the button \c Defaults was clicked. |
| 102 | * Set the config page settings to the default values. |
| 103 | */ |
| 104 | virtual void defaults() = 0; |
| 105 | |
| 106 | Q_SIGNALS: |
| 107 | /*! |
| 108 | * Emit this signal whenever a config option changed. |
| 109 | */ |
| 110 | void changed(); |
| 111 | |
| 112 | private: |
| 113 | class ConfigPagePrivate *const d; |
| 114 | }; |
| 115 | |
| 116 | } |
| 117 | |
| 118 | #endif |
| 119 | |