• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
khelpmenu.cpp
1 /*
2  * This file is part of the KDE Libraries
3  * Copyright (C) 1999-2000 Espen Sand (espen@kde.org)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 // I (espen) prefer that header files are included alphabetically
23 #include <tqhbox.h>
24 #include <tqlabel.h>
25 #include <tqtimer.h>
26 #include <tqtoolbutton.h>
27 #include <tqwhatsthis.h>
28 #include <tqwidget.h>
29 
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>
39 #include <tdelocale.h>
40 #include <tdemessagebox.h>
41 #include <tdepopupmenu.h>
42 #include <tdestdaccel.h>
43 #include <kstdaction.h>
44 #include <kstandarddirs.h>
45 
46 #include "kswitchlanguagedialog.h"
47 
48 #include "config.h"
49 #include <qxembed.h>
50 
51 class KHelpMenuPrivate
52 {
53 public:
54  KHelpMenuPrivate():mSwitchApplicationLanguage(NULL)
55  {
56  }
57  ~KHelpMenuPrivate()
58  {
59  delete mSwitchApplicationLanguage;
60  }
61 
62  const TDEAboutData *mAboutData;
63  KSwitchLanguageDialog *mSwitchApplicationLanguage;
64 };
65 
66 KHelpMenu::KHelpMenu( TQWidget *parent, const TQString &aboutAppText,
67  bool showWhatsThis )
68  : TQObject(parent), mMenu(0), mAboutApp(0), mAboutKDE(0), mBugReport(0),
69  d(new KHelpMenuPrivate)
70 {
71  mParent = parent;
72  mAboutAppText = aboutAppText;
73  mShowWhatsThis = showWhatsThis;
74  d->mAboutData = 0;
75 }
76 
77 KHelpMenu::KHelpMenu( TQWidget *parent, const TDEAboutData *aboutData,
78  bool showWhatsThis, TDEActionCollection *actions )
79  : TQObject(parent), mMenu(0), mAboutApp(0), mAboutKDE(0), mBugReport(0),
80  d(new KHelpMenuPrivate)
81 {
82  mParent = parent;
83  mShowWhatsThis = showWhatsThis;
84 
85  d->mAboutData = aboutData;
86 
87  if (!aboutData)
88  mAboutAppText = TQString::null;
89 
90  if (actions)
91  {
92  KStdAction::helpContents(this, TQ_SLOT(appHelpActivated()), actions);
93  if (showWhatsThis)
94  KStdAction::whatsThis(this, TQ_SLOT(contextHelpActivated()), actions);
95  KStdAction::reportBug(this, TQ_SLOT(reportBug()), actions);
96  KStdAction::aboutApp(this, TQ_SLOT(aboutApplication()), actions);
97  KStdAction::aboutKDE(this, TQ_SLOT(aboutKDE()), actions);
98  KStdAction::switchApplicationLanguage(this, TQ_SLOT(switchApplicationLanguage()), actions);
99  }
100 }
101 
102 KHelpMenu::~KHelpMenu()
103 {
104  delete mMenu;
105  delete mAboutApp;
106  delete mAboutKDE;
107  delete mBugReport;
108  delete d;
109 }
110 
111 
112 TDEPopupMenu* KHelpMenu::menu()
113 {
114  if( !mMenu )
115  {
116  //
117  // 1999-12-02 Espen Sand:
118  // I use hardcoded menu id's here. Reason is to stay backward
119  // compatible.
120  //
121  const TDEAboutData *aboutData = d->mAboutData ? d->mAboutData : TDEGlobal::instance()->aboutData();
122  TQString appName = (aboutData)? aboutData->programName() : TQString::fromLatin1(tqApp->name());
123 
124  mMenu = new TDEPopupMenu();
125  connect( mMenu, TQ_SIGNAL(destroyed()), this, TQ_SLOT(menuDestroyed()));
126 
127  bool need_separator = false;
128  if (kapp->authorizeTDEAction("help_contents"))
129  {
130  mMenu->insertItem( BarIcon( "contents", TDEIcon::SizeSmall),
131  TQString(i18n( "%1 &Handbook" ).arg( appName)) ,menuHelpContents );
132  mMenu->connectItem( menuHelpContents, this, TQ_SLOT(appHelpActivated()) );
133  mMenu->setAccel( TDEStdAccel::shortcut(TDEStdAccel::Help), menuHelpContents );
134  need_separator = true;
135  }
136 
137  if( mShowWhatsThis && kapp->authorizeTDEAction("help_whats_this") )
138  {
139  TQToolButton* wtb = TQWhatsThis::whatsThisButton(0);
140  mMenu->insertItem( wtb->iconSet(),i18n( "What's &This" ), menuWhatsThis);
141  mMenu->connectItem( menuWhatsThis, this, TQ_SLOT(contextHelpActivated()) );
142  delete wtb;
143  mMenu->setAccel( SHIFT + Key_F1, menuWhatsThis );
144  need_separator = true;
145  }
146 
147  if (kapp->authorizeTDEAction("help_report_bug") && aboutData && !aboutData->bugAddress().isEmpty() )
148  {
149  if (need_separator)
150  mMenu->insertSeparator();
151  mMenu->insertItem( SmallIcon("bug"), i18n( "&Report Bug/Request Enhancement..." ), menuReportBug );
152  mMenu->connectItem( menuReportBug, this, TQ_SLOT(reportBug()) );
153  need_separator = true;
154  }
155 
156  if (kapp->authorizeTDEAction("switch_application_language"))
157  {
158  if (need_separator)
159  mMenu->insertSeparator();
160  mMenu->insertItem( SmallIcon("locale"), i18n( "Switch application &language..." ), menuSwitchLanguage );
161  mMenu->connectItem( menuSwitchLanguage, this, TQ_SLOT(switchApplicationLanguage()) );
162  need_separator = true;
163  }
164 
165  if (need_separator)
166  mMenu->insertSeparator();
167 
168  if (kapp->authorizeTDEAction("help_about_app"))
169  {
170  mMenu->insertItem( kapp->miniIcon(),
171  TQString(i18n( "&About %1" ).arg(appName)), menuAboutApp );
172  mMenu->connectItem( menuAboutApp, this, TQ_SLOT( aboutApplication() ) );
173  }
174 
175  if (kapp->authorizeTDEAction("help_about_kde"))
176  {
177  mMenu->insertItem( SmallIcon("about_kde"), i18n( "About &TDE" ), menuAboutKDE );
178  mMenu->connectItem( menuAboutKDE, this, TQ_SLOT( aboutKDE() ) );
179  }
180  }
181 
182  return mMenu;
183 }
184 
185 
186 
187 void KHelpMenu::appHelpActivated()
188 {
189  kapp->invokeHelp();
190 }
191 
192 
193 void KHelpMenu::aboutApplication()
194 {
195  if (d->mAboutData)
196  {
197  if( !mAboutApp )
198  {
199  mAboutApp = new TDEAboutApplication( d->mAboutData, mParent, "about", false );
200  connect( mAboutApp, TQ_SIGNAL(finished()), this, TQ_SLOT( dialogFinished()) );
201  }
202  mAboutApp->show();
203  }
204  else if( mAboutAppText.isEmpty() )
205  {
206  emit showAboutApplication();
207  }
208  else
209  {
210  if( !mAboutApp )
211  {
212  mAboutApp = new KDialogBase( TQString::null, // Caption is defined below
213  KDialogBase::Yes, KDialogBase::Yes,
214  KDialogBase::Yes, mParent, "about",
215  false, true, KStdGuiItem::ok() );
216  connect( mAboutApp, TQ_SIGNAL(finished()), this, TQ_SLOT( dialogFinished()) );
217 
218  TQHBox *hbox = new TQHBox( mAboutApp );
219  mAboutApp->setMainWidget( hbox );
220  hbox->setSpacing(KDialog::spacingHint()*3);
221  hbox->setMargin(KDialog::marginHint()*1);
222 
223  TQLabel *label1 = new TQLabel(hbox);
224  label1->setPixmap( kapp->icon() );
225  TQLabel *label2 = new TQLabel(hbox);
226  label2->setText( mAboutAppText );
227 
228  mAboutApp->setPlainCaption( i18n("About %1").arg(kapp->caption()) );
229  mAboutApp->disableResize();
230  }
231 
232  mAboutApp->show();
233  }
234 }
235 
236 
237 void KHelpMenu::aboutKDE()
238 {
239  if( !mAboutKDE )
240  {
241  mAboutKDE = new TDEAboutKDE( mParent, "aboutkde", false );
242  connect( mAboutKDE, TQ_SIGNAL(finished()), this, TQ_SLOT( dialogFinished()) );
243  }
244  mAboutKDE->show();
245 }
246 
247 
248 void KHelpMenu::reportBug()
249 {
250  if( !mBugReport )
251  {
252  mBugReport = new KBugReport( mParent, false, d->mAboutData );
253  connect( mBugReport, TQ_SIGNAL(finished()),this,TQ_SLOT( dialogFinished()) );
254  }
255  mBugReport->show();
256 }
257 
258 void KHelpMenu::switchApplicationLanguage()
259 {
260  if ( !d->mSwitchApplicationLanguage )
261  {
262  d->mSwitchApplicationLanguage = new KSwitchLanguageDialog( mParent, "switchlanguagedialog", false );
263  connect( d->mSwitchApplicationLanguage, TQ_SIGNAL(finished()), this, TQ_SLOT( dialogFinished()) );
264  }
265  d->mSwitchApplicationLanguage->show();
266 }
267 
268 
269 void KHelpMenu::dialogFinished()
270 {
271  TQTimer::singleShot( 0, this, TQ_SLOT(timerExpired()) );
272 }
273 
274 
275 void KHelpMenu::timerExpired()
276 {
277  if( mAboutKDE && !mAboutKDE->isVisible() )
278  {
279  delete mAboutKDE; mAboutKDE = 0;
280  }
281 
282  if( mBugReport && !mBugReport->isVisible() )
283  {
284  delete mBugReport; mBugReport = 0;
285  }
286 
287  if( mAboutApp && !mAboutApp->isVisible() )
288  {
289  delete mAboutApp; mAboutApp = 0;
290  }
291 
292  if (d->mSwitchApplicationLanguage && !d->mSwitchApplicationLanguage->isVisible())
293  {
294  delete d->mSwitchApplicationLanguage; d->mSwitchApplicationLanguage = 0;
295  }
296 }
297 
298 
299 void KHelpMenu::menuDestroyed()
300 {
301  mMenu = 0;
302 }
303 
304 
305 void KHelpMenu::contextHelpActivated()
306 {
307  TQWhatsThis::enterWhatsThisMode();
308  TQWidget* w = TQApplication::widgetAt( TQCursor::pos(), true );
309  while ( w && !w->isTopLevel() && !w->inherits("QXEmbed") )
310  w = w->parentWidget();
311 #ifdef TQ_WS_X11
312  if ( w && w->inherits("QXEmbed") )
313  (( QXEmbed*) w )->enterWhatsThisMode();
314 #endif
315 }
316 
317 void KHelpMenu::virtual_hook( int, void* )
318 { /*BASE::virtual_hook( id, data );*/ }
319 
320 
321 #include "khelpmenu.moc"
KBugReport
A dialog box for sending bug reports.
Definition: kbugreport.h:44
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:192
KDialogBase::setMainWidget
void setMainWidget(TQWidget *widget)
Sets the main user definable widget.
Definition: kdialogbase.cpp:1431
KDialogBase::Yes
@ Yes
Show Yes button.
Definition: kdialogbase.h:210
KDialogBase::disableResize
void disableResize()
Convenience method.
Definition: kdialogbase.cpp:531
KDialog::marginHint
static int marginHint()
Return the number of pixels you shall use between a dialog edge and the outermost widget(s) according...
Definition: kdialog.cpp:104
KDialog::setPlainCaption
virtual void setPlainCaption(const TQString &caption)
Make a plain caption without any modifications.
Definition: kdialog.cpp:129
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:110
KHelpMenu::showAboutApplication
void showAboutApplication()
This signal is emitted from aboutApplication() if no "about application" string has been defined.
KHelpMenu::appHelpActivated
void appHelpActivated()
Opens the help page for the application.
Definition: khelpmenu.cpp:187
KHelpMenu::contextHelpActivated
void contextHelpActivated()
Activates What's This help for the application.
Definition: khelpmenu.cpp:305
KHelpMenu::aboutKDE
void aboutKDE()
Opens the standard "About KDE" dialog box.
Definition: khelpmenu.cpp:237
KHelpMenu::~KHelpMenu
~KHelpMenu()
Destructor.
Definition: khelpmenu.cpp:102
KHelpMenu::switchApplicationLanguage
void switchApplicationLanguage()
Opens changing default application language dialog box.
Definition: khelpmenu.cpp:258
KHelpMenu::reportBug
void reportBug()
Opens the standard "Report Bugs" dialog box.
Definition: khelpmenu.cpp:248
KHelpMenu::menu
TDEPopupMenu * menu()
Returns a popup menu you can use in the menu bar or where you need it.
Definition: khelpmenu.cpp:112
KHelpMenu::aboutApplication
void aboutApplication()
Opens an application specific dialog box.
Definition: khelpmenu.cpp:193
KHelpMenu::KHelpMenu
KHelpMenu(TQWidget *parent=0, const TQString &aboutAppText=TQString::null, bool showWhatsThis=true)
Constructor.
Definition: khelpmenu.cpp:66
KSwitchLanguageDialog
Standard "switch application language" dialog box.
Definition: kswitchlanguagedialog.h:39
TDEAboutApplication
Standard "About Application" dialog box.
Definition: tdeaboutapplication.h:45
TDEAboutData
TDEAboutData::bugAddress
TQString bugAddress() const
TDEAboutData::programName
TQString programName() const
TDEAboutDialog::show
virtual void show(void)
Makes a modeless (modal = false in constructor) dialog visible.
Definition: tdeaboutdialog.cpp:1549
TDEAboutKDE
Standard "About KDE" dialog box,.
Definition: tdeabouttde.h:41
TDEActionCollection
A managed set of TDEAction objects.
Definition: tdeactioncollection.h:79
TDEGlobal::instance
static TDEInstance * instance()
TDEIcon::SizeSmall
SizeSmall
TDEInstance::aboutData
const TDEAboutData * aboutData() const
TDEPopupMenu
A menu with title items.
Definition: tdepopupmenu.h:123
KStdAction::whatsThis
TDEAction * whatsThis(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Trigger the What's This cursor.
Definition: kstdaction.cpp:310
KStdAction::aboutKDE
TDEAction * aboutKDE(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Display the About KDE dialog.
Definition: kstdaction.cpp:320
KStdAction::helpContents
TDEAction * helpContents(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Display the help contents.
Definition: kstdaction.cpp:308
KStdAction::switchApplicationLanguage
TDEAction * switchApplicationLanguage(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Display "Switch application language" dialog.
Definition: kstdaction.cpp:316
KStdAction::aboutApp
TDEAction * aboutApp(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Display the application's About box.
Definition: kstdaction.cpp:318
KStdAction::reportBug
TDEAction * reportBug(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Open up the Report Bug dialog.
Definition: kstdaction.cpp:314
TDEStdAccel::shortcut
const TDEShortcut & shortcut(StdAccel id)
tdelocale.h

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.1
This website is maintained by Timothy Pearson.