KHelpMenu Class
Standard KDE help menu with dialog boxes. More...
Header: | #include <KHelpMenu> |
CMake: | find_package(KF6 REQUIRED COMPONENTS XmlGui) target_link_libraries(mytarget PRIVATE KF6::XmlGui) |
Inherits: | QObject |
Public Types
enum | MenuId { menuHelpContents, menuWhatsThis, menuAboutApp, menuAboutKDE, menuReportBug, …, menuDonate } |
Public Functions
virtual | ~KHelpMenu() override |
QAction * | action(KHelpMenu::MenuId id) const |
QMenu * | menu() |
Public Slots
void | aboutApplication() |
void | aboutKDE() |
void | appHelpActivated() |
void | contextHelpActivated() |
(since 5.24) void | donate() |
void | reportBug() |
void | switchApplicationLanguage() |
Signals
void | showAboutApplication() |
Detailed Description
This class provides the standard KDE help menu with the default "About" dialog boxes and help entry.
This class is used in KMainWindow so normally you don't need to use this class yourself. However, if you need the help menu or any of its dialog boxes in your code that is not subclassed from KMainWindow you should use this class.
The usage is simple:
mHelpMenu = new KHelpMenu( this ); kmenubar->addMenu(mHelpMenu->menu() );
or if you just want to open a dialog box:
mHelpMenu = new KHelpMenu( this ); connect(this, &ClassFoo::someSignal, mHelpMenu, &KHelpMenu::aboutKDE);
Warning: The first time you use KHelpMenu::menu(), a QMenu object is allocated. Only one object is created by the class so if you call KHelpMenu::menu() twice or more, the same pointer is returned. The class will destroy the popupmenu in the destructor so do not delete this pointer yourself.
The KHelpMenu object will be deleted when its parent is destroyed but you can delete it yourself if you want. The code below will always work.
MyClass::~MyClass() { delete mHelpMenu; }
Using your own "About Application" dialog box:
The standard "About Application" dialog box is quite simple. If you need a dialog box with more functionality you must design that one yourself. When you want to display the dialog, you simply need to connect the help menu signal showAboutApplication() to your slot.
void MyClass::myFunc() { // ... KHelpMenu *helpMenu = new KHelpMenu( this ); connect(helpMenu, &KHelpMenu::showAboutApplication, this, &ClassFoo:myDialogSlot); // ... } void MyClass::myDialogSlot() { <activate your custom dialog> }
KHelpMenu respects Kiosk settings (see the KAuthorized namespace in the KConfig framework). In particular, system administrators can disable items on this menu using some subset of the following configuration:
[KDE Action Restrictions][$i] actions/help_contents=false actions/help_whats_this=false actions/help_report_bug=false actions/switch_application_language=false actions/help_about_app=false actions/help_about_kde=false
Member Type Documentation
enum KHelpMenu::MenuId
Constant | Value | Description |
---|---|---|
KHelpMenu::menuHelpContents | 0 | Whether to show the Help contents. This usually consists of the handbook for the application. |
KHelpMenu::menuWhatsThis | 1 | Whether to show the "What's This?" menu. When triggered, clicking anything with the mouse cursor should show information about the clicked component. |
KHelpMenu::menuAboutApp | 2 | Whether to show the "About <application>" menu. This menu usually contains information about the application version, copyright, license, library components, authors and acknowledgements. |
KHelpMenu::menuAboutKDE | 3 | Whether to show the "About KDE" menu. The contents of this menu is standardized, mentioning what KDE is, how to get support, contribute, and donate. |
KHelpMenu::menuReportBug | 4 | Whether to show the "Report Bug..." menu. This provides a dialog to initiate the bug report wizard provided by KCrash. |
KHelpMenu::menuSwitchLanguage | 5 | Whether to show the switch language menu. |
KHelpMenu::menuDonate | 6 | Since 5.24, triggering this menu opens the donation page on a browser. |
Member Function Documentation
[override virtual noexcept]
KHelpMenu::~KHelpMenu()
Destroys the help menu dialogs and the menu pointer returned by the menu.
[slot]
void KHelpMenu::aboutApplication()
Opens an application specific dialog box.
The method will try to open the about box using the following steps: - If the showAboutApplication() signal is connected, then it will be emitted. This means there is an application defined aboutBox. - If the aboutData was set in the constructor a KAboutApplicationDialog will be created with this aboutData. - Else a KAboutApplicationDialog will be created using KAboutData::applicationData().
[slot]
void KHelpMenu::aboutKDE()
Opens the standard "About KDE" dialog box.
QAction *KHelpMenu::action(KHelpMenu::MenuId id) const
Returns the QAction * associated with the given parameter id.
Will return a nullptr if menu() has not been called.
[slot]
void KHelpMenu::appHelpActivated()
Opens the help page for the application.
The application name is used as a key to determine what to display and the system will attempt to open <appName>/index.html.
[slot]
void KHelpMenu::contextHelpActivated()
Activates "What's This" help for the application.
[slot, since 5.24]
void KHelpMenu::donate()
Opens the donate url on a browser.
This function was introduced in 5.24.
QMenu *KHelpMenu::menu()
Returns a popup menu you can use in the menu bar or where you need it.
The returned menu is configured with an icon, a title and menu entries. Therefore adding the returned pointer to your menu is enough to have access to the help menu.
Note: This method will only create one instance of the menu. If you call this method twice or more the same pointer is returned.
[slot]
void KHelpMenu::reportBug()
Opens the standard "Report Bugs" dialog box.
[signal]
void KHelpMenu::showAboutApplication()
This signal is emitted from aboutApplication() if no "About <application>" string has been defined.
The standard application specific dialog box that is normally activated in aboutApplication() will not be displayed when this signal is emitted.
[slot]
void KHelpMenu::switchApplicationLanguage()
Opens the changing default application language dialog box.