00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "kstdaction.h"
00020
00021 #include <tqtoolbutton.h>
00022 #include <tqwhatsthis.h>
00023
00024 #include <tdeaboutdata.h>
00025 #include <tdeaction.h>
00026 #include <tdeapplication.h>
00027 #include <kdebug.h>
00028 #include <tdeglobal.h>
00029 #include <kiconloader.h>
00030 #include <tdelocale.h>
00031 #include <tdestdaccel.h>
00032 #include <tdemainwindow.h>
00033 #include "kstdaction_p.h"
00034
00035 namespace KStdAction
00036 {
00037
00038 TQStringList stdNames()
00039 {
00040 return internal_stdNames();
00041 }
00042
00043 TDEAction* create( StdAction id, const char *name, const TQObject *recvr, const char *slot, TDEActionCollection* parent )
00044 {
00045 TDEAction* pAction = 0;
00046 const KStdActionInfo* pInfo = infoPtr( id );
00047 kdDebug(125) << "KStdAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << ", " << name << " )" << endl;
00048 if( pInfo ) {
00049 TQString sLabel, iconName = pInfo->psIconName;
00050 switch( id ) {
00051 case Back: sLabel = i18n("go back", "&Back");
00052 if (TQApplication::reverseLayout() )
00053 iconName = "forward";
00054 break;
00055
00056 case Forward: sLabel = i18n("go forward", "&Forward");
00057 if (TQApplication::reverseLayout() )
00058 iconName = "back";
00059 break;
00060
00061 case Home: sLabel = i18n("beginning (of line)", "&Home"); break;
00062 case Help: sLabel = i18n("show help", "&Help"); break;
00063 case AboutApp: iconName = kapp->miniIconName();
00064 case Preferences:
00065 case HelpContents:
00066 {
00067 const TDEAboutData *aboutData = TDEGlobal::instance()->aboutData();
00068
00069
00070
00071
00072
00073
00074
00075 TQString appName = (aboutData) ? aboutData->programName() : TQString::fromLatin1(tqApp->name());
00076 sLabel = i18n(pInfo->psLabel).arg(appName);
00077 }
00078 break;
00079 default: sLabel = i18n(pInfo->psLabel);
00080 }
00081
00082 if (TQApplication::reverseLayout()){
00083 if (id == Prior) iconName = "forward";
00084 if (id == Next ) iconName = "back";
00085 if (id == FirstPage) iconName = "go-last";
00086 if (id == LastPage) iconName = "go-first";
00087 }
00088
00089 TDEShortcut cut = TDEStdAccel::shortcut(pInfo->idAccel);
00090 switch( id ) {
00091 case OpenRecent:
00092 pAction = new TDERecentFilesAction( sLabel, pInfo->psIconName, cut,
00093 recvr, slot,
00094 parent, (name) ? name : pInfo->psName );
00095 break;
00096 case ShowMenubar:
00097 case ShowToolbar:
00098 case ShowStatusbar:
00099 {
00100 TDEToggleAction *ret;
00101 ret = new TDEToggleAction( sLabel, pInfo->psIconName, cut,
00102 recvr, slot,
00103 parent, (name) ? name : pInfo->psName );
00104 ret->setChecked( true );
00105 pAction = ret;
00106 break;
00107 }
00108 case FullScreen:
00109 {
00110 TDEToggleFullScreenAction *ret;
00111 ret = new TDEToggleFullScreenAction( cut, recvr, slot,
00112 parent, NULL, (name) ? name : pInfo->psName );
00113 ret->setChecked( false );
00114 pAction = ret;
00115 break;
00116 }
00117 case PasteText:
00118 {
00119 TDEPasteTextAction *ret;
00120 ret = new TDEPasteTextAction(sLabel, iconName, cut,
00121 recvr, slot,
00122 parent, (name) ? name : pInfo->psName );
00123 pAction = ret;
00124 break;
00125 }
00126 default:
00127 pAction = new TDEAction( sLabel, iconName, cut,
00128 recvr, slot,
00129 parent, (name) ? name : pInfo->psName );
00130 break;
00131 }
00132 }
00133 return pAction;
00134 }
00135
00136 const char* name( StdAction id )
00137 {
00138 const KStdActionInfo* pInfo = infoPtr( id );
00139 return (pInfo) ? pInfo->psName : 0;
00140 }
00141
00142 TDEAction *openNew( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00143 { return KStdAction::create( New, name, recvr, slot, parent ); }
00144 TDEAction *open( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00145 { return KStdAction::create( Open, name, recvr, slot, parent ); }
00146 TDERecentFilesAction *openRecent( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00147 { return (TDERecentFilesAction*) KStdAction::create( OpenRecent, name, recvr, slot, parent ); }
00148 TDEAction *save( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00149 { return KStdAction::create( Save, name, recvr, slot, parent ); }
00150 TDEAction *saveAs( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00151 { return KStdAction::create( SaveAs, name, recvr, slot, parent ); }
00152 TDEAction *revert( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00153 { return KStdAction::create( Revert, name, recvr, slot, parent ); }
00154 TDEAction *print( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00155 { return KStdAction::create( Print, name, recvr, slot, parent ); }
00156 TDEAction *printPreview( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00157 { return KStdAction::create( PrintPreview, name, recvr, slot, parent ); }
00158 TDEAction *close( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00159 { return KStdAction::create( Close, name, recvr, slot, parent ); }
00160 TDEAction *mail( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00161 { return KStdAction::create( Mail, name, recvr, slot, parent ); }
00162 TDEAction *quit( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00163 { return KStdAction::create( Quit, name, recvr, slot, parent ); }
00164 TDEAction *undo( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00165 { return KStdAction::create( Undo, name, recvr, slot, parent ); }
00166 TDEAction *redo( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00167 { return KStdAction::create( Redo, name, recvr, slot, parent ); }
00168 TDEAction *cut( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00169 { return KStdAction::create( Cut, name, recvr, slot, parent ); }
00170 TDEAction *copy( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00171 { return KStdAction::create( Copy, name, recvr, slot, parent ); }
00172 TDEAction *paste( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00173 { return KStdAction::create( Paste, name, recvr, slot, parent ); }
00174 TDEAction *pasteText( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00175 { return KStdAction::create( PasteText, name, recvr, slot, parent ); }
00176 TDEAction *clear( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00177 { return KStdAction::create( Clear, name, recvr, slot, parent ); }
00178 TDEAction *selectAll( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00179 { return KStdAction::create( SelectAll, name, recvr, slot, parent ); }
00180 TDEAction *deselect( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00181 { return KStdAction::create( Deselect, name, recvr, slot, parent ); }
00182 TDEAction *find( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00183 { return KStdAction::create( Find, name, recvr, slot, parent ); }
00184 TDEAction *findNext( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00185 { return KStdAction::create( FindNext, name, recvr, slot, parent ); }
00186 TDEAction *findPrev( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00187 { return KStdAction::create( FindPrev, name, recvr, slot, parent ); }
00188 TDEAction *replace( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00189 { return KStdAction::create( Replace, name, recvr, slot, parent ); }
00190 TDEAction *actualSize( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00191 { return KStdAction::create( ActualSize, name, recvr, slot, parent ); }
00192 TDEAction *fitToPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00193 { return KStdAction::create( FitToPage, name, recvr, slot, parent ); }
00194 TDEAction *fitToWidth( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00195 { return KStdAction::create( FitToWidth, name, recvr, slot, parent ); }
00196 TDEAction *fitToHeight( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00197 { return KStdAction::create( FitToHeight, name, recvr, slot, parent ); }
00198 TDEAction *zoomIn( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00199 { return KStdAction::create( ZoomIn, name, recvr, slot, parent ); }
00200 TDEAction *zoomOut( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00201 { return KStdAction::create( ZoomOut, name, recvr, slot, parent ); }
00202 TDEAction *zoom( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00203 { return KStdAction::create( Zoom, name, recvr, slot, parent ); }
00204 TDEAction *redisplay( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00205 { return KStdAction::create( Redisplay, name, recvr, slot, parent ); }
00206 TDEAction *up( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00207 { return KStdAction::create( Up, name, recvr, slot, parent ); }
00208 TDEAction *back( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00209 { return KStdAction::create( Back, name, recvr, slot, parent ); }
00210 TDEAction *forward( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00211 { return KStdAction::create( Forward, name, recvr, slot, parent ); }
00212 TDEAction *home( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00213 { return KStdAction::create( Home, name, recvr, slot, parent ); }
00214 TDEAction *prior( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00215 { return KStdAction::create( Prior, name, recvr, slot, parent ); }
00216 TDEAction *next( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00217 { return KStdAction::create( Next, name, recvr, slot, parent ); }
00218 TDEAction *goTo( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00219 { return KStdAction::create( Goto, name, recvr, slot, parent ); }
00220 TDEAction *gotoPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00221 { return KStdAction::create( GotoPage, name, recvr, slot, parent ); }
00222 TDEAction *gotoLine( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00223 { return KStdAction::create( GotoLine, name, recvr, slot, parent ); }
00224 TDEAction *firstPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00225 { return KStdAction::create( FirstPage, name, recvr, slot, parent ); }
00226 TDEAction *lastPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00227 { return KStdAction::create( LastPage, name, recvr, slot, parent ); }
00228 TDEAction *addBookmark( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00229 { return KStdAction::create( AddBookmark, name, recvr, slot, parent ); }
00230 TDEAction *editBookmarks( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00231 { return KStdAction::create( EditBookmarks, name, recvr, slot, parent ); }
00232 TDEAction *spelling( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00233 { return KStdAction::create( Spelling, name, recvr, slot, parent ); }
00234
00235 TDEToggleAction *showMenubar( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *_name )
00236 {
00237 TDEToggleAction *ret;
00238 ret = new TDEToggleAction(i18n("Show &Menubar"), "showmenu", TDEStdAccel::shortcut(TDEStdAccel::ShowMenubar), recvr, slot,
00239 parent, _name ? _name : name(ShowMenubar));
00240 ret->setWhatsThis( i18n( "Show Menubar<p>"
00241 "Shows the menubar again after it has been hidden" ) );
00242 KGuiItem guiItem( i18n("Hide &Menubar"), 0 , TQString::null,
00243 i18n( "Hide Menubar<p>"
00244 "Hide the menubar. You can usually get it back using the right mouse button inside the window itself." ) );
00245 ret->setCheckedState( guiItem );
00246 ret->setChecked(true);
00247 return ret;
00248 }
00249
00250
00251 TDEToggleAction *showToolbar( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *_name )
00252 {
00253 TDEToggleAction *ret;
00254 ret = new TDEToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent,
00255 _name ? _name : name(ShowToolbar));
00256 ret->setChecked(true);
00257 return ret;
00258
00259 }
00260
00261
00262 TDEToggleToolBarAction *showToolbar( const char* toolBarName, TDEActionCollection* parent, const char *_name )
00263 {
00264 TDEToggleToolBarAction *ret;
00265 ret = new TDEToggleToolBarAction(toolBarName, i18n("Show &Toolbar"), parent,
00266 _name ? _name : name(ShowToolbar));
00267 return ret;
00268 }
00269
00270 TDEToggleAction *showStatusbar( const TQObject *recvr, const char *slot,
00271 TDEActionCollection* parent, const char *_name )
00272 {
00273 TDEToggleAction *ret;
00274 ret = new TDEToggleAction(i18n("Show St&atusbar"), 0, recvr, slot, parent,
00275 _name ? _name : name(ShowStatusbar));
00276 ret->setWhatsThis( i18n( "Show Statusbar<p>"
00277 "Shows the statusbar, which is the bar at the bottom of the window used for status information." ) );
00278 KGuiItem guiItem( i18n("Hide St&atusbar"), TQString::null, TQString::null,
00279 i18n( "Hide Statusbar<p>"
00280 "Hides the statusbar, which is the bar at the bottom of the window used for status information." ) );
00281 ret->setCheckedState( guiItem );
00282
00283 ret->setChecked(true);
00284 return ret;
00285 }
00286
00287 TDEToggleFullScreenAction *fullScreen( const TQObject *recvr, const char *slot, TDEActionCollection* parent,
00288 TQWidget* window, const char *name )
00289 {
00290 TDEToggleFullScreenAction *ret;
00291 ret = static_cast< TDEToggleFullScreenAction* >( KStdAction::create( FullScreen, name, recvr, slot, parent ));
00292 ret->setWindow( window );
00293 return ret;
00294 }
00295
00296 TDEAction *saveOptions( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00297 { return KStdAction::create( SaveOptions, name, recvr, slot, parent ); }
00298 TDEAction *keyBindings( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00299 { return KStdAction::create( KeyBindings, name, recvr, slot, parent ); }
00300 TDEAction *preferences( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00301 { return KStdAction::create( Preferences, name, recvr, slot, parent ); }
00302 TDEAction *configureToolbars( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00303 { return KStdAction::create( ConfigureToolbars, name, recvr, slot, parent ); }
00304 TDEAction *configureNotifications( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00305 { return KStdAction::create( ConfigureNotifications, name, recvr, slot, parent ); }
00306 TDEAction *help( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00307 { return KStdAction::create( Help, name, recvr, slot, parent ); }
00308 TDEAction *helpContents( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00309 { return KStdAction::create( HelpContents, name, recvr, slot, parent ); }
00310 TDEAction *whatsThis( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00311 { return KStdAction::create( WhatsThis, name, recvr, slot, parent ); }
00312 TDEAction *tipOfDay( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00313 { return KStdAction::create( TipofDay, name, recvr, slot, parent ); }
00314 TDEAction *reportBug( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00315 { return KStdAction::create( ReportBug, name, recvr, slot, parent ); }
00316 TDEAction *switchApplicationLanguage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00317 { return KStdAction::create( SwitchApplicationLanguage, name, recvr, slot, parent ); }
00318 TDEAction *aboutApp( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00319 { return KStdAction::create( AboutApp, name, recvr, slot, parent ); }
00320 TDEAction *aboutKDE( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
00321 { return KStdAction::create( AboutKDE, name, recvr, slot, parent ); }
00322
00323 }