diff --git a/umbrello/dialogs/dontaskagain.h b/umbrello/dialogs/dontaskagain.h index 3749cd7cf..a85cab7dc 100644 --- a/umbrello/dialogs/dontaskagain.h +++ b/umbrello/dialogs/dontaskagain.h @@ -1,116 +1,117 @@ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2018 * * Umbrello UML Modeller Authors * ***************************************************************************/ #ifndef DONTASKAGAIN_H #define DONTASKAGAIN_H // Qt includes #include #include #include // KDE includes #include class QVBoxLayout; /** * The DontAskAgainItem class holds a 'dont ask again' item, * see @ref DontAskAgainHandler for details. * * @author Ralf Habacker */ class DontAskAgainItem { public: DontAskAgainItem(const QString &name); virtual ~DontAskAgainItem(); QString &name(); virtual QString text() const = 0; bool isAll(); bool isEnabled(); void setEnabled(bool state = true); protected: QString m_name; }; #define DefineDontAskAgainItem(name,key,_text) \ class DontAskAgainItem##name : public DontAskAgainItem \ { \ public: \ DontAskAgainItem##name() : DontAskAgainItem(QLatin1String(key)) {} \ virtual QString text() const { return _text; } \ -} name; +}; \ +static DontAskAgainItem##name name; /** * The DontAskAgainWidget provides a graphical user interface * to change 'dont ask again' settings and could be embedded * in dialogs or dialog pages. * * After adding the widget to a dialog call @ref apply() to apply * changed values and call @ref setDefaults() to reset changes to * default values, which is all messages enabled. * * The widget is designed as group box with embedded check boxes. * * @author Ralf Habacker */ class DontAskAgainWidget : public QWidget { Q_OBJECT public: DontAskAgainWidget(QList &items, QWidget *parent = 0); bool apply(); void setDefaults(); protected: void addItem(DontAskAgainItem *item); QVBoxLayout *m_layout; QList &m_items; protected slots: void slotToggled(bool state); }; /** * Dialogs provided by namespace KMessageBox support a feature to hide dialogs on user request * by specifying the parameter dontAskAgainName, which adds a checkbox named "Don't ask again" * to the related dialog. * * What is currently missing in KMessageBox namespace and therefore provided by class * DontAskAgainHandler, is a widget to reenable or disable dialogs using the "Don't ask again" * support in an application setting dialog. * * To use this support call macro @ref DefineDontAskAgainItem and add a call to method * DontAskAgainItem::name as parameter @p dontAskAgainName to related class KMessageBox * methods. See the following example: * * \code{.cpp} * DefineDontAskAgainItem(aDontAskAgainItem, "delete-diagram", i18n("Enable 'delete diagram' related messages")); * ... * return KMessageBox::warningContinueCancel(..., aDontAskAgainItem.name()) * \endcode * * To add the mentioned widget to a settings dialog call @ref createWidget() and * add the result to a dialog layout. * * @author Ralf Habacker */ class DontAskAgainHandler { public: void addItem(DontAskAgainItem *item); static DontAskAgainHandler &instance(); DontAskAgainWidget *createWidget(); protected: QList m_items; }; #endif // DONTASKAGAIN_H