Warning, file /graphics/krita/libs/widgetutils/xmlgui/khelpmenu.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * This file is part of the KDE Libraries
0003  * SPDX-FileCopyrightText: 1999-2000 Espen Sand (espen@kde.org)
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  *
0007  */
0008 
0009 #ifndef KHELPMENU_H
0010 #define KHELPMENU_H
0011 
0012 #include <kritawidgetutils_export.h>
0013 
0014 #include <QObject>
0015 #include <QString>
0016 
0017 class QMenu;
0018 class QWidget;
0019 class QAction;
0020 
0021 class KAboutData;
0022 class KisKHelpMenuPrivate;
0023 
0024 /**
0025  * @short Standard %KDE help menu with dialog boxes.
0026  *
0027  * This class provides the standard %KDE help menu with the default "about"
0028  * dialog boxes and help entry.
0029  *
0030  * This class is used in KisKMainWindow so
0031  * normally you don't need to use this class yourself. However, if you
0032  * need the help menu or any of its dialog boxes in your code that is
0033  * not subclassed from KisKMainWindow you should use this class.
0034  *
0035  * The usage is simple:
0036  *
0037  * \code
0038  * mHelpMenu = new KisKHelpMenu( this, <someText> );
0039  * kmenubar->addMenu(mHelpMenu->menu() );
0040  * \endcode
0041  *
0042  * or if you just want to open a dialog box:
0043  *
0044  * \code
0045  * mHelpMenu = new KisKHelpMenu( this, <someText> );
0046  * connect( this, SIGNAL(someSignal()), mHelpMenu,SLOT(aboutKDE()));
0047  * \endcode
0048  *
0049  * IMPORTANT:
0050  * The first time you use KisKHelpMenu::menu(), a QMenu object is
0051  * allocated. Only one object is created by the class so if you call
0052  * KisKHelpMenu::menu() twice or more, the same pointer is returned. The class
0053  * will destroy the popupmenu in the destructor so do not delete this
0054  * pointer yourself.
0055  *
0056  * The KisKHelpMenu object will be deleted when its parent is destroyed but you
0057  * can delete it yourself if you want. The code below will always work.
0058  *
0059  * \code
0060  * MyClass::~MyClass()
0061  * {
0062  *   delete mHelpMenu;
0063  * }
0064  * \endcode
0065  *
0066  *
0067  * Using your own "about application" dialog box:
0068  *
0069  * The standard "about application" dialog box is quite simple. If you
0070  * need a dialog box with more functionality you must design that one
0071  * yourself. When you want to display the dialog, you simply need to
0072  * connect the help menu signal showAboutApplication() to your slot.
0073  *
0074  * \code
0075  * void MyClass::myFunc()
0076  * {
0077  *   ..
0078  *   KisKHelpMenu *helpMenu = new KisKHelpMenu( this );
0079  *   connect( helpMenu, SIGNAL(showAboutApplication()),
0080  *          this, SLOT(myDialogSlot()));
0081  *   ..
0082  * }
0083  *
0084  * void MyClass::myDialogSlot()
0085  * {
0086  *   <activate your custom dialog>
0087  * }
0088  * \endcode
0089  *
0090  * \image html khelpmenu.png "KDE Help Menu"
0091  *
0092  * @verbatim
0093    [KDE Action Restrictions][$i]
0094    actions/help_contents=false
0095    actions/help_whats_this=false
0096    actions/help_report_bug=false
0097    actions/switch_application_language=false
0098    actions/help_about_app=false
0099    actions/help_about_kde=false
0100    @endverbatim
0101  *
0102  * @author Espen Sand (espen@kde.org)
0103  */
0104 
0105 class KRITAWIDGETUTILS_EXPORT KisKHelpMenu : public QObject
0106 {
0107     Q_OBJECT
0108 
0109 public:
0110     /**
0111      * Constructor.
0112      *
0113      * @param parent The parent of the dialog boxes. The boxes are modeless
0114      *        and will be centered with respect to the parent.
0115      * @param aboutAppText User definable string that is used in the
0116      *        default application dialog box.
0117      * @param showWhatsThis Decides whether a "Whats this" entry will be
0118      *        added to the dialog.
0119      *
0120      */
0121     explicit KisKHelpMenu(QWidget *parent = 0, const QString &aboutAppText = QString(),
0122                        bool showWhatsThis = true);
0123 
0124     /**
0125      * Constructor.
0126      *
0127      * This alternative constructor is mainly useful if you want to
0128      * override the standard actions (aboutApplication(), aboutKDE(),
0129      * helpContents(), reportBug, and optionally whatsThis).
0130      *
0131      * @param parent The parent of the dialog boxes. The boxes are modeless
0132      *        and will be centered with respect to the parent.
0133      * @param aboutData User and app data used in the About app dialog
0134      * @param showWhatsThis Decides whether a "Whats this" entry will be
0135      *        added to the dialog.
0136      */
0137     KisKHelpMenu(QWidget *parent, const KAboutData &aboutData,
0138               bool showWhatsThis = true);
0139 
0140     /**
0141      * Destructor
0142      *
0143      * Destroys dialogs and the menu pointer returned by menu
0144      */
0145     ~KisKHelpMenu() override;
0146 
0147     /**
0148      * Returns a popup menu you can use in the menu bar or where you
0149      * need it.
0150      *
0151      * The returned menu is configured with an icon, a title and
0152      * menu entries. Therefore adding the returned pointer to your menu
0153      * is enough to have access to the help menu.
0154      *
0155      * Note: This method will only create one instance of the menu. If
0156      * you call this method twice or more the same pointer is returned.
0157      */
0158     QMenu *menu();
0159 
0160     enum MenuId {
0161         menuHelpContents = 0,
0162         menuWhatsThis = 1,
0163         menuAboutApp = 2,
0164         menuAboutKDE = 3,
0165         menuReportBug = 4,
0166         menuSwitchLanguage = 5
0167     };
0168 
0169     /**
0170      * Returns the QAction * associated with the given parameter
0171      * Will return 0 pointers if menu() has not been called
0172      *
0173      * @param id The id of the action of which you want to get QAction *
0174      */
0175     QAction *action(MenuId id) const;
0176 
0177 public Q_SLOTS:
0178     /**
0179      * Opens the help page for the application. The application name is
0180      * used as a key to determine what to display and the system will attempt
0181      * to open \<appName\>/index.html.
0182      */
0183     void appHelpActivated();
0184 
0185     /**
0186      * Activates What's This help for the application.
0187      */
0188     void contextHelpActivated();
0189 
0190     /**
0191      * Opens an application specific dialog box.
0192      *
0193      * The method will try to open the about box using the following steps:
0194      * - If the showAboutApplication() signal is connected, then it will be called.
0195      *   This means there is an application defined aboutBox.
0196      * - If the aboutData was set in the constructor a KAboutApplicationDialog will be created.
0197      * - Else a default about box using the aboutAppText from the constructor will be created.
0198      */
0199     void aboutApplication();
0200 
0201     /**
0202      * Opens the standard "About KDE" dialog box.
0203      */
0204     void aboutKDE();
0205 
0206     /**
0207      * Opens the standard "Report Bugs" dialog box.
0208      */
0209     void reportBug();
0210 
0211     /**
0212      * Opens the changing default application language dialog box.
0213      */
0214     void switchApplicationLanguage();
0215 
0216 private Q_SLOTS:
0217     /**
0218      * Connected to the menu pointer (if created) to detect a delete
0219      * operation on the pointer. You should not delete the pointer in your
0220      * code yourself. Let the KisKHelpMenu destructor do the job.
0221      */
0222     void menuDestroyed();
0223 
0224     /**
0225      * Connected to the dialogs (about kde and bug report) to detect
0226      * when they are finished.
0227      */
0228     void dialogFinished();
0229 
0230     /**
0231      * This slot will delete a dialog (about kde or bug report) if the
0232      * dialog pointer is not zero and the dialog is not visible. This
0233      * slot is activated by a one shot timer started in dialogHidden
0234      */
0235     void timerExpired();
0236 
0237 Q_SIGNALS:
0238     /**
0239      * This signal is emitted from aboutApplication() if no
0240      * "about application" string has been defined. The standard
0241      * application specific dialog box that is normally activated in
0242      * aboutApplication() will not be displayed when this signal
0243      * is emitted.
0244      */
0245     void showAboutApplication();
0246 
0247 private:
0248     KisKHelpMenuPrivate *const d;
0249 };
0250 
0251 #endif