File indexing completed on 2024-05-12 15:45:39

0001 /*
0002     SPDX-FileCopyrightText: 2001-2014 Christoph Cullmann <cullmann@kde.org>
0003     SPDX-FileCopyrightText: 2005-2014 Dominik Haumann <dhaumann@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KTEXTEDITOR_CONFIGPAGE_H
0009 #define KTEXTEDITOR_CONFIGPAGE_H
0010 
0011 #include <ktexteditor_export.h>
0012 
0013 #include <QWidget>
0014 
0015 namespace KTextEditor
0016 {
0017 /**
0018  * \class ConfigPage configpage.h <KTextEditor/ConfigPage>
0019  *
0020  * \brief Config page interface for the Editor and Plugin%s.
0021  *
0022  * \section configpage_intro Introduction
0023  *
0024  * The class ConfigPage represents a config page.
0025  * The config pages are usually embedded into a dialog that shows
0026  * buttons like \e Defaults, \e Reset and \e Apply. If one of the buttons is
0027  * clicked and the config page sent the signal changed() beforehand the
0028  * Editor will call the corresponding slot, either defaults(), reset() or
0029  * apply().
0030  *
0031  * To obtain a useful navigation information for displaying to a user see name(),
0032  * fullName() and icon() functions.
0033  *
0034  * \section configpage_config Saving and Loading Config Data
0035  *
0036  * Saving and loading the configuration data can either be achieved by using
0037  * the host application's KSharedConfig::openConfig() object, or by using an
0038  * own configuration file.
0039  *
0040  * \see KTextEditor::Editor, KTextEditor::Plugin
0041  * \author Christoph Cullmann \<cullmann@kde.org\>
0042  */
0043 class KTEXTEDITOR_EXPORT ConfigPage : public QWidget
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     /**
0049      * Constructor.
0050      *
0051      * Create a new config page with \p parent.
0052      * \param parent parent widget
0053      */
0054     ConfigPage(QWidget *parent);
0055     /**
0056      * Virtual destructor.
0057      */
0058     ~ConfigPage() override;
0059 
0060     /**
0061      * Get a readable name for the config page. The name should be translated.
0062      * \return name of given page index
0063      * \see fullName(), icon()
0064      */
0065     virtual QString name() const = 0;
0066 
0067     /**
0068      * Get a readable full name for the config page. The name
0069      * should be translated.
0070      *
0071      * Example: If the name is "Filetypes", the full name could be
0072      * "Filetype Specific Settings". For "Shortcuts" the full name would be
0073      * something like "Shortcut Configuration".
0074      * \return full name of given page index, default implementation returns name()
0075      * \see name(), icon()
0076      */
0077     virtual QString fullName() const;
0078 
0079     /**
0080      * Get an icon for the config page.
0081      * \return icon for the given page index
0082      * \see name(), fullName()
0083      */
0084     virtual QIcon icon() const;
0085 
0086 public Q_SLOTS:
0087     /**
0088      * This slot is called whenever the button \e Apply or \e OK was clicked.
0089      * Apply the changed settings made in the config page now.
0090      */
0091     virtual void apply() = 0;
0092 
0093     /**
0094      * This slot is called whenever the button \e Reset was clicked.
0095      * Reset the config page settings to the initial state.
0096      */
0097     virtual void reset() = 0;
0098 
0099     /**
0100      * Sets default options
0101      * This slot is called whenever the button \e Defaults was clicked.
0102      * Set the config page settings to the default values.
0103      */
0104     virtual void defaults() = 0;
0105 
0106 Q_SIGNALS:
0107     /**
0108      * Emit this signal whenever a config option changed.
0109      */
0110     void changed();
0111 
0112 private:
0113     class ConfigPagePrivate *const d;
0114 };
0115 
0116 }
0117 
0118 #endif