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

kdeui

  • kdeui
kstdaction.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 1999,2000 Kurt Granroth <granroth@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "kstdaction.h"
20 
21 #include <tqtoolbutton.h>
22 #include <tqwhatsthis.h>
23 
24 #include <kaboutdata.h>
25 #include <kaction.h>
26 #include <kapplication.h>
27 #include <kdebug.h>
28 #include <kglobal.h>
29 #include <kiconloader.h>
30 #include <klocale.h>
31 #include <kstdaccel.h>
32 #include <kmainwindow.h>
33 #include "kstdaction_p.h"
34 
35 namespace KStdAction
36 {
37 
38 TQStringList stdNames()
39 {
40  return internal_stdNames();
41 }
42 
43 KAction* create( StdAction id, const char *name, const TQObject *recvr, const char *slot, KActionCollection* parent )
44 {
45  KAction* pAction = 0;
46  const KStdActionInfo* pInfo = infoPtr( id );
47  kdDebug(125) << "KStdAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << ", " << name << " )" << endl; // ellis
48  if( pInfo ) {
49  TQString sLabel, iconName = pInfo->psIconName;
50  switch( id ) {
51  case Back: sLabel = i18n("go back", "&Back");
52  if (TQApplication::reverseLayout() )
53  iconName = "forward";
54  break;
55 
56  case Forward: sLabel = i18n("go forward", "&Forward");
57  if (TQApplication::reverseLayout() )
58  iconName = "back";
59  break;
60 
61  case Home: sLabel = i18n("beginning (of line)", "&Home"); break;
62  case Help: sLabel = i18n("show help", "&Help"); break;
63  case AboutApp: iconName = kapp->miniIconName();
64  case Preferences:
65  case HelpContents:
66  {
67  const KAboutData *aboutData = KGlobal::instance()->aboutData();
68  /* TODO KDE4
69  const KAboutData *aboutData;
70  if ( parent )
71  aboutData = parent->instance()->aboutData();
72  else
73  aboutData = KGlobal::instance()->aboutData();
74  */
75  TQString appName = (aboutData) ? aboutData->programName() : TQString::fromLatin1(tqApp->name());
76  sLabel = i18n(pInfo->psLabel).arg(appName);
77  }
78  break;
79  default: sLabel = i18n(pInfo->psLabel);
80  }
81 
82  if (TQApplication::reverseLayout()){
83  if (id == Prior) iconName = "forward";
84  if (id == Next ) iconName = "back";
85  if (id == FirstPage) iconName = "finish";
86  if (id == LastPage) iconName = "start";
87  }
88 
89  KShortcut cut = KStdAccel::shortcut(pInfo->idAccel);
90  switch( id ) {
91  case OpenRecent:
92  pAction = new KRecentFilesAction( sLabel, pInfo->psIconName, cut,
93  recvr, slot,
94  parent, (name) ? name : pInfo->psName );
95  break;
96  case ShowMenubar:
97  case ShowToolbar:
98  case ShowStatusbar:
99  {
100  KToggleAction *ret;
101  ret = new KToggleAction( sLabel, pInfo->psIconName, cut,
102  recvr, slot,
103  parent, (name) ? name : pInfo->psName );
104  ret->setChecked( true );
105  pAction = ret;
106  break;
107  }
108  case FullScreen:
109  {
110  KToggleFullScreenAction *ret;
111  ret = new KToggleFullScreenAction( cut, recvr, slot,
112  parent, NULL, (name) ? name : pInfo->psName );
113  ret->setChecked( false );
114  pAction = ret;
115  break;
116  }
117  case PasteText:
118  {
119  KPasteTextAction *ret;
120  ret = new KPasteTextAction(sLabel, iconName, cut,
121  recvr, slot,
122  parent, (name) ? name : pInfo->psName );
123  pAction = ret;
124  break;
125  }
126  default:
127  pAction = new KAction( sLabel, iconName, cut,
128  recvr, slot,
129  parent, (name) ? name : pInfo->psName );
130  break;
131  }
132  }
133  return pAction;
134 }
135 
136 const char* name( StdAction id )
137 {
138  const KStdActionInfo* pInfo = infoPtr( id );
139  return (pInfo) ? pInfo->psName : 0;
140 }
141 
142 KAction *openNew( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
143  { return KStdAction::create( New, name, recvr, slot, parent ); }
144 KAction *open( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
145  { return KStdAction::create( Open, name, recvr, slot, parent ); }
146 KRecentFilesAction *openRecent( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
147  { return (KRecentFilesAction*) KStdAction::create( OpenRecent, name, recvr, slot, parent ); }
148 KAction *save( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
149  { return KStdAction::create( Save, name, recvr, slot, parent ); }
150 KAction *saveAs( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
151  { return KStdAction::create( SaveAs, name, recvr, slot, parent ); }
152 KAction *revert( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
153  { return KStdAction::create( Revert, name, recvr, slot, parent ); }
154 KAction *print( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
155  { return KStdAction::create( Print, name, recvr, slot, parent ); }
156 KAction *printPreview( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
157  { return KStdAction::create( PrintPreview, name, recvr, slot, parent ); }
158 KAction *close( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
159  { return KStdAction::create( Close, name, recvr, slot, parent ); }
160 KAction *mail( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
161  { return KStdAction::create( Mail, name, recvr, slot, parent ); }
162 KAction *quit( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
163  { return KStdAction::create( Quit, name, recvr, slot, parent ); }
164 KAction *undo( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
165  { return KStdAction::create( Undo, name, recvr, slot, parent ); }
166 KAction *redo( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
167  { return KStdAction::create( Redo, name, recvr, slot, parent ); }
168 KAction *cut( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
169  { return KStdAction::create( Cut, name, recvr, slot, parent ); }
170 KAction *copy( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
171  { return KStdAction::create( Copy, name, recvr, slot, parent ); }
172 KAction *paste( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
173  { return KStdAction::create( Paste, name, recvr, slot, parent ); }
174 KAction *pasteText( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
175  { return KStdAction::create( PasteText, name, recvr, slot, parent ); }
176 KAction *clear( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
177  { return KStdAction::create( Clear, name, recvr, slot, parent ); }
178 KAction *selectAll( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
179  { return KStdAction::create( SelectAll, name, recvr, slot, parent ); }
180 KAction *deselect( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
181  { return KStdAction::create( Deselect, name, recvr, slot, parent ); }
182 KAction *find( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
183  { return KStdAction::create( Find, name, recvr, slot, parent ); }
184 KAction *findNext( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
185  { return KStdAction::create( FindNext, name, recvr, slot, parent ); }
186 KAction *findPrev( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
187  { return KStdAction::create( FindPrev, name, recvr, slot, parent ); }
188 KAction *replace( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
189  { return KStdAction::create( Replace, name, recvr, slot, parent ); }
190 KAction *actualSize( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
191  { return KStdAction::create( ActualSize, name, recvr, slot, parent ); }
192 KAction *fitToPage( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
193  { return KStdAction::create( FitToPage, name, recvr, slot, parent ); }
194 KAction *fitToWidth( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
195  { return KStdAction::create( FitToWidth, name, recvr, slot, parent ); }
196 KAction *fitToHeight( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
197  { return KStdAction::create( FitToHeight, name, recvr, slot, parent ); }
198 KAction *zoomIn( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
199  { return KStdAction::create( ZoomIn, name, recvr, slot, parent ); }
200 KAction *zoomOut( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
201  { return KStdAction::create( ZoomOut, name, recvr, slot, parent ); }
202 KAction *zoom( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
203  { return KStdAction::create( Zoom, name, recvr, slot, parent ); }
204 KAction *redisplay( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
205  { return KStdAction::create( Redisplay, name, recvr, slot, parent ); }
206 KAction *up( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
207  { return KStdAction::create( Up, name, recvr, slot, parent ); }
208 KAction *back( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
209  { return KStdAction::create( Back, name, recvr, slot, parent ); }
210 KAction *forward( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
211  { return KStdAction::create( Forward, name, recvr, slot, parent ); }
212 KAction *home( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
213  { return KStdAction::create( Home, name, recvr, slot, parent ); }
214 KAction *prior( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
215  { return KStdAction::create( Prior, name, recvr, slot, parent ); }
216 KAction *next( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
217  { return KStdAction::create( Next, name, recvr, slot, parent ); }
218 KAction *goTo( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
219  { return KStdAction::create( Goto, name, recvr, slot, parent ); }
220 KAction *gotoPage( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
221  { return KStdAction::create( GotoPage, name, recvr, slot, parent ); }
222 KAction *gotoLine( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
223  { return KStdAction::create( GotoLine, name, recvr, slot, parent ); }
224 KAction *firstPage( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
225  { return KStdAction::create( FirstPage, name, recvr, slot, parent ); }
226 KAction *lastPage( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
227  { return KStdAction::create( LastPage, name, recvr, slot, parent ); }
228 KAction *addBookmark( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
229  { return KStdAction::create( AddBookmark, name, recvr, slot, parent ); }
230 KAction *editBookmarks( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
231  { return KStdAction::create( EditBookmarks, name, recvr, slot, parent ); }
232 KAction *spelling( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
233  { return KStdAction::create( Spelling, name, recvr, slot, parent ); }
234 
235 KToggleAction *showMenubar( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *_name )
236 {
237  KToggleAction *ret;
238  ret = new KToggleAction(i18n("Show &Menubar"), "showmenu", KStdAccel::shortcut(KStdAccel::ShowMenubar), recvr, slot,
239  parent, _name ? _name : name(ShowMenubar));
240  ret->setWhatsThis( i18n( "Show Menubar<p>"
241  "Shows the menubar again after it has been hidden" ) );
242  KGuiItem guiItem( i18n("Hide &Menubar"), 0 /*same icon*/, TQString::null,
243  i18n( "Hide Menubar<p>"
244  "Hide the menubar. You can usually get it back using the right mouse button inside the window itself." ) );
245  ret->setCheckedState( guiItem );
246  ret->setChecked(true);
247  return ret;
248 }
249 
250 // obsolete
251 KToggleAction *showToolbar( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *_name )
252 {
253  KToggleAction *ret;
254  ret = new KToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent,
255  _name ? _name : name(ShowToolbar));
256  ret->setChecked(true);
257  return ret;
258 
259 }
260 
261 // obsolete
262 KToggleToolBarAction *showToolbar( const char* toolBarName, KActionCollection* parent, const char *_name )
263 {
264  KToggleToolBarAction *ret;
265  ret = new KToggleToolBarAction(toolBarName, i18n("Show &Toolbar"), parent,
266  _name ? _name : name(ShowToolbar));
267  return ret;
268 }
269 
270 KToggleAction *showStatusbar( const TQObject *recvr, const char *slot,
271  KActionCollection* parent, const char *_name )
272 {
273  KToggleAction *ret;
274  ret = new KToggleAction(i18n("Show St&atusbar"), 0, recvr, slot, parent,
275  _name ? _name : name(ShowStatusbar));
276  ret->setWhatsThis( i18n( "Show Statusbar<p>"
277  "Shows the statusbar, which is the bar at the bottom of the window used for status information." ) );
278  KGuiItem guiItem( i18n("Hide St&atusbar"), TQString::null, TQString::null,
279  i18n( "Hide Statusbar<p>"
280  "Hides the statusbar, which is the bar at the bottom of the window used for status information." ) );
281  ret->setCheckedState( guiItem );
282 
283  ret->setChecked(true);
284  return ret;
285 }
286 
287 KToggleFullScreenAction *fullScreen( const TQObject *recvr, const char *slot, KActionCollection* parent,
288  TQWidget* window, const char *name )
289 {
290  KToggleFullScreenAction *ret;
291  ret = static_cast< KToggleFullScreenAction* >( KStdAction::create( FullScreen, name, recvr, slot, parent ));
292  ret->setWindow( window );
293  return ret;
294 }
295 
296 KAction *saveOptions( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
297  { return KStdAction::create( SaveOptions, name, recvr, slot, parent ); }
298 KAction *keyBindings( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
299  { return KStdAction::create( KeyBindings, name, recvr, slot, parent ); }
300 KAction *preferences( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
301  { return KStdAction::create( Preferences, name, recvr, slot, parent ); }
302 KAction *configureToolbars( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
303  { return KStdAction::create( ConfigureToolbars, name, recvr, slot, parent ); }
304 KAction *configureNotifications( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
305  { return KStdAction::create( ConfigureNotifications, name, recvr, slot, parent ); }
306 KAction *help( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
307  { return KStdAction::create( Help, name, recvr, slot, parent ); }
308 KAction *helpContents( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
309  { return KStdAction::create( HelpContents, name, recvr, slot, parent ); }
310 KAction *whatsThis( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
311  { return KStdAction::create( WhatsThis, name, recvr, slot, parent ); }
312 KAction *tipOfDay( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
313  { return KStdAction::create( TipofDay, name, recvr, slot, parent ); }
314 KAction *reportBug( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
315  { return KStdAction::create( ReportBug, name, recvr, slot, parent ); }
316 KAction *switchApplicationLanguage( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
317  { return KStdAction::create( SwitchApplicationLanguage, name, recvr, slot, parent ); }
318 KAction *aboutApp( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
319  { return KStdAction::create( AboutApp, name, recvr, slot, parent ); }
320 KAction *aboutKDE( const TQObject *recvr, const char *slot, KActionCollection* parent, const char *name )
321  { return KStdAction::create( AboutKDE, name, recvr, slot, parent ); }
322 
323 }

kdeui

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

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |