26 #include <tqtoolbutton.h>
27 #include <tqwhatsthis.h>
30 #include <tdeaboutapplication.h>
31 #include <tdeaboutdata.h>
32 #include <tdeabouttde.h>
33 #include <tdeaction.h>
34 #include <tdeapplication.h>
35 #include <kbugreport.h>
36 #include <kdialogbase.h>
37 #include <khelpmenu.h>
38 #include <kiconloader.h>
40 #include <tdemessagebox.h>
41 #include <tdepopupmenu.h>
42 #include <tdestdaccel.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->authorizeTDEAction(
"help_contents"))
131 TQString(i18n(
"%1 &Handbook" ).arg( appName)) ,menuHelpContents );
134 need_separator =
true;
137 if( mShowWhatsThis && kapp->authorizeTDEAction(
"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->authorizeTDEAction(
"help_report_bug") && aboutData && !aboutData->
bugAddress().isEmpty() )
150 mMenu->insertSeparator();
151 mMenu->insertItem( SmallIcon(
"bug"), i18n(
"&Report Bug/Request Enhancement..." ), menuReportBug );
152 mMenu->connectItem( menuReportBug,
this, TQT_SLOT(
reportBug()) );
153 need_separator =
true;
156 if (kapp->authorizeTDEAction(
"switch_application_language"))
159 mMenu->insertSeparator();
160 mMenu->insertItem( SmallIcon(
"locale"), i18n(
"Switch application &language..." ), menuSwitchLanguage );
162 need_separator =
true;
166 mMenu->insertSeparator();
168 if (kapp->authorizeTDEAction(
"help_about_app"))
170 mMenu->insertItem( kapp->miniIcon(),
171 TQString(i18n(
"&About %1" ).arg(appName)), menuAboutApp );
175 if (kapp->authorizeTDEAction(
"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 TDEAboutKDE( 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"