Krita Source Code Documentation
Loading...
Searching...
No Matches
KisKHelpMenu Class Reference

Standard KDE help menu with dialog boxes. More...

#include <khelpmenu.h>

+ Inheritance diagram for KisKHelpMenu:

Public Types

enum  MenuId {
  menuHelpContents = 0 , menuWhatsThis = 1 , menuAboutApp = 2 , menuAboutKDE = 3 ,
  menuReportBug = 4 , menuSwitchLanguage = 5
}
 

Public Slots

void aboutApplication ()
 
void aboutKDE ()
 
void appHelpActivated ()
 
void contextHelpActivated ()
 
void reportBug ()
 
void switchApplicationLanguage ()
 

Signals

void showAboutApplication ()
 

Public Member Functions

QAction * action (MenuId id) const
 
 KisKHelpMenu (QWidget *parent, const KAboutData &aboutData, bool showWhatsThis=true)
 
 KisKHelpMenu (QWidget *parent=0, const QString &aboutAppText=QString(), bool showWhatsThis=true)
 
QMenu * menu ()
 
 ~KisKHelpMenu () override
 

Private Slots

void dialogFinished ()
 
void menuDestroyed ()
 
void timerExpired ()
 

Private Attributes

KisKHelpMenuPrivate *const d
 

Detailed Description

Standard KDE help menu with dialog boxes.

This class provides the standard KDE help menu with the default "about" dialog boxes and help entry.

This class is used in KisKMainWindow 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 KisKMainWindow you should use this class.

The usage is simple:

mHelpMenu = new KisKHelpMenu( this, <someText> );
kmenubar->addMenu(mHelpMenu->menu() );
KisKHelpMenu(QWidget *parent=0, const QString &aboutAppText=QString(), bool showWhatsThis=true)
Definition khelpmenu.cpp:81

or if you just want to open a dialog box:

mHelpMenu = new KisKHelpMenu( this, <someText> );
connect( this, SIGNAL(someSignal()), mHelpMenu,SLOT(aboutKDE()));
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void aboutKDE()

IMPORTANT: The first time you use KisKHelpMenu::menu(), a QMenu object is allocated. Only one object is created by the class so if you call KisKHelpMenu::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 KisKHelpMenu 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()
{
..
KisKHelpMenu *helpMenu = new KisKHelpMenu( this );
connect( helpMenu, SIGNAL(showAboutApplication()),
this, SLOT(myDialogSlot()));
..
}
void MyClass::myDialogSlot()
{
<activate your custom dialog>
}
Standard KDE help menu with dialog boxes.
Definition khelpmenu.h:106
void showAboutApplication()
KDE Help Menu
[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
Author
Espen Sand (espen.nosp@m.@kde.nosp@m..org)

Definition at line 105 of file khelpmenu.h.

Member Enumeration Documentation

◆ MenuId

Enumerator
menuHelpContents 
menuWhatsThis 
menuAboutApp 
menuAboutKDE 
menuReportBug 
menuSwitchLanguage 

Definition at line 160 of file khelpmenu.h.

160 {
162 menuWhatsThis = 1,
163 menuAboutApp = 2,
164 menuAboutKDE = 3,
165 menuReportBug = 4,
167 };

Constructor & Destructor Documentation

◆ KisKHelpMenu() [1/2]

KisKHelpMenu::KisKHelpMenu ( QWidget * parent = 0,
const QString & aboutAppText = QString(),
bool showWhatsThis = true )
explicit

Constructor.

Parameters
parentThe parent of the dialog boxes. The boxes are modeless and will be centered with respect to the parent.
aboutAppTextUser definable string that is used in the default application dialog box.
showWhatsThisDecides whether a "Whats this" entry will be added to the dialog.

Definition at line 81 of file khelpmenu.cpp.

83 : QObject(parent), d(new KisKHelpMenuPrivate)
84{
85 d->mAboutAppText = aboutAppText;
86 d->mShowWhatsThis = showWhatsThis;
87 d->mParent = parent;
88 d->createActions(this);
89}
void createActions(KisKHelpMenu *q)
KisKHelpMenuPrivate *const d
Definition khelpmenu.h:248
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References KisKHelpMenuPrivate::createActions(), d, KisKHelpMenuPrivate::mAboutAppText, KisKHelpMenuPrivate::mParent, and KisKHelpMenuPrivate::mShowWhatsThis.

◆ KisKHelpMenu() [2/2]

KisKHelpMenu::KisKHelpMenu ( QWidget * parent,
const KAboutData & aboutData,
bool showWhatsThis = true )

Constructor.

This alternative constructor is mainly useful if you want to override the standard actions (aboutApplication(), aboutKDE(), helpContents(), reportBug, and optionally whatsThis).

Parameters
parentThe parent of the dialog boxes. The boxes are modeless and will be centered with respect to the parent.
aboutDataUser and app data used in the About app dialog
showWhatsThisDecides whether a "Whats this" entry will be added to the dialog.

Definition at line 91 of file khelpmenu.cpp.

93 : QObject(parent), d(new KisKHelpMenuPrivate)
94{
95 d->mShowWhatsThis = showWhatsThis;
96 d->mParent = parent;
97 d->mAboutData = aboutData;
98 d->createActions(this);
99}
KAboutData mAboutData
Definition khelpmenu.cpp:78

References KisKHelpMenuPrivate::createActions(), d, KisKHelpMenuPrivate::mAboutData, KisKHelpMenuPrivate::mParent, and KisKHelpMenuPrivate::mShowWhatsThis.

◆ ~KisKHelpMenu()

KisKHelpMenu::~KisKHelpMenu ( )
override

Destructor

Destroys dialogs and the menu pointer returned by menu

Definition at line 101 of file khelpmenu.cpp.

102{
103 delete d;
104}

References d.

Member Function Documentation

◆ aboutApplication

void KisKHelpMenu::aboutApplication ( )
slot

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 called. This means there is an application defined aboutBox.
  • If the aboutData was set in the constructor a KAboutApplicationDialog will be created.
  • Else a default about box using the aboutAppText from the constructor will be created.

Definition at line 216 of file khelpmenu.cpp.

217{
218 if (receivers(SIGNAL(showAboutApplication())) > 0) {
219 Q_EMIT showAboutApplication();
220 }
221}

References showAboutApplication().

◆ aboutKDE

void KisKHelpMenu::aboutKDE ( )
slot

Opens the standard "About KDE" dialog box.

Definition at line 223 of file khelpmenu.cpp.

224{
225 if (!d->mAboutKDE) {
227 connect(d->mAboutKDE, SIGNAL(finished(int)), this, SLOT(dialogFinished()));
228 }
229 d->mAboutKDE->show();
230}
Standard "About KDE" dialog box.
KisKAboutKdeDialog * mAboutKDE
Definition khelpmenu.cpp:61
void dialogFinished()

References connect(), d, dialogFinished(), KisKHelpMenuPrivate::mAboutKDE, and KisKHelpMenuPrivate::mParent.

◆ action()

QAction * KisKHelpMenu::action ( MenuId id) const

Returns the QAction * associated with the given parameter Will return 0 pointers if menu() has not been called

Parameters
idThe id of the action of which you want to get QAction *

Definition at line 180 of file khelpmenu.cpp.

181{
182 switch (id) {
183 case menuHelpContents:
184 return d->mHandBookAction;
185 break;
186
187 case menuWhatsThis:
188 return d->mWhatsThisAction;
189 break;
190
191 case menuReportBug:
192 return d->mReportBugAction;
193 break;
194
197 break;
198
199 case menuAboutApp:
200 return d->mAboutAppAction;
201 break;
202
203 case menuAboutKDE:
204 return d->mAboutKDEAction;
205 break;
206 }
207
208 return 0;
209}
QAction * mAboutAppAction
Definition khelpmenu.cpp:75
QAction * mAboutKDEAction
Definition khelpmenu.cpp:76
QAction * mHandBookAction
Definition khelpmenu.cpp:71
QAction * mSwitchApplicationLanguageAction
Definition khelpmenu.cpp:74
QAction * mWhatsThisAction
Definition khelpmenu.cpp:72
QAction * mReportBugAction
Definition khelpmenu.cpp:73

References d, KisKHelpMenuPrivate::mAboutAppAction, KisKHelpMenuPrivate::mAboutKDEAction, menuAboutApp, menuAboutKDE, menuHelpContents, menuReportBug, menuSwitchLanguage, menuWhatsThis, KisKHelpMenuPrivate::mHandBookAction, KisKHelpMenuPrivate::mReportBugAction, KisKHelpMenuPrivate::mSwitchApplicationLanguageAction, and KisKHelpMenuPrivate::mWhatsThisAction.

◆ appHelpActivated

void KisKHelpMenu::appHelpActivated ( )
slot

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.

Definition at line 211 of file khelpmenu.cpp.

212{
213 QDesktopServices::openUrl(QUrl(QStringLiteral("help:/")));
214}

◆ contextHelpActivated

void KisKHelpMenu::contextHelpActivated ( )
slot

Activates What's This help for the application.

Definition at line 281 of file khelpmenu.cpp.

282{
283 QWhatsThis::enterWhatsThisMode();
284}

◆ dialogFinished

void KisKHelpMenu::dialogFinished ( )
privateslot

Connected to the dialogs (about kde and bug report) to detect when they are finished.

Definition at line 254 of file khelpmenu.cpp.

255{
256 QTimer::singleShot(0, this, SLOT(timerExpired()));
257}
void timerExpired()

References timerExpired().

◆ menu()

QMenu * KisKHelpMenu::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.

Definition at line 127 of file khelpmenu.cpp.

128{
129 if (!d->mMenu) {
130 d->mMenu = new QMenu();
131 connect(d->mMenu, SIGNAL(destroyed()), this, SLOT(menuDestroyed()));
132
133 d->mMenu->setTitle(i18n("&Help"));
134
135 d->createActions(this);
136
137 bool need_separator = false;
138 if (d->mHandBookAction) {
139 d->mMenu->addAction(d->mHandBookAction);
140 need_separator = true;
141 }
142
143 if (d->mWhatsThisAction) {
144 d->mMenu->addAction(d->mWhatsThisAction);
145 need_separator = true;
146 }
147
148 if (d->mReportBugAction) {
149 if (need_separator) {
150 d->mMenu->addSeparator();
151 }
152 d->mMenu->addAction(d->mReportBugAction);
153 need_separator = true;
154 }
155
157 if (need_separator) {
158 d->mMenu->addSeparator();
159 }
161 need_separator = true;
162 }
163
164 if (need_separator) {
165 d->mMenu->addSeparator();
166 }
167
168 if (d->mAboutAppAction) {
169 d->mMenu->addAction(d->mAboutAppAction);
170 }
171
172 if (d->mAboutKDEAction) {
173 d->mMenu->addAction(d->mAboutKDEAction);
174 }
175 }
176
177 return d->mMenu;
178}
void menuDestroyed()

References connect(), KisKHelpMenuPrivate::createActions(), d, KisKHelpMenuPrivate::mAboutAppAction, KisKHelpMenuPrivate::mAboutKDEAction, menuDestroyed(), KisKHelpMenuPrivate::mHandBookAction, KisKHelpMenuPrivate::mMenu, KisKHelpMenuPrivate::mReportBugAction, KisKHelpMenuPrivate::mSwitchApplicationLanguageAction, and KisKHelpMenuPrivate::mWhatsThisAction.

◆ menuDestroyed

void KisKHelpMenu::menuDestroyed ( )
privateslot

Connected to the menu pointer (if created) to detect a delete operation on the pointer. You should not delete the pointer in your code yourself. Let the KisKHelpMenu destructor do the job.

Definition at line 276 of file khelpmenu.cpp.

277{
278 d->mMenu = 0;
279}

References d, and KisKHelpMenuPrivate::mMenu.

◆ reportBug

void KisKHelpMenu::reportBug ( )
slot

Opens the standard "Report Bugs" dialog box.

Definition at line 232 of file khelpmenu.cpp.

233{
234#ifdef KRITA_STABLE
235 QDesktopServices::openUrl(QUrl("https://docs.krita.org/en/untranslatable_pages/reporting_bugs.html"));
236#else
237 if (!d->mBugReport) {
239 connect(d->mBugReport, SIGNAL(finished(int)), this, SLOT(dialogFinished()));
240 }
241 d->mBugReport->show();
242#endif
243}
A dialog box for sending bug reports.
Definition kbugreport.h:29
KisKBugReport * mBugReport
Definition khelpmenu.cpp:62

References connect(), d, dialogFinished(), KisKHelpMenuPrivate::mAboutData, KisKHelpMenuPrivate::mBugReport, and KisKHelpMenuPrivate::mParent.

◆ showAboutApplication

void KisKHelpMenu::showAboutApplication ( )
signal

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.

◆ switchApplicationLanguage

void KisKHelpMenu::switchApplicationLanguage ( )
slot

Opens the changing default application language dialog box.

Definition at line 245 of file khelpmenu.cpp.

246{
249 connect(d->mSwitchApplicationLanguage, SIGNAL(finished(int)), this, SLOT(dialogFinished()));
250 }
252}
Standard "switch application language" dialog box.
KisKSwitchLanguageDialog * mSwitchApplicationLanguage
Definition khelpmenu.cpp:63

References connect(), d, dialogFinished(), KisKHelpMenuPrivate::mParent, and KisKHelpMenuPrivate::mSwitchApplicationLanguage.

◆ timerExpired

void KisKHelpMenu::timerExpired ( )
privateslot

This slot will delete a dialog (about kde or bug report) if the dialog pointer is not zero and the dialog is not visible. This slot is activated by a one shot timer started in dialogHidden

Definition at line 259 of file khelpmenu.cpp.

260{
261 if (d->mAboutKDE && !d->mAboutKDE->isVisible()) {
262 delete d->mAboutKDE; d->mAboutKDE = 0;
263 }
264
265 if (d->mBugReport && !d->mBugReport->isVisible()) {
266 delete d->mBugReport; d->mBugReport = 0;
267 }
270 }
271 if (d->mAboutApp && !d->mAboutApp->isVisible()) {
272 delete d->mAboutApp; d->mAboutApp = 0;
273 }
274}

References d, KisKHelpMenuPrivate::mAboutApp, KisKHelpMenuPrivate::mAboutKDE, KisKHelpMenuPrivate::mBugReport, and KisKHelpMenuPrivate::mSwitchApplicationLanguage.

Member Data Documentation

◆ d

KisKHelpMenuPrivate* const KisKHelpMenu::d
private

Definition at line 248 of file khelpmenu.h.


The documentation for this class was generated from the following files: