diff --git a/src/kcmodule.h b/src/kcmodule.h index e5ab3ab..83f5959 100644 --- a/src/kcmodule.h +++ b/src/kcmodule.h @@ -1,444 +1,446 @@ /* This file is part of the KDE libraries Copyright (c) 1999 Matthias Hoelzer-Kluepfel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KCMODULE_H #define KCMODULE_H #include #include #include #include class QStringList; class KAboutData; class KConfigDialogManager; class KCoreConfigSkeleton; class KConfigSkeleton; class KCModulePrivate; /** + * @class KCModule kcmodule.h KCModule + * * The base class for configuration modules. * * Configuration modules are realized as plugins that are loaded only when * needed. * * The module in principle is a simple widget displaying the * item to be changed. The module has a very small interface. * * All the necessary glue logic and the GUI bells and whistles * are provided by the control center and must not concern * the module author. * * To write a config module, you have to create a library * that contains a factory function like the following: * * \code * #include * * K_PLUGIN_FACTORY(MyKCModuleFactory, registerPlugin() ) * \endcode * * The constructor of the KCModule then looks like this: * \code * YourKCModule::YourKCModule( QWidget* parent ) * : KCModule( parent ) * { * KAboutData *about = new KAboutData( * , i18n( "..." ), * KDE_VERSION_STRING, QString(), KAboutLicense::GPL, * i18n( "Copyright 2006 ..." ) ); * about->addAuthor( i18n(...) ); * setAboutData( about ); * . * . * . * } * \endcode * * If you want to make the KCModule available only conditionally (i.e. show in * the list of available modules only if some test succeeds) then you can use * Hidden in the .desktop file. An example: * \code * Hidden[$e]=$(if test -e /dev/js*; then echo "false"; else echo "true"; fi) * \endcode * The example executes the given code in a shell and uses the stdout output for * the Hidden value (so it's either Hidden=true or Hidden=false). * * See http://techbase.kde.org/Development/Tutorials/KCM_HowTo * for more detailed documentation. * * @author Matthias Hoelzer-Kluepfel */ class KCONFIGWIDGETS_EXPORT KCModule : public QWidget { Q_OBJECT public: /** * An enumeration type for the buttons used by this module. * You should only use Help, Default and Apply. The rest is obsolete. * NoAdditionalButton can be used when we do not want have other button that Ok Cancel * * @see KCModule::buttons @see KCModule::setButtons */ enum Button { NoAdditionalButton = 0, Help = 1, Default = 2, Apply = 4, Export = 8 }; Q_DECLARE_FLAGS(Buttons, Button) /** * Base class for all KControlModules. * * @note do not emit changed signals here, since they are not yet connected * to any slot. * @param aboutData becomes owned by the KCModule */ explicit KCModule(const KAboutData *aboutData, QWidget *parent = nullptr, const QVariantList &args = QVariantList()); /** * Base class for all KControlModules. * * @note do not emit changed signals here, since they are not yet connected * to any slot. */ explicit KCModule(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); /** * Destroys the module. */ ~KCModule(); /** * Return a quick-help text. * * This method is called when the module is docked. * The quick-help text should contain a short description of the module and * links to the module's help files. You can use QML formatting tags in the text. * * @note make sure the quick help text gets translated (use i18n()). */ virtual QString quickHelp() const; /** * This is generally only called for the KBugReport. * If you override you should have it return a pointer to a constant. * * * @returns the KAboutData for this module */ virtual const KAboutData *aboutData() const; /** * This sets the KAboutData returned by aboutData() * The about data is now owned by KCModule. */ void setAboutData(const KAboutData *about); /** * Indicate which buttons will be used. * * The return value is a value or'ed together from * the Button enumeration type. * * @see KCModule::setButtons */ Buttons buttons() const; /** * Get the RootOnly message for this module. * * When the module must be run as root, or acts differently * for root and a normal user, it is sometimes useful to * customize the message that appears at the top of the module * when used as a normal user. This function returns this * customized message. If none has been set, a default message * will be used. * * @see KCModule::setRootOnlyMessage */ QString rootOnlyMessage() const; /** * Tell if KControl should show a RootOnly message when run as * a normal user. * * In some cases, the module don't want a RootOnly message to * appear (for example if it has already one). This function * tells KControl if a RootOnly message should be shown * * @see KCModule::setUseRootOnlyMessage */ bool useRootOnlyMessage() const; KAboutData componentData() const; /** * @return a list of @ref KConfigDialogManager's in use, if any. */ QList configs() const; /** * @brief Set if the module's save() method requires authorization to be executed. * * The module can set this property to @c true if it requires authorization. * It will still have to execute the action itself using the KAuth library, so * this method is not technically needed to perform the action, but * using this and/or the setAuthAction() method will ensure that hosting * applications like System Settings or kcmshell behave correctly. * * Called with @c true, this method will set the action to "org.kde.kcontrol.name.save" where * "name" is aboutData()->appName() return value. This default action won't be set if * the aboutData() object is not valid. * * Note that called with @c false, this method will reset the action name set with setAuthAction(). * * @param needsAuth Tells if the module's save() method requires authorization to be executed. */ void setNeedsAuthorization(bool needsAuth); /** * Returns the value previously set with setNeedsAuthorization() or setAuthAction(). By default it's @c false. * * @return @c true if the module's save() method requires authorization, @c false otherwise */ bool needsAuthorization() const; /** * @brief Set if the module's save() method requires authorization to be executed * * It will still have to execute the action itself using the KAuth library, so * this method is not technically needed to perform the action, but * using this method will ensure that hosting * applications like System Settings or kcmshell behave correctly. * * @param action the action that will be used by this KCModule */ void setAuthAction(const KAuth::Action &action); /** * Returns the action previously set with setAuthAction(). By default its an invalid action. * * @return The action that has to be authorized to execute the save() method. */ KAuth::Action authAction() const; /** * Returns the value set by setExportText(); * @deprecated since 5.0, obsolete feature */ KCONFIGWIDGETS_DEPRECATED QString exportText() const; /** * Sets the export QString value, used for exporting data. * @deprecated since 5.0, obsolete feature */ KCONFIGWIDGETS_DEPRECATED void setExportText(const QString &); public Q_SLOTS: /** * Load the configuration data into the module. * * The load method sets the user interface elements of the * module to reflect the current settings stored in the * configuration files. * * This method is invoked whenever the module should read its configuration * (most of the times from a config file) and update the user interface. * This happens when the user clicks the "Reset" button in the control * center, to undo all of his changes and restore the currently valid * settings. It is also called right after construction. */ virtual void load(); /** * Save the configuration data. * * The save method stores the config information as shown * in the user interface in the config files. * * If necessary, this method also updates the running system, * e.g. by restarting applications. This normally does not apply for * KSettings::Dialog modules where the updating is taken care of by * KSettings::Dispatcher. * * save is called when the user clicks "Apply" or "Ok". * * If you use KConfigXT, saving is taken care off automatically and * you do not need to load manually. However, if you for some reason reimplement it and * also are using KConfigXT, you must call this function, otherwise the saving of KConfigXT * options will not work. Call it at the very end of your reimplementation, to avoid * changed() signals getting emitted when you modify widgets. */ virtual void save(); /** * Sets the configuration to sensible default values. * * This method is called when the user clicks the "Default" * button. It should set the display to useful values. * * If you use KConfigXT, you do not have to reimplement this function since * the fetching and settings of default values is done automatically. However, if you * reimplement and also are using KConfigXT, remember to call the base function at the * very end of your reimplementation. */ virtual void defaults(); protected: /** * Adds a KCoreConfigskeleton @p config to watch the widget @p widget * * This function is useful if you need to handle multiple configuration files. * * @return a pointer to the KCoreConfigDialogManager in use * @param config the KCoreConfigSkeleton to use * @param widget the widget to watch */ KConfigDialogManager *addConfig(KCoreConfigSkeleton *config, QWidget *widget); /** * Adds a KConfigskeleton @p config to watch the widget @p widget * * This function is useful if you need to handle multiple configuration files. * * @return a pointer to the KConfigDialogManager in use * @param config the KConfigSkeleton to use * @param widget the widget to watch */ KConfigDialogManager *addConfig(KConfigSkeleton *config, QWidget *widget); /** * Sets the quick help. */ void setQuickHelp(const QString &help); void showEvent(QShowEvent *ev) Q_DECL_OVERRIDE; friend class KCModuleProxy; Q_SIGNALS: /** * Indicate that the state of the modules contents has changed. * * This signal is emitted whenever the state of the configuration * shown in the module changes. It allows the module container to * keep track of unsaved changes. */ void changed(bool state); /** * Indicate that the module's quickhelp has changed. * * Emit this signal whenever the module's quickhelp changes. * Modules implemented as tabbed dialogs might want to implement * per-tab quickhelp for example. * */ void quickHelpChanged(); /** * Indicate that the module's root message has changed. * * Emits this signal whenever the module's root message changes. * * @since 4.4 * */ void rootOnlyMessageChanged(bool use, QString message); protected Q_SLOTS: /** * Calling this slot is equivalent to emitting changed(true). */ void changed(); /** * A managed widget was changed, the widget settings and the current * settings are compared and a corresponding changed() signal is emitted */ void widgetChanged(); /** * The status of the auth action, if one, has changed */ void authStatusChanged(KAuth::Action::AuthStatus status); protected: /** * Sets the buttons to display. * * Help: shows a "Help" button. * * Default: shows a "Use Defaults" button. * * Apply: in kcontrol this will show an "Apply" and "Reset" button, * in kcmshell this will show an "Ok", "Apply" and "Cancel" button. * * If Apply is not specified, kcmshell will show a "Close" button. * * @see KCModule::buttons */ void setButtons(Buttons btn); /** * Sets the RootOnly message. * * This message will be shown at the top of the module if useRootOnlyMessage is * set. If no message is set, a default one will be used. * * @see KCModule::rootOnlyMessage */ void setRootOnlyMessage(const QString &message); /** * Change whether or not the RootOnly message should be shown. * * Following the value of @p on, the RootOnly message will be * shown or not. * * @see KCModule::useRootOnlyMessage */ void setUseRootOnlyMessage(bool on); /** * Returns the changed state of automatically managed widgets in this dialog */ bool managedWidgetChangeState() const; /** * Call this method when your manually managed widgets change state between * changed and not changed */ void unmanagedWidgetChangeState(bool); private: KCModulePrivate *const d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(KCModule::Buttons) #endif //KCMODULE_H diff --git a/src/kcodecaction.h b/src/kcodecaction.h index a36973a..d346600 100644 --- a/src/kcodecaction.h +++ b/src/kcodecaction.h @@ -1,116 +1,118 @@ /* kcodecaction.h Copyright (c) 2003 Jason Keirstead Copyright (c) 2003-2006 Michel Hermier Copyright (c) 2007 Nick Shaforostoff ******************************************************************** * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, * * Fifth Floor, Boston, MA 02110-1301 USA * * * ******************************************************************** */ #ifndef KCODECACTION_H #define KCODECACTION_H #include #include #include /** + * @class KCodecAction kcodecaction.h KCodecAction + * * @short Action for selecting one of several QTextCodec. * * This action shows up a submenu with a list of the available codecs on the system. */ class KCONFIGWIDGETS_EXPORT KCodecAction : public KSelectAction { Q_OBJECT Q_PROPERTY(QString codecName READ currentCodecName WRITE setCurrentCodec) Q_PROPERTY(int codecMib READ currentCodecMib) public: explicit KCodecAction(QObject *parent, bool showAutoOptions = false); KCodecAction(const QString &text, QObject *parent, bool showAutoOptions = false); KCodecAction(const QIcon &icon, const QString &text, QObject *parent, bool showAutoOptions = false); virtual ~KCodecAction(); public: int mibForName(const QString &codecName, bool *ok = nullptr) const; QTextCodec *codecForMib(int mib) const; QTextCodec *currentCodec() const; bool setCurrentCodec(QTextCodec *codec); QString currentCodecName() const; bool setCurrentCodec(const QString &codecName); int currentCodecMib() const; bool setCurrentCodec(int mib); /** * Applicable only if showAutoOptions in c'tor was true * * @returns KEncodingProber::None if specific encoding is selected, not autodetection, otherwise... you know it! */ KEncodingProber::ProberType currentProberType() const; /** * Applicable only if showAutoOptions in c'tor was true * * KEncodingProber::Universal means 'Default' item */ bool setCurrentProberType(KEncodingProber::ProberType); Q_SIGNALS: /** * Specific (proper) codec was selected * * Note that triggered(const QString&) is emitted too (as defined in KSelectAction) */ void triggered(QTextCodec *codec); /** * Autodetection has been selected. * emits KEncodingProber::Universal if Default was selected. * * Applicable only if showAutoOptions in c'tor was true */ void triggered(KEncodingProber::ProberType); /** * If showAutoOptions==true, then better handle triggered(KEncodingProber::ProberType) signal */ void defaultItemTriggered(); protected Q_SLOTS: void actionTriggered(QAction *) Q_DECL_OVERRIDE; protected: using KSelectAction::triggered; private: class Private; Private *const d; Q_PRIVATE_SLOT(d, void _k_subActionTriggered(QAction *)) }; #endif diff --git a/src/kcolorscheme.h b/src/kcolorscheme.h index fe636d5..8a46024 100644 --- a/src/kcolorscheme.h +++ b/src/kcolorscheme.h @@ -1,578 +1,580 @@ /* This file is part of the KDE project * Copyright (C) 2007 Matthew Woehlke * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KCOLORSCHEME_H #define KCOLORSCHEME_H #include #include #include #include class QColor; class QBrush; class KColorSchemePrivate; /** + * @class KColorScheme kcolorscheme.h KColorScheme + * * A set of methods used to work with colors. * * KColorScheme currently provides access to the system color palette that the * user has selected (in the future, it is expected to do more). It greatly * expands on QPalette by providing five distinct "sets" with several color * choices each, covering background, foreground, and decoration colors. * * A KColorScheme instance represents colors corresponding to a "set", where a * set consists of those colors used to draw a particular type of element, such * as a menu, button, view, selected text, or tooltip. Each set has a distinct * set of colors, so you should always use the correct set for drawing and * never assume that a particular foreground for one set is the same as the * foreground for any other set. Individual colors may be quickly referenced by * creating an anonymous instance and invoking a lookup member. * * @note * The color palettes for the various states of a widget (active, inactive, * disabled) may be wildly different. Therefore, it is important to take the * state into account. This is why the KColorScheme constructor requires a * QPalette::ColorGroup as an argument. * * To facilitate working with potentially-varying states, two convenience API's * are provided. These are KColorScheme::adjustBackground and its sister * KColorScheme::adjustForeground, and the helper class ::KStatefulBrush. * * @see KColorScheme::ColorSet, KColorScheme::ForegroundRole, * KColorScheme::BackgroundRole, KColorScheme::DecorationRole, * KColorScheme::ShadeRole */ class KCONFIGWIDGETS_EXPORT KColorScheme { public: /** * This enumeration describes the color set for which a color is being * selected. * * Color sets define a color "environment", suitable for drawing all parts * of a given region. Colors from different sets should not be combined. */ enum ColorSet { /** * Views; for example, frames, input fields, etc. * * If it contains things that can be selected, it is probably a View. */ View, /** * Non-editable window elements; for example, menus. * * If it isn't a Button, View, or Tooltip, it is probably a Window. */ Window, /** * Buttons and button-like controls. * * In addition to buttons, "button-like" controls such as non-editable * dropdowns, scrollbar sliders, slider handles, etc. should also use * this role. */ Button, /** * Selected items in views. * * Note that unfocused or disabled selections should use the Window * role. This makes it more obvious to the user that the view * containing the selection does not have input focus. */ Selection, /** * Tooltips. * * The tooltip set can often be substituted for the view * set when editing is not possible, but the Window set is deemed * inappropriate. "What's This" help is an excellent example, another * might be pop-up notifications (depending on taste). */ Tooltip, /** * Complementary areas. * * Some applications want some areas to have a different color scheme. * Ususally dark areas over a light theme. For instance the fullscreen UI * of a picture viewer, or the logout/lock screen of the plasma workspace * ask for a dark color scheme even on light themes. * @since 5.19 */ Complementary }; /** * This enumeration describes the background color being selected from the * given set. * * Background colors are suitable for drawing under text, and should never * be used to draw text. In combination with one of the overloads of * KColorScheme::shade, they may be used to generate colors for drawing * frames, bevels, and similar decorations. */ enum BackgroundRole { /** * Normal background. */ NormalBackground = 0, /** * Alternate background; for example, for use in lists. * * This color may be the same as BackgroundNormal, especially in sets * other than View and Window. */ AlternateBackground = 1, /** * Third color; for example, items which are new, active, requesting * attention, etc. * * Alerting the user that a certain field must be filled out would be a * good usage (although NegativeBackground could be used to the same * effect, depending on what you are trying to achieve). Unlike * ActiveText, this should not be used for mouseover effects. */ ActiveBackground = 2, /** * Fourth color; corresponds to (unvisited) links. * * Exactly what this might be used for is somewhat harder to qualify; * it might be used for bookmarks, as a 'you can click here' indicator, * or to highlight recent content (i.e. in a most-recently-accessed * list). */ LinkBackground = 3, /** * Fifth color; corresponds to visited links. * * This can also be used to indicate "not recent" content, especially * when a color is needed to denote content which is "old" or * "archival". */ VisitedBackground = 4, /** * Sixth color; for example, errors, untrusted content, etc. */ NegativeBackground = 5, /** * Seventh color; for example, warnings, secure/encrypted content. */ NeutralBackground = 6, /** * Eigth color; for example, success messages, trusted content. */ PositiveBackground = 7 }; /** * This enumeration describes the foreground color being selected from the * given set. * * Foreground colors are suitable for drawing text or glyphs (such as the * symbols on window decoration buttons, assuming a suitable background * brush is used), and should never be used to draw backgrounds. * * For window decorations, the following is suggested, but not set in * stone: * @li Maximize - PositiveText * @li Minimize - NeutralText * @li Close - NegativeText * @li WhatsThis - LinkText * @li Sticky - ActiveText */ enum ForegroundRole { /** * Normal foreground. */ NormalText = 0, /** * Second color; for example, comments, items which are old, inactive * or disabled. Generally used for things that are meant to be "less * important". InactiveText is not the same role as NormalText in the * inactive state. */ InactiveText = 1, /** * Third color; for example items which are new, active, requesting * attention, etc. May be used as a hover color for clickable items. */ ActiveText = 2, /** * Fourth color; use for (unvisited) links. May also be used for other * clickable items or content that indicates relationships, items that * indicate somewhere the user can visit, etc. */ LinkText = 3, /** * Fifth color; used for (visited) links. As with LinkText, may be used * for items that have already been "visited" or accessed. May also be * used to indicate "historical" (i.e. "old") items or information, * especially if InactiveText is being used in the same context to * express something different. */ VisitedText = 4, /** * Sixth color; for example, errors, untrusted content, deletions, * etc. */ NegativeText = 5, /** * Seventh color; for example, warnings, secure/encrypted content. */ NeutralText = 6, /** * Eigth color; for example, additions, success messages, trusted * content. */ PositiveText = 7 }; /** * This enumeration describes the decoration color being selected from the * given set. * * Decoration colors are used to draw decorations (such as frames) for * special purposes. Like color shades, they are neither foreground nor * background colors. Text should not be painted over a decoration color, * and decoration colors should not be used to draw text. */ enum DecorationRole { /** * Color used to draw decorations for items which have input focus. */ FocusColor, /** * Color used to draw decorations for items which will be activated by * clicking. */ HoverColor }; /** * This enumeration describes the color shade being selected from the given * set. * * Color shades are used to draw "3d" elements, such as frames and bevels. * They are neither foreground nor background colors. Text should not be * painted over a shade, and shades should not be used to draw text. */ enum ShadeRole { /** * The light color is lighter than dark() or shadow() and contrasts * with the base color. */ LightShade, /** * The midlight color is in between base() and light(). */ MidlightShade, /** * The mid color is in between base() and dark(). */ MidShade, /** * The dark color is in between mid() and shadow(). */ DarkShade, /** * The shadow color is darker than light() or midlight() and contrasts * the base color. */ ShadowShade }; /** Construct a copy of another KColorScheme. */ KColorScheme(const KColorScheme &); /** Destructor */ virtual ~KColorScheme(); /** Standard assignment operator */ KColorScheme &operator=(const KColorScheme &); /** * Construct a palette from given color set and state. Colors are taken * from the given KConfig. If null, the application's color scheme is used * (either the system default or one set by KColorSchemeManager). * * @note KColorScheme provides direct access to the color scheme for users * that deal directly with widget states. Unless you are a low-level user * or have a legitimate reason to only care about a fixed, limited number * of states (e.g. windows that cannot be inactive), consider using a * ::KStatefulBrush instead. */ explicit KColorScheme(QPalette::ColorGroup, ColorSet = View, KSharedConfigPtr = KSharedConfigPtr()); /** * Retrieve the requested background brush. */ QBrush background(BackgroundRole = NormalBackground) const; /** * Retrieve the requested foreground brush. */ QBrush foreground(ForegroundRole = NormalText) const; /** * Retrieve the requested decoration brush. */ QBrush decoration(DecorationRole) const; /** * Retrieve the requested shade color, using * KColorScheme::background(KColorScheme::NormalBackground) * as the base color and the contrast setting from the KConfig used to * create this KColorScheme instance. * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). */ QColor shade(ShadeRole) const; /** * Returns the contrast for borders. * @return the contrast (between 0 for minimum and 10 for maximum * contrast) */ static int contrast(); /** * Returns the contrast for borders as a floating point value. * @param config pointer to the config from which to read the contrast * setting. If null, the application's color scheme will be used * (either the system default or one set by KColorSchemeManager). * @return the contrast (between 0.0 for minimum and 1.0 for maximum * contrast) */ static qreal contrastF(const KSharedConfigPtr &config = KSharedConfigPtr()); /** * Retrieve the requested shade color, using the specified color as the * base color and the application's contrast setting. * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). */ static QColor shade(const QColor &, ShadeRole); /** * Retrieve the requested shade color, using the specified color as the * base color and the specified contrast. * * @param contrast Amount roughly specifying the contrast by which to * adjust the base color, between -1.0 and 1.0 (values between 0.0 and 1.0 * correspond to the value from KColorScheme::contrastF) * @param chromaAdjust (optional) Amount by which to adjust the chroma of * the shade (1.0 means no adjustment) * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). * * @see KColorUtils::shade */ static QColor shade(const QColor &, ShadeRole, qreal contrast, qreal chromaAdjust = 0.0); /** * Adjust a QPalette by replacing the specified QPalette::ColorRole with * the requested background color for all states. Using this method is * safer than replacing individual states, as it insulates you against * changes in QPalette::ColorGroup. * * @note Although it is possible to replace a foreground color using this * method, it's bad usability to do so. Just say "no". */ static void adjustBackground(QPalette &, BackgroundRole newRole = NormalBackground, QPalette::ColorRole color = QPalette::Base, ColorSet set = View, KSharedConfigPtr = KSharedConfigPtr()); /** * Adjust a QPalette by replacing the specified QPalette::ColorRole with * the requested foreground color for all states. Using this method is * safer than replacing individual states, as it insulates you against * changes in QPalette::ColorGroup. * * @note Although it is possible to replace a background color using this * method, it's bad usability to do so. Just say "no". */ static void adjustForeground(QPalette &, ForegroundRole newRole = NormalText, QPalette::ColorRole color = QPalette::Text, ColorSet set = View, KSharedConfigPtr = KSharedConfigPtr()); /** * Used to obtain the QPalette that will be used to set the application * palette from KDE Platform theme. * * @param config KConfig from which to load the colors * * @returns the QPalette * * @since 5.0 */ static QPalette createApplicationPalette(const KSharedConfigPtr &config); private: QExplicitlySharedDataPointer d; }; /** * A container for a "state-aware" brush. * * KStatefulBrush provides an easy and safe way to store a color for use in a * user interface. It is "safe" both in that it will make it easy to deal with * widget states in a correct manner, and that it insulates you against changes * in QPalette::ColorGroup. * * Basically, a stateful brush is used to cache a particular "color" from the * KDE system palette (usually, one which does not live in QPalette). When you * are ready to draw using the brush, you use the current state to retrieve the * appropriate brush. * * Stateful brushes can also be used to apply state effects to arbitrary * brushes, for example when working with a application specific user-defined * color palette. * * @note As of Qt 4.3, QPalette::ColorGroup is missing a state for disabled * widgets in an inactive window. Hopefully Trolltech will fix this bug, at * which point KColorScheme and KStatefulBrush will be updated to recognize the * new state. Using KStatefulBrush will allow your application to inherit these * changes "for free", without even recompiling. */ class KCONFIGWIDGETS_EXPORT KStatefulBrush { public: /** * Construct a "default" stateful brush. For such an instance, all * overloads of KStatefulBrush::brush will return a default brush (i.e. * QBrush()). */ explicit KStatefulBrush(); /** * Construct a stateful brush from given color set and foreground role, * using the colors from the given KConfig. * If null, the application's color scheme is used (either the system * default, or one set by KColorSchemeManager). */ explicit KStatefulBrush(KColorScheme::ColorSet, KColorScheme::ForegroundRole, KSharedConfigPtr = KSharedConfigPtr()); /** * Construct a stateful brush from given color set and background role, * using the colors from the given KConfig (if null, the application's * colors are used). */ explicit KStatefulBrush(KColorScheme::ColorSet, KColorScheme::BackgroundRole, KSharedConfigPtr = KSharedConfigPtr()); /** * Construct a stateful brush from given color set and decoration role, * using the colors from the given KConfig (if null, the application's * colors are used). */ explicit KStatefulBrush(KColorScheme::ColorSet, KColorScheme::DecorationRole, KSharedConfigPtr = KSharedConfigPtr()); /** * Construct a stateful background brush from a specified QBrush (or * QColor, via QBrush's implicit constructor). The various states are * determined from the base QBrush (which fills in the Active state) * according to the same rules used to build stateful color schemes from * the system color scheme. The state effects from the given KConfig are * used (if null, the application's state effects are used). */ explicit KStatefulBrush(const QBrush &, KSharedConfigPtr = KSharedConfigPtr()); /** * Construct a stateful foreground/decoration brush from a specified * QBrush (or QColor, via QBrush's implicit constructor). The various * states are determined from the base QBrush (which fills in the Active * state) according to the same rules used to build stateful color schemes * from the system color scheme. The state effects from the given KConfig * are used (if null, the application's state effects are used). * * @param background The background brush (or color) corresponding to the * KColorScheme::NormalBackground role and QPalette::Active state for this * foreground/decoration color. */ explicit KStatefulBrush(const QBrush &, const QBrush &background, KSharedConfigPtr = KSharedConfigPtr()); /** Construct a copy of another KStatefulBrush. */ KStatefulBrush(const KStatefulBrush &); /** Destructor */ ~KStatefulBrush(); /** Standard assignment operator */ KStatefulBrush &operator=(const KStatefulBrush &); /** * Retrieve the brush for the specified widget state. This is used when you * know explicitly what state is wanted. Otherwise one of overloads is * often more convenient. */ QBrush brush(QPalette::ColorGroup) const; /** * Retrieve the brush, using a QPalette reference to determine the correct * state. Use when your painting code has easy access to the QPalette that * it is supposed to be using. The state used in this instance is the * currentColorGroup of the palette. */ QBrush brush(const QPalette &) const; /** * Retrieve the brush, using a QWidget pointer to determine the correct * state. Use when you have a pointer to the widget that you are painting. * The state used is the current state of the widget. * * @note If you pass an invalid widget, you will get a default brush (i.e. * QBrush()). */ QBrush brush(const QWidget *) const; private: class KStatefulBrushPrivate *d; }; Q_DECLARE_METATYPE(KStatefulBrush) /* so we can pass it in QVariant's */ #endif // KCOLORSCHEME_H diff --git a/src/kcolorschememanager.h b/src/kcolorschememanager.h index 2f434c2..35d245d 100644 --- a/src/kcolorschememanager.h +++ b/src/kcolorschememanager.h @@ -1,123 +1,125 @@ /* This file is part of the KDE project * Copyright (C) 2013 Martin Gräßlin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KCOLORSCHEMEMANAGER_H #define KCOLORSCHEMEMANAGER_H #include #include class QAbstractItemModel; class QModelIndex; class QIcon; class KActionMenu; class KColorSchemeManagerPrivate; /** + * @class KColorSchemeManager kcolorschememanager.h KColorSchemeManager + * * A small helper to get access to all available color schemes and activating a scheme in the * QApplication. This is useful for applications which want to provide a selection of custom color * schemes to their user. For example it is very common for photo and painting applications to use * a dark color scheme even if the default is a light scheme. * * The KColorSchemeManager provides access to a QAbstractItemModel which holds all the available * schemes. A possible usage looks like the following: * * @code * KColorSchemeManager *schemes = new KColorSchemeManager(this); * QListView *view = new QListView(this); * view->setModel(schemes->model()); * connect(view, &QListView::activated, schemes, &KColorSchemeManager::activateScheme); * @endcode * * In addition the KColorSchemeManager also provides the possibility to create a KActionMenu populated * with all the available color schemes in an action group. If one of the actions is selected the * scheme is applied instantly: * * @code * QToolButton *button = new QToolButton(); * KColorSchemeManager *schemes = new KColorSchemeManager(this); * KActionMenu *menu = schemes->createSchemeSelectionMenu(QStringLiteral("Oxygen"), button); * button->setMenu(menu->menu()); * @endcode * * @since 5.0 */ class KCONFIGWIDGETS_EXPORT KColorSchemeManager : public QObject { Q_OBJECT public: explicit KColorSchemeManager(QObject *parent = nullptr); virtual ~KColorSchemeManager(); /** * A QAbstractItemModel of all available color schemes. * * The model provides the name of the scheme in Qt::DisplayRole, a preview * in Qt::DelegateRole and the full path to the scheme file in Qt::UserRole. * * @return Model of all available color schemes. */ QAbstractItemModel *model() const; /** * Returns the model index for the scheme with the given @p name. If no such * scheme exists an invalid index is returned. * @see model */ QModelIndex indexForScheme(const QString &name) const; /** * Creates a KActionMenu populated with all the available color schemes. * All actions are in an action group and when one of the actions is triggered the scheme * referenced by this action is activated. * * The color scheme with the same name as @p selectedSchemeName will be checked. If none * of the available color schemes has the same name, no action will be checked. * * The KActionMenu will not be updated in case the installed color schemes change. It's the * task of the user of the KActionMenu to monitor for changes if required. * * @param icon The icon to use for the KActionMenu * @param text The text to use for the KActionMenu * @param selectedSchemeName The name of the color scheme to select * @param parent The parent of the KActionMenu * @return KActionMenu populated with all available color schemes. * @see activateScheme */ KActionMenu *createSchemeSelectionMenu(const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent); KActionMenu *createSchemeSelectionMenu(const QString &text, const QString &selectedSchemeName, QObject *parent); KActionMenu *createSchemeSelectionMenu(const QString &selectedSchemeName, QObject *parent); public Q_SLOTS: /** * @brief Activates the KColorScheme identified by the provided @p index. * * Installs the KColorScheme as the QApplication's QPalette. * * @param index The index for the KColorScheme to activate. * The index must reference the QAbstractItemModel provided by @link model * @see model() */ void activateScheme(const QModelIndex &index); private: QScopedPointer d; }; #endif diff --git a/src/kconfigdialog.h b/src/kconfigdialog.h index 2a3958e..cfe4a59 100644 --- a/src/kconfigdialog.h +++ b/src/kconfigdialog.h @@ -1,275 +1,277 @@ /* * This file is part of the KDE libraries * Copyright (C) 2003 Benjamin C Meyer (ben+kdelibs at meyerhome dot net) * Copyright (C) 2003 Waldo Bastian * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KCONFIGDIALOG_H #define KCONFIGDIALOG_H #include #include "kconfigwidgets_export.h" class KConfig; class KCoreConfigSkeleton; class KConfigDialogManager; /** + * @class KConfigDialog kconfigdialog.h KConfigDialog + * * \short Standard %KDE configuration dialog class * * The KConfigDialog class provides an easy and uniform means of displaying * a settings dialog using KPageDialog, KConfigDialogManager and a * KConfigSkeleton derived settings class. * * KConfigDialog handles the enabling and disabling of buttons, creation * of the dialog, and deletion of the widgets. Because of * KConfigDialogManager, this class also manages: restoring * the settings, reseting them to the default values, and saving them. This * requires that the names of the widgets corresponding to configuration entries * have to have the same name plus an additional "kcfg_" prefix. For example the * widget named "kcfg_MyOption" would be associated with the configuration entry * "MyOption". * * Here is an example usage of KConfigDialog: * * \code * void KCoolApp::showSettings(){ * if(KConfigDialog::showDialog("settings")) * return; * KConfigDialog *dialog = new KConfigDialog(this, "settings", MySettings::self()); * dialog->setFaceType(KPageDialog::List); * dialog->addPage(new General(0, "General"), i18n("General") ); * dialog->addPage(new Appearance(0, "Style"), i18n("Appearance") ); * connect(dialog, SIGNAL(settingsChanged(const QString&)), mainWidget, SLOT(loadSettings())); * connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(loadSettings())); * dialog->show(); * } * \endcode * * Other than the above code, each class that has settings in the dialog should * have a loadSettings() type slot to read settings and perform any * necessary changes. * * For dialog appearance options (like buttons, default button, ...) please see * @see KPageDialog * * @see KConfigSkeleton * @author Waldo Bastian */ class KCONFIGWIDGETS_EXPORT KConfigDialog : public KPageDialog { Q_OBJECT Q_SIGNALS: /** * A widget in the dialog was modified. */ void widgetModified(); /** * One or more of the settings have been permanently changed such as if * the user clicked on the Apply or Ok button. * @param dialogName the name of the dialog. */ void settingsChanged(const QString &dialogName); public: /** * @param parent - The parent of this object. Even though the class * deletes itself the parent should be set so the dialog can be centered * with the application on the screen. * * @param name - The name of this object. The name is used in determining if * there can be more than one dialog at a time. Use names such as: * "Font Settings" or "Color Settings" and not just "Settings" in * applications where there is more than one dialog. * * @param config - Config object containing settings. */ KConfigDialog(QWidget *parent, const QString &name, KCoreConfigSkeleton *config); /** * Deconstructor, removes name from the list of open dialogs. * Deletes private class. * @see exists() */ ~KConfigDialog(); /** * Adds page to the dialog and to KConfigDialogManager. When an * application is done adding pages show() should be called to * display the dialog. * @param page - Pointer to the page that is to be added to the dialog. * This object is reparented. * @param itemName - Name of the page. * @param pixmapName - Name of the icon that should be used, if needed, when * displaying the page. The string may either be the name of a themed * icon (e.g. "document-save"), which the internal icon loader will be * used to retrieve, or an absolute path to the pixmap on disk. * @param header - Header text use in the list modes. Ignored in Tabbed * mode. If empty, the itemName text is used when needed. * @param manage - Whether KConfigDialogManager should manage the page or not. * @returns The KPageWidgetItem associated with the page. */ KPageWidgetItem *addPage(QWidget *page, const QString &itemName, const QString &pixmapName = QString(), const QString &header = QString(), bool manage = true); /** * Adds page to the dialog that is managed by a custom KConfigDialogManager. * This is useful for dialogs that contain settings spread over more than * one configuration file and thus have/need more than one KConfigSkeleton. * When an application is done adding pages show() should be called to * display the dialog. * @param page - Pointer to the page that is to be added to the dialog. * This object is reparented. * @param config - Config object containing corresponding settings. * @param itemName - Name of the page. * @param pixmapName - Name of the icon that should be used, if needed, when * displaying the page. The string may either be the name of a themed * icon (e.g. "document-save"), which the internal icon loader will be * used to retrieve, or an absolute path to the pixmap on disk. * @param header - Header text use in the list modes. Ignored in Tabbed * mode. If empty, the itemName text is used when needed. * @returns The KPageWidgetItem associated with the page. */ KPageWidgetItem *addPage(QWidget *page, KCoreConfigSkeleton *config, const QString &itemName, const QString &pixmapName = QString(), const QString &header = QString()); /** * See if a dialog with the name 'name' already exists. * @see showDialog() * @param name - Dialog name to look for. * @return Pointer to widget or NULL if it does not exist. */ static KConfigDialog *exists(const QString &name); /** * Attempts to show the dialog with the name 'name'. * @see exists() * @param name - The name of the dialog to show. * @return True if the dialog 'name' exists and was shown. */ static bool showDialog(const QString &name); protected Q_SLOTS: /** * Update the settings from the dialog. * Virtual function for custom additions. * * Example use: User clicks Ok or Apply button in a configure dialog. */ virtual void updateSettings(); /** * Update the dialog based on the settings. * Virtual function for custom additions. * * Example use: Initialisation of dialog. * Example use: User clicks Reset button in a configure dialog. */ virtual void updateWidgets(); /** * Update the dialog based on the default settings. * Virtual function for custom additions. * * Example use: User clicks Defaults button in a configure dialog. */ virtual void updateWidgetsDefault(); /** * Updates the Apply and Default buttons. * Connect to this slot if you implement your own hasChanged() * or isDefault() methods for widgets not managed by KConfig. * @since 4.3 */ void updateButtons(); /** * Some setting was changed. Emit the signal with the dialogs name. * Connect to this slot if there are widgets not managed by KConfig. * @since 4.3 */ void settingsChangedSlot(); /** * Sets the help path and topic. * * The HTML file will be found using the X-DocPath entry in the application's desktop file. * It can be either a relative path, or a website URL. * * @param anchor This has to be a defined anchor in your * docbook sources or website. If empty the main index * is loaded. * @param appname This allows you to specify the .desktop file to get the help path from. * If empty the QCoreApplication::applicationName() is used. */ void setHelp(const QString &anchor, const QString &appname = QString()); /** * Displays help for this config dialog. * @since 5.0 */ virtual void showHelp(); protected: /** * Returns whether the current state of the dialog is * different from the current configuration. * Virtual function for custom additions. */ virtual bool hasChanged(); /** * Returns whether the current state of the dialog is * the same as the default configuration. */ virtual bool isDefault(); /** * @internal */ void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; private Q_SLOTS: /** * Slot which cleans up the KConfigDialogManager of the page. * */ void onPageRemoved(KPageWidgetItem *item); private: class KConfigDialogPrivate; friend class KConfigDialogPrivate; KConfigDialogPrivate *const d; Q_PRIVATE_SLOT(d, void _k_updateButtons()) Q_PRIVATE_SLOT(d, void _k_settingsChangedSlot()) Q_DISABLE_COPY(KConfigDialog) }; #endif //KCONFIGDIALOG_H diff --git a/src/kconfigdialogmanager.h b/src/kconfigdialogmanager.h index 22e2106..620dcda 100644 --- a/src/kconfigdialogmanager.h +++ b/src/kconfigdialogmanager.h @@ -1,384 +1,386 @@ /* * This file is part of the KDE libraries * Copyright (C) 2003 Benjamin C Meyer (ben+kdelibs at meyerhome dot net) * Copyright (C) 2003 Waldo Bastian * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KCONFIGDIALOGMANAGER_H #define KCONFIGDIALOGMANAGER_H #include #include #include class KConfigDialogManagerPrivate; class KCoreConfigSkeleton; class KConfigSkeleton; class KConfigSkeletonItem; class QWidget; /** + * @class KConfigDialogManager kconfigdialogmanager.h KConfigDialogManager + * * @short Provides a means of automatically retrieving, * saving and resetting KConfigSkeleton based settings in a dialog. * * The KConfigDialogManager class provides a means of automatically * retrieving, saving and resetting basic settings. * It also can emit signals when settings have been changed * (settings were saved) or modified (the user changes a checkbox * from on to off). * * The object names of the widgets to be managed have to correspond to the names of the * configuration entries in the KConfigSkeleton object plus an additional * "kcfg_" prefix. For example a widget with the object name "kcfg_MyOption" * would be associated to the configuration entry "MyOption". * * The widget classes of Qt and KDE Frameworks are supported out of the box. * * Custom widget classes are supported if they have a Q_PROPERTY defined for the * property representing the value edited by the widget. By default the property * is used for which "USER true" is set. For using another property, see below. * * Example: * * A class ColorEditWidget is used in the settings UI to select a color. The * color value is set and read as type QColor. For that it has a definition of * the value property similar to this: * \code * Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged USER true) * \endcode * And of course it has the definition and implementation of the respective * read & write methods and the notify signal. * This class then can be used directly with KConfigDialogManager and does not need * further setup. For supporting also KDE Frameworks versions older than 5.32 see * below for how to register the property change signal. * * To use a widget's property that is not the USER property, the property to use * can be selected by setting onto the widget instance a property with the key * "kcfg_property" and as the value the name of the property: * \code * ColorEditWidget *myWidget = new ColorEditWidget; * myWidget->setProperty("kcfg_property", QByteArray("redColorPart")); * \endcode * This selection of the property to use is just valid for this widget instance. * When using a UI file, the "kcfg_property" property can also be set using Qt Designer. * * Alternatively a non-USER property can be defined for a widget class globally * by registering it for the class in the KConfigDialogManager::propertyMap(). * This global registration has lower priority than any "kcfg_property" property * set on a class instance though, so the latter overrules this global setting. * Note: setting the property in the propertyMap affects any instances of that * widget class in the current application, so use only when needed and prefer * instead the "kcfg_property" property. Especially with software with many * libraries and 3rd-party plugins in one process there is a chance of * conflicting settings. * * Example: * * If the ColorEditWidget has another property redColor defined by * \code * Q_PROPERTY(int redColorPart READ redColorPart WRITE setRedColorPart NOTIFY redColorPartChanged) * \endcode * and this one should be used in the settings, call somewhere in the code before * using the settings: * \code * KConfigDialogManager::propertyMap()->insert("ColorEditWidget", QByteArray("redColorPart")); * \endcode * * If some non-default signal should be used, e.g. because the property to use does not * have a NOTIFY setting, for a given widget instance the signal to use can be set * by a property with the key "kcfg_propertyNotify" and as the value the signal signature. * This will take priority over the signal noted by NOTIFY for the chosen property * as well as the content of KConfigDialogManager::changedMap(). Since 5.32. * * Example: * * If for a class OtherColorEditWidget there was no NOTIFY set on the USER property, * but some signal colorSelected(QColor) defined which would be good enough to reflect * the settings change, defined by * \code * Q_PROPERTY(QColor color READ color WRITE setColor USER true) * Q_SIGNALS: * void colorSelected(const QColor &color); * \endcode * the signal to use would be defined by this: * \code * OtherColorEditWidget *myWidget = new OtherColorEditWidget; * myWidget->setProperty("kcfg_propertyNotify", SIGNAL(colorSelected(QColor))); * \endcode * * Before version 5.32 of KDE Frameworks, the signal notifying about a change * of the property value in the widget had to be manually registered for any * custom widget, using KConfigDialogManager::changedMap(). The same also had * to be done for custom signals with widgets from Qt and KDE Frameworks. * So for code which needs to also work with older versions of the KDE Frameworks, * this still needs to be done. * Starting with version 5.32, where the new signal handling is effective, the * signal registered via KConfigDialogManager::changedMap() will take precedence over * the one read from the Q_PROPERTY declaration, but is overridden for a given * widget instance by the "kcfg_propertyNotify" property. * * Examples: * * For the class ColorEditWidget from the previous example this will register * the change signal as needed: * \code * KConfigDialogManager::changedMap()->insert("ColorEditWidget", SIGNAL(colorChanged(QColor))); * \endcode * For KDE Framework versions starting with 5.32 this will override then the signal * as read from the USER property, but as it is the same signal, nothing will break. * * If wants wants to reduce conflicts and also only add code to the build as needed, * one would add both a buildtime switch and a runtime switch like * \code * #include * #include * // [...] * #if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5,32,0) * if (KCoreAddons::version() < QT_VERSION_CHECK(5,32,0)) { * KConfigDialogManager::changedMap()->insert("ColorEditWidget", SIGNAL(colorChanged(QColor))); * } * #endif * \endcode * so support for the old variant would be only used when running against an older * KDE Frameworks, and this again only built in if also compiled against an older version. * Note: KCoreAddons::version() needs at least KDE Frameworks 5.20 though. * * For the class OtherColorEditWidget from the previous example for the support of * also older KDE Frameworks versions the change signal would be registered by this: * \code * KConfigDialogManager::changedMap()->insert("OtherColorEditWidget", SIGNAL(colorSelected(QColor))); * OtherColorEditWidget *myWidget = new OtherColorEditWidget; * myWidget->setProperty("kcfg_propertyNotify", SIGNAL(colorSelected(QColor))); * \endcode * Here for KDE Framework versions before 5.32 the "kcfg_propertyNotify" property would * be ignored and the signal taken from KConfigDialogManager::changedMap(), while * for newer versions it is taken from that property, which then overrides the latter. * But as it is the same signal, nothing will break. * * Again, using KConfigDialogManager::changedMap could be made to depend on the version, * so for newer versions any global conflicts are avoided: * \code * #include * #include * // [...] * #if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5,32,0) * if (KCoreAddons::version() < QT_VERSION_CHECK(5,32,0)) { * KConfigDialogManager::changedMap()->insert("OtherColorEditWidget", SIGNAL(colorSelected(QColor))); * } * #endif * OtherColorEditWidget *myWidget = new OtherColorEditWidget; * myWidget->setProperty("kcfg_propertyNotify", SIGNAL(colorSelected(QColor))); * \endcode * * @author Benjamin C Meyer * @author Waldo Bastian */ class KCONFIGWIDGETS_EXPORT KConfigDialogManager : public QObject { Q_OBJECT Q_SIGNALS: /** * One or more of the settings have been saved (such as when the user * clicks on the Apply button). This is only emitted by updateSettings() * whenever one or more setting were changed and consequently saved. */ void settingsChanged(); /** * TODO: Verify * One or more of the settings have been changed. * @param widget - The widget group (pass in via addWidget()) that * contains the one or more modified setting. * @see settingsChanged() */ void settingsChanged(QWidget *widget); /** * If retrieveSettings() was told to track changes then if * any known setting was changed this signal will be emitted. Note * that a settings can be modified several times and might go back to the * original saved state. hasChanged() will tell you if anything has * actually changed from the saved values. */ void widgetModified(); public: /** * Constructor. * @param parent Dialog widget to manage * @param conf Object that contains settings */ KConfigDialogManager(QWidget *parent, KCoreConfigSkeleton *conf); /** * Constructor. * @param parent Dialog widget to manage * @param conf Object that contains settings */ KConfigDialogManager(QWidget *parent, KConfigSkeleton *conf); /** * Destructor. */ ~KConfigDialogManager(); /** * Add additional widgets to manage * @param widget Additional widget to manage, inlcuding all its children */ void addWidget(QWidget *widget); /** * Returns whether the current state of the known widgets are * different from the state in the config object. */ bool hasChanged() const; /** * Returns whether the current state of the known widgets are * the same as the default state in the config object. */ bool isDefault() const; /** * Retrieve the map between widgets class names and the * USER properties used for the configuration values. */ static QHash *propertyMap(); /** * Retrieve the map between widgets class names and signals that are listened * to detect changes in the configuration values. * @deprecated For code having KDE Frameworks 5.32 as minimal required version, * rely on the change signal noted with NOTIFY in the definition of the * used property instead of setting it in this map. Or set the * "kcfg_propertyNotify" property on the widget instance. */ static QHash *changedMap(); public Q_SLOTS: /** * Traverse the specified widgets, saving the settings of all known * widgets in the settings object. * * Example use: User clicks Ok or Apply button in a configure dialog. */ void updateSettings(); /** * Traverse the specified widgets, sets the state of all known * widgets according to the state in the settings object. * * Example use: Initialisation of dialog. * Example use: User clicks Reset button in a configure dialog. */ void updateWidgets(); /** * Traverse the specified widgets, sets the state of all known * widgets according to the default state in the settings object. * * Example use: User clicks Defaults button in a configure dialog. */ void updateWidgetsDefault(); protected: /** * @param trackChanges - If any changes by the widgets should be tracked * set true. This causes the emitting the modified() signal when * something changes. * TODO: @return bool - True if any setting was changed from the default. */ void init(bool trackChanges); /** * Recursive function that finds all known children. * Goes through the children of widget and if any are known and not being * ignored, stores them in currentGroup. Also checks if the widget * should be disabled because it is set immutable. * @param widget - Parent of the children to look at. * @param trackChanges - If true then tracks any changes to the children of * widget that are known. * @return bool - If a widget was set to something other than its default. */ bool parseChildren(const QWidget *widget, bool trackChanges); /** * Finds the USER property name using Qt's MetaProperty system, and caches * it in the property map (the cache could be retrieved by propertyMap() ). */ QByteArray getUserProperty(const QWidget *widget) const; /** * Find the property to use for a widget by querying the "kcfg_property" * property of the widget. Like a widget can use a property other than the * USER property. * @since 4.3 */ QByteArray getCustomProperty(const QWidget *widget) const; /** * Finds the changed signal of the USER property using Qt's MetaProperty system. * @since 5.32 */ QByteArray getUserPropertyChangedSignal(const QWidget *widget) const; /** * Find the changed signal of the property to use for a widget by querying * the "kcfg_propertyNotify" property of the widget. Like a widget can use a * property change signal other than the one for USER property, if there even is one. * @since 5.32 */ QByteArray getCustomPropertyChangedSignal(const QWidget *widget) const; /** * Set a property */ void setProperty(QWidget *w, const QVariant &v); /** * Retrieve a property */ QVariant property(QWidget *w) const; /** * Setup secondary widget properties */ void setupWidget(QWidget *widget, KConfigSkeletonItem *item); /** * Initializes the property maps */ static void initMaps(); private: /** * KConfigDialogManager KConfigDialogManagerPrivate class. */ KConfigDialogManagerPrivate *const d; Q_DISABLE_COPY(KConfigDialogManager) }; #endif // KCONFIGDIALOGMANAGER_H diff --git a/src/klanguagebutton.h b/src/klanguagebutton.h index fa5566f..c5f2408 100644 --- a/src/klanguagebutton.h +++ b/src/klanguagebutton.h @@ -1,175 +1,177 @@ /* * klangbutton.h - Button with language selection drop down menu. * Derived from the KLangCombo class by Hans Petter Bieker. * * Copyright (c) 1999-2003 Hans Petter Bieker * (c) 2001 Martijn Klingens * (c) 2007 David Jarvie * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KLANGUAGEBUTTON_H #define KLANGUAGEBUTTON_H #include "kconfigwidgets_export.h" #include class QAction; class KLanguageButtonPrivate; /** + * @class KLanguageButton klanguagebutton.h KLanguageButton + * * KLanguageButton is a pushbutton which allows a language to be selected from * a popup list. * * Languages are identified by their ISO 639-1 codes, e.g. en, pt_BR. * * \image html klanguagebutton.png "KDE Language Selection Widget" * * @author Hans Petter Bieker , Martijn Klingens , * David Jarvie */ class KCONFIGWIDGETS_EXPORT KLanguageButton : public QWidget { Q_OBJECT public: /** * Constructs a button whose text is determined by the current language * in the popup list. * * @param parent the parent of the button */ explicit KLanguageButton(QWidget *parent = nullptr); /** * Constructs a button with static text. * * @param text the text of the button * @param parent the parent of the button */ explicit KLanguageButton(const QString &text, QWidget *parent = nullptr); /** * Deconstructor */ virtual ~KLanguageButton(); /** * Sets the locale to display language names. By default, QLocale::system().name() is used. * * @param locale locale to use */ void setLocale(const QString &locale); /** * Sets a static button text. * * @param text button text */ void setText(const QString &text); /** * Specifies whether language codes should be shown alongside language names * in the popup. Calling this method does not affect any previously * inserted language texts, so it should normally be called before * populating the list. * * @param show true to show codes, false to hide codes */ void showLanguageCodes(bool show); /** * Load all known languages into the popup list. * The current language in the list is set to the default language for the * current locale (as modified by setLocale()). */ void loadAllLanguages(); /** * Inserts a language into the combo box. * Normally the display name of the language is obtained automatically, but * if either the language code does not exist, or there are special display * requirements, the name of the language can be specified in @p name. * * @param languageCode the code for the language * @param name language name. If empty, the name is obtained automatically. * @param index the insertion position, or -1 to insert in alphabetical order */ void insertLanguage(const QString &languageCode, const QString &name = QString(), int index = -1); /** * Inserts a separator item into the combo box. A negative index will append the item. * * @param index the insertion position */ void insertSeparator(int index = -1); /** * Returns the number of items in the combo box. */ int count() const; /** * Removes all combobox items. */ void clear(); /** * Returns the language code of the combobox's current item. * * @return the current item's language code */ QString current() const; /** * Checks whether the specified language is in the popup list. * * @param languageCode the language's code * @return true if in the list */ bool contains(const QString &languageCode) const; /** * Sets a given language to be the current item. * * @param languageCode the language's code */ void setCurrentItem(const QString &languageCode); Q_SIGNALS: /** * This signal is emitted when a new item is activated. * * @param languageCode code of the activated language */ void activated(const QString &languageCode); /** * This signal is emitted when a new item is highlighted. * * @param languageCode code of the highlighted language */ void highlighted(const QString &languageCode); private Q_SLOTS: void slotTriggered(QAction *); void slotHovered(QAction *); private: KLanguageButtonPrivate *const d; }; #endif diff --git a/src/kpastetextaction.h b/src/kpastetextaction.h index d01b7e6..2b547e7 100644 --- a/src/kpastetextaction.h +++ b/src/kpastetextaction.h @@ -1,102 +1,104 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Reginald Stadlbauer (C) 1999 Simon Hausmann (C) 2000 Nicolas Hadacek (C) 2000 Kurt Granroth (C) 2000 Michael Koch (C) 2001 Holger Freyther (C) 2002 Ellis Whitehead (C) 2003 Andras Mantia (C) 2005-2006 Hamish Rodda This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPASTETEXTACTION_H #define KPASTETEXTACTION_H #include #include class KPasteTextActionPrivate; /** + * @class KPasteTextAction kpastetextaction.h KPasteTextAction + * * An action for pasting text from the clipboard. * It's useful for text handling applications as * when plugged into a toolbar it provides a menu * with the clipboard history if klipper is running. * If klipper is not running, the menu has only one * item: the current clipboard content. */ class KCONFIGWIDGETS_EXPORT KPasteTextAction: public QAction { Q_OBJECT public: /** * Constructs an action with the specified parent. * * @param parent The parent of this action. */ explicit KPasteTextAction(QObject *parent); /** * Constructs an action with text; a shortcut may be specified by * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) * * This is the most common KAction used when you do not have a * corresponding icon (note that it won't appear in the current version * of the "Edit ToolBar" dialog, because an action needs an icon to be * plugged in a toolbar...). * * @param text The text that will be displayed. * @param parent The parent of this action. */ KPasteTextAction(const QString &text, QObject *parent); /** * Constructs an action with text and an icon; a shortcut may be specified by * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) * * This is the other common KAction used. Use it when you * \e do have a corresponding icon. * * @param icon The icon to display. * @param text The text that will be displayed. * @param parent The parent of this action. */ KPasteTextAction(const QIcon &icon, const QString &text, QObject *parent); virtual ~KPasteTextAction(); /** * Controls the behavior of the clipboard history menu popup. * * @param mode If false and the clipboard contains a non-text object * the popup menu with the clipboard history will appear * immediately as the user clicks the toolbar action; if * true, the action works like the standard paste action * even if the current clipboard object is not text. * Default value is true. */ void setMixedMode(bool mode); private: KPasteTextActionPrivate *const d; Q_PRIVATE_SLOT(d, void _k_menuAboutToShow()) Q_PRIVATE_SLOT(d, void _k_slotTriggered(QAction *)) }; #endif diff --git a/src/krecentfilesaction.h b/src/krecentfilesaction.h index adb36a1..a3c797f 100644 --- a/src/krecentfilesaction.h +++ b/src/krecentfilesaction.h @@ -1,193 +1,195 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Reginald Stadlbauer (C) 1999 Simon Hausmann (C) 2000 Nicolas Hadacek (C) 2000 Kurt Granroth (C) 2000 Michael Koch (C) 2001 Holger Freyther (C) 2002 Ellis Whitehead (C) 2003 Andras Mantia (C) 2005-2006 Hamish Rodda This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KRECENTFILESACTION_H #define KRECENTFILESACTION_H #include #include #include class KConfigGroup; class KRecentFilesActionPrivate; /** + * @class KRecentFilesAction krecentfilesaction.h KRecentFilesAction + * * @short Recent files action * * This class is an action to handle a recent files submenu. * The best way to create the action is to use KStandardAction::openRecent. * Then you simply need to call loadEntries on startup, saveEntries * on shutdown, addURL when your application loads/saves a file. * * @author Michael Koch */ class KCONFIGWIDGETS_EXPORT KRecentFilesAction : public KSelectAction { Q_OBJECT Q_PROPERTY(int maxItems READ maxItems WRITE setMaxItems) Q_DECLARE_PRIVATE(KRecentFilesAction) public: /** * Constructs an action with the specified parent. * * @param parent The parent of this action. */ explicit KRecentFilesAction(QObject *parent); /** * Constructs an action with text; a shortcut may be specified by * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) * * This is the most common KAction used when you do not have a * corresponding icon (note that it won't appear in the current version * of the "Edit ToolBar" dialog, because an action needs an icon to be * plugged in a toolbar...). * * @param text The text that will be displayed. * @param parent The parent of this action. */ KRecentFilesAction(const QString &text, QObject *parent); /** * Constructs an action with text and an icon; a shortcut may be specified by * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) * * This is the other common KAction used. Use it when you * \e do have a corresponding icon. * * @param icon The icon to display. * @param text The text that will be displayed. * @param parent The parent of this action. */ KRecentFilesAction(const QIcon &icon, const QString &text, QObject *parent); /** * Destructor. */ virtual ~KRecentFilesAction(); /** * Adds \a action to the list of URLs, with \a url and title \a name. * * Do not use addAction(QAction*), as no url will be associated, and * consequently urlSelected() will not be emitted when \a action is selected. */ void addAction(QAction *action, const QUrl &url, const QString &name); /** * Reimplemented for internal reasons. */ QAction *removeAction(QAction *action) Q_DECL_OVERRIDE; public Q_SLOTS: /** * Clears the recent files list. * Note that there is also an action shown to the user for clearing the list. */ virtual void clear(); public: /** * Returns the maximum of items in the recent files list. */ int maxItems() const; /** * Sets the maximum of items in the recent files list. * The default for this value is 10 set in the constructor. * * If this value is lesser than the number of items currently * in the recent files list the last items are deleted until * the number of items are equal to the new maximum. */ void setMaxItems(int maxItems); /** * Loads the recent files entries from a given KConfigGroup object. * You can provide the name of the group used to load the entries. * If the groupname is empty, entries are loaded from a group called 'RecentFiles'. * Local file entries that do not exist anymore are not restored. * */ void loadEntries(const KConfigGroup &config); /** * Saves the current recent files entries to a given KConfigGroup object. * You can provide the name of the group used to load the entries. * If the groupname is empty, entries are saved to a group called 'RecentFiles' * */ void saveEntries(const KConfigGroup &config); /** * Add URL to recent files list. This will enable this action. * * @param url The URL of the file * @param name The user visible pretty name that appears before the URL */ void addUrl(const QUrl &url, const QString &name = QString()); /** * Remove an URL from the recent files list. * * @param url The URL of the file */ void removeUrl(const QUrl &url); /** * Retrieve a list of all URLs in the recent files list. */ QList urls() const; Q_SIGNALS: /** * This signal gets emitted when the user selects an URL. * * @param url The URL thats the user selected. */ void urlSelected(const QUrl &url); /** * This signal gets emitted when the user clear list. * So when user store url in specific config file it can saveEntry. * @since 4.3 */ void recentListCleared(); private: //Internal void clearEntries(); // Don't warn about the virtual overload. As the comment of the other // addAction() says, addAction( QAction* ) should not be used. using KSelectAction::addAction; KRecentFilesActionPrivate *d_ptr; Q_PRIVATE_SLOT(d_func(), void _k_urlSelected(QAction *)) }; #endif diff --git a/src/ktipdialog.h b/src/ktipdialog.h index c6438c0..ec29409 100644 --- a/src/ktipdialog.h +++ b/src/ktipdialog.h @@ -1,187 +1,189 @@ /***************************************************************** Copyright (c) 2000-2003 Matthias Hoelzer-Kluepfel Tobias Koenig Daniel Molkentin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************/ #ifndef KTIP_H #define KTIP_H #include #include #include /** * A database for tips-of-the-day. * * This class provides convenient access to a database containing * tips of the day. The database is stored in a XML file and parsed * when a KTipDatabase object is created. * * Once the file is read in, you can access the tips to display * them in the tip of the day dialog. * * The state of the tipdialog is saved to the applications's config file * in the group "TipOfDay" with a bool entry "RunOnStart". Check this value * if you want to allow the user to enable/disable the tipdialog in the * application's configuration dialog. * * \image html ktip.png "KDE Tip-of-the-Day Dialog" * * @author Matthias Hoelzer-Kluepfel * */ class KCONFIGWIDGETS_EXPORT KTipDatabase { public: /** * This constructor reads in the tips from a file with the given name. If * no name is given, a file called 'application-name/tips' will be loaded. * * @param tipFile The absolute path to the tips file. */ explicit KTipDatabase(const QString &tipFile = QString()); /** * This constructor takes a list of files that will be merged. This constructor * essentially behaves like the one above. It returns when tipFiles is empty. * * @param tipFiles A list of absolute paths to the tips file */ explicit KTipDatabase(const QStringList &tipFiles); ~KTipDatabase(); /** * Returns the current tip. */ QString tip() const; /** * The next tip will become the current one. */ void nextTip(); /** * The previous tip will become the current one. */ void prevTip(); private: class Private; Private *const d; Q_DISABLE_COPY(KTipDatabase) }; /** + * @class KTipDialog ktipdialog.h KTipDialog + * * A Tip-of-the-Day dialog. * * This dialog class presents a tip-of-the-day. * * The tips will be looked up for translation using gettext * with KLocalizedString::applicationDomain() as domain. * * @author Matthias Hoelzer-Kluepfel */ class KCONFIGWIDGETS_EXPORT KTipDialog : public QDialog { Q_OBJECT public: /** * Construct a tip dialog. * * @param database TipDatabase that should be used by the TipDialog. The KTipDialog * will take ownership of the database, including deleting it. * @param parent Parent widget of TipDialog. */ explicit KTipDialog(KTipDatabase *database, QWidget *parent = nullptr); /** * Destroys the tip dialog. */ ~KTipDialog(); /** * Shows a tip. * * This static method is all that is needed to add a tip-of-the-day * dialog to an application. It will pop up the dialog, unless the * user has asked that the dialog does not pop up on startup. * * Note that you probably want an item in the help menu calling * this method with force=true. * * @param parent Parent widget of TipDialog. * @param tipFile The name of the tip file. It has be relative to the GenericDataLocation * resource of QStandardPaths. * @param force If true, the dialog is show, even when the users * disabled it. */ static void showTip(QWidget *parent, const QString &tipFile = QString(), bool force = false); /** * Shows a tip * * This method behaves essentially as the one above, but expects a list of tips * * @param parent Parent widget of TipDialog. * @param tipFiles A List of tip files. Each has be relative to the GenericDataLocation * resource of QStandardPaths. * @param force If true, the dialog is show, even when the users * disabled it. */ static void showMultiTip(QWidget *parent, const QStringList &tipFiles, bool force = false); /** * Shows a tip. * * This methods calls showTip() with the applications main window as parent. * */ static void showTip(const QString &tipFile = QString(), bool force = false); /** * Toggles the start behavior. * * Normally, the user can disable the display of the tip in the dialog. * This is just a way to change this setting from outside. */ static void setShowOnStart(bool show); protected: bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; private: class Private; Private *const d; Q_PRIVATE_SLOT(d, void _k_nextTip()) Q_PRIVATE_SLOT(d, void _k_prevTip()) Q_PRIVATE_SLOT(d, void _k_showOnStart(bool)) Q_DISABLE_COPY(KTipDialog) }; #endif diff --git a/src/kviewstatemaintainer.h b/src/kviewstatemaintainer.h index e90dbb5..57c2eee 100644 --- a/src/kviewstatemaintainer.h +++ b/src/kviewstatemaintainer.h @@ -1,76 +1,78 @@ /* Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net, author Stephen Kelly This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KVIEWSTATEMAINTAINER_H #define KVIEWSTATEMAINTAINER_H #include "kviewstatemaintainerbase.h" #include #include #include "kconfiggroup.h" /** + * @class KViewStateMaintainer kviewstatemaintainer.h KViewStateMaintainer + * * @brief Encapsulates the maintenance of state between resets of QAbstractItemModel * * @code * m_collectionViewStateMaintainer = new KViewStateMaintainer(KSharedConfig::openConfig()->group("collectionView")); * m_collectionViewStateMaintainer->setView(m_collectionView); * * m_collectionCheckStateMaintainer = new KViewStateMaintainer(KSharedConfig::openConfig()->group("collectionCheckState")); * m_collectionCheckStateMaintainer->setSelectionModel(m_checkableProxy->selectionModel()); * @endcode * * @see KViewStateSaver */ template class KViewStateMaintainer : public KViewStateMaintainerBase { typedef StateSaver StateRestorer; public: KViewStateMaintainer(const KConfigGroup &configGroup, QObject *parent = 0) : KViewStateMaintainerBase(parent), m_configGroup(configGroup) { } /* reimp */ void saveState() { StateSaver saver; saver.setView(view()); saver.setSelectionModel(selectionModel()); saver.saveState(m_configGroup); m_configGroup.sync(); } /* reimp */ void restoreState() { StateRestorer *restorer = new StateRestorer; restorer->setView(view()); restorer->setSelectionModel(selectionModel()); restorer->restoreState(m_configGroup); } private: KConfigGroup m_configGroup; }; #endif