26 #include <tqtoolbutton.h> 27 #include <tqwhatsthis.h> 30 #include <kaboutapplication.h> 31 #include <kaboutdata.h> 32 #include <kaboutkde.h> 34 #include <kapplication.h> 35 #include <kbugreport.h> 36 #include <kdialogbase.h> 37 #include <khelpmenu.h> 38 #include <kiconloader.h> 40 #include <kmessagebox.h> 41 #include <kpopupmenu.h> 42 #include <kstdaccel.h> 43 #include <kstdaction.h> 44 #include <kstandarddirs.h> 46 #include "kswitchlanguagedialog.h" 51 class KHelpMenuPrivate
54 KHelpMenuPrivate():mSwitchApplicationLanguage(NULL)
59 delete mSwitchApplicationLanguage;
68 : TQObject(parent), mMenu(0), mAboutApp(0), mAboutKDE(0), mBugReport(0),
69 d(new KHelpMenuPrivate)
72 mAboutAppText = aboutAppText;
73 mShowWhatsThis = showWhatsThis;
79 : TQObject(parent), mMenu(0), mAboutApp(0), mAboutKDE(0), mBugReport(0),
80 d(new KHelpMenuPrivate)
83 mShowWhatsThis = showWhatsThis;
85 d->mAboutData = aboutData;
88 mAboutAppText = TQString::null;
122 TQString appName = (aboutData)? aboutData->
programName() : TQString::fromLatin1(tqApp->name());
125 connect( mMenu, TQT_SIGNAL(destroyed()),
this, TQT_SLOT(menuDestroyed()));
127 bool need_separator =
false;
128 if (kapp->authorizeKAction(
"help_contents"))
131 TQString(i18n(
"%1 &Handbook" ).arg( appName)) ,menuHelpContents );
134 need_separator =
true;
137 if( mShowWhatsThis && kapp->authorizeKAction(
"help_whats_this") )
139 TQToolButton* wtb = TQWhatsThis::whatsThisButton(0);
140 mMenu->insertItem( wtb->iconSet(),i18n(
"What's &This" ), menuWhatsThis);
143 mMenu->setAccel( SHIFT + Key_F1, menuWhatsThis );
144 need_separator =
true;
147 if (kapp->authorizeKAction(
"help_report_bug") && aboutData && !aboutData->
bugAddress().isEmpty() )
150 mMenu->insertSeparator();
151 mMenu->insertItem( i18n(
"&Report Bug/Request Enhancement..." ), menuReportBug );
152 mMenu->connectItem( menuReportBug,
this, TQT_SLOT(
reportBug()) );
153 need_separator =
true;
156 if (kapp->authorizeKAction(
"switch_application_language"))
159 mMenu->insertSeparator();
160 mMenu->insertItem( i18n(
"Switch application &language..." ), menuSwitchLanguage );
162 need_separator =
true;
166 mMenu->insertSeparator();
168 if (kapp->authorizeKAction(
"help_about_app"))
170 mMenu->insertItem( kapp->miniIcon(),
171 TQString(i18n(
"&About %1" ).arg(appName)), menuAboutApp );
175 if (kapp->authorizeKAction(
"help_about_kde"))
177 mMenu->insertItem( SmallIcon(
"about_kde"), i18n(
"About &Trinity" ), menuAboutKDE );
178 mMenu->connectItem( menuAboutKDE,
this, TQT_SLOT(
aboutKDE() ) );
200 connect( mAboutApp, TQT_SIGNAL(finished()),
this, TQT_SLOT( dialogFinished()) );
204 else if( mAboutAppText.isEmpty() )
215 false,
true, KStdGuiItem::ok() );
216 connect( mAboutApp, TQT_SIGNAL(finished()),
this, TQT_SLOT( dialogFinished()) );
218 TQHBox *hbox =
new TQHBox( mAboutApp );
223 TQLabel *label1 =
new TQLabel(hbox);
224 label1->setPixmap( kapp->icon() );
225 TQLabel *label2 =
new TQLabel(hbox);
226 label2->setText( mAboutAppText );
241 mAboutKDE =
new KAboutKDE( mParent,
"aboutkde",
false );
242 connect( mAboutKDE, TQT_SIGNAL(finished()),
this, TQT_SLOT( dialogFinished()) );
252 mBugReport =
new KBugReport( mParent,
false, d->mAboutData );
253 connect( mBugReport, TQT_SIGNAL(finished()),
this,TQT_SLOT( dialogFinished()) );
260 if ( !d->mSwitchApplicationLanguage )
263 connect( d->mSwitchApplicationLanguage, TQT_SIGNAL(finished()),
this, TQT_SLOT( dialogFinished()) );
265 d->mSwitchApplicationLanguage->show();
269 void KHelpMenu::dialogFinished()
271 TQTimer::singleShot( 0,
this, TQT_SLOT(timerExpired()) );
275 void KHelpMenu::timerExpired()
277 if( mAboutKDE && !mAboutKDE->isVisible() )
279 delete mAboutKDE; mAboutKDE = 0;
282 if( mBugReport && !mBugReport->isVisible() )
284 delete mBugReport; mBugReport = 0;
287 if( mAboutApp && !mAboutApp->isVisible() )
289 delete mAboutApp; mAboutApp = 0;
292 if (d->mSwitchApplicationLanguage && !d->mSwitchApplicationLanguage->isVisible())
294 delete d->mSwitchApplicationLanguage; d->mSwitchApplicationLanguage = 0;
299 void KHelpMenu::menuDestroyed()
307 TQWhatsThis::enterWhatsThisMode();
308 TQWidget* w = TQApplication::widgetAt( TQCursor::pos(),
true );
309 while ( w && !w->isTopLevel() && !w->inherits(
"QXEmbed") )
310 w = w->parentWidget();
312 if ( w && w->inherits(
"QXEmbed") )
313 (( QXEmbed*) w )->enterWhatsThisMode();
317 void KHelpMenu::virtual_hook(
int,
void* )
321 #include "khelpmenu.moc" static int marginHint()
Return the number of pixels you shall use between a dialog edge and the outermost widget(s) according...
A managed set of KAction objects.
TQString programName() const
const KShortcut & shortcut(StdAccel id)
Standard "About KDE" dialog box,.
const KAboutData * aboutData() const
void disableResize()
Convenience method.
virtual void setPlainCaption(const TQString &caption)
Make a plain caption without any modifications.
KAction * helpContents(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Display the help contents.
A dialog base class with standard buttons and predefined layouts.
KAction * switchApplicationLanguage(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Display "Switch application language" dialog.
A dialog box for sending bug reports.
KAction * aboutApp(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Display the application's About box.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
KAction * reportBug(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Open up the Report Bug dialog.
void setMainWidget(TQWidget *widget)
Sets the main user definable widget.
Standard "About Application" dialog box.
Standard "switch application language" dialog box.
static KInstance * instance()
virtual void show(void)
Makes a modeless (modal = false in constructor) dialog visible.
KAction * whatsThis(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Trigger the What's This cursor.
KAction * aboutKDE(const TQObject *recvr, const char *slot, KActionCollection *parent, const char *name)
Display the About KDE dialog.
TQString bugAddress() const