summaryrefslogtreecommitdiffstats
path: root/tdeui/kstdaction.cpp
blob: 41c7e72ea8a4cd2283279cf786ec2559d0c66baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/* This file is part of the KDE libraries
   Copyright (C) 1999,2000 Kurt Granroth <granroth@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include "kstdaction.h"

#include <tqtoolbutton.h>
#include <tqwhatsthis.h>

#include <kaboutdata.h>
#include <kaction.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kstdaccel.h>
#include <kmainwindow.h>
#include "kstdaction_p.h"

namespace KStdAction
{

TQStringList stdNames()
{
    return internal_stdNames();
}

TDEAction* create( StdAction id, const char *name, const TQObject *recvr, const char *slot, TDEActionCollection* parent )
{
	TDEAction* pAction = 0;
	const KStdActionInfo* pInfo = infoPtr( id );
	kdDebug(125) << "KStdAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << ", " << name << " )" << endl; // ellis
	if( pInfo ) {
		TQString sLabel, iconName = pInfo->psIconName;
		switch( id ) {
		 case Back: sLabel = i18n("go back", "&Back");
			if (TQApplication::reverseLayout() )
			    iconName = "forward";
			break;

		 case Forward: sLabel = i18n("go forward", "&Forward");
			if (TQApplication::reverseLayout() )
			    iconName = "back";
			break;

		 case Home: sLabel = i18n("beginning (of line)", "&Home"); break;
		 case Help: sLabel = i18n("show help", "&Help"); break;
		 case AboutApp: iconName = kapp->miniIconName();
		 case Preferences:
		 case HelpContents:
			{
			const TDEAboutData *aboutData = TDEGlobal::instance()->aboutData();
			/* TODO KDE4
			const TDEAboutData *aboutData;
			if ( parent )
			    aboutData = parent->instance()->aboutData();
			else
			    aboutData = TDEGlobal::instance()->aboutData();
			*/
			TQString appName = (aboutData) ? aboutData->programName() : TQString::fromLatin1(tqApp->name());
			sLabel = i18n(pInfo->psLabel).arg(appName);
			}
			break;
		 default: sLabel = i18n(pInfo->psLabel);
		}

		if (TQApplication::reverseLayout()){
			if (id == Prior) iconName = "forward";
			if (id == Next ) iconName = "back";
			if (id == FirstPage) iconName = "finish";
			if (id == LastPage) iconName = "start";
		}

		TDEShortcut cut = TDEStdAccel::shortcut(pInfo->idAccel);
		switch( id ) {
		 case OpenRecent:
			pAction = new TDERecentFilesAction( sLabel, pInfo->psIconName, cut,
					recvr, slot,
					parent, (name) ? name : pInfo->psName );
			break;
		 case ShowMenubar:
		 case ShowToolbar:
		 case ShowStatusbar:
		 {
			TDEToggleAction *ret;
			ret = new TDEToggleAction( sLabel, pInfo->psIconName, cut,
					recvr, slot,
					parent, (name) ? name : pInfo->psName );
			ret->setChecked( true );
			pAction = ret;
			break;
		 }
		 case FullScreen:
		 {
			TDEToggleFullScreenAction *ret;
			ret = new TDEToggleFullScreenAction( cut, recvr, slot,
					parent, NULL, (name) ? name : pInfo->psName );
			ret->setChecked( false );
			pAction = ret;
			break;
		 }
         case PasteText:
         {
            TDEPasteTextAction *ret;
            ret = new TDEPasteTextAction(sLabel, iconName, cut,
					recvr, slot,
					parent, (name) ? name : pInfo->psName );
            pAction = ret;
            break;
         }
		 default:
			pAction = new TDEAction( sLabel, iconName, cut,
					recvr, slot,
					parent, (name) ? name : pInfo->psName );
			break;
		}
	}
	return pAction;
}

const char* name( StdAction id )
{
	const KStdActionInfo* pInfo = infoPtr( id );
	return (pInfo) ? pInfo->psName : 0;
}

TDEAction *openNew( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( New, name, recvr, slot, parent ); }
TDEAction *open( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Open, name, recvr, slot, parent ); }
TDERecentFilesAction *openRecent( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return (TDERecentFilesAction*) KStdAction::create( OpenRecent, name, recvr, slot, parent ); }
TDEAction *save( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Save, name, recvr, slot, parent ); }
TDEAction *saveAs( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( SaveAs, name, recvr, slot, parent ); }
TDEAction *revert( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Revert, name, recvr, slot, parent ); }
TDEAction *print( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Print, name, recvr, slot, parent ); }
TDEAction *printPreview( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( PrintPreview, name, recvr, slot, parent ); }
TDEAction *close( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Close, name, recvr, slot, parent ); }
TDEAction *mail( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Mail, name, recvr, slot, parent ); }
TDEAction *quit( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Quit, name, recvr, slot, parent ); }
TDEAction *undo( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Undo, name, recvr, slot, parent ); }
TDEAction *redo( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Redo, name, recvr, slot, parent ); }
TDEAction *cut( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Cut, name, recvr, slot, parent ); }
TDEAction *copy( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Copy, name, recvr, slot, parent ); }
TDEAction *paste( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Paste, name, recvr, slot, parent ); }
TDEAction *pasteText( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( PasteText, name, recvr, slot, parent ); }
TDEAction *clear( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Clear, name, recvr, slot, parent ); }
TDEAction *selectAll( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( SelectAll, name, recvr, slot, parent ); }
TDEAction *deselect( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Deselect, name, recvr, slot, parent ); }
TDEAction *find( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Find, name, recvr, slot, parent ); }
TDEAction *findNext( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( FindNext, name, recvr, slot, parent ); }
TDEAction *findPrev( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( FindPrev, name, recvr, slot, parent ); }
TDEAction *replace( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Replace, name, recvr, slot, parent ); }
TDEAction *actualSize( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( ActualSize, name, recvr, slot, parent ); }
TDEAction *fitToPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( FitToPage, name, recvr, slot, parent ); }
TDEAction *fitToWidth( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( FitToWidth, name, recvr, slot, parent ); }
TDEAction *fitToHeight( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( FitToHeight, name, recvr, slot, parent ); }
TDEAction *zoomIn( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( ZoomIn, name, recvr, slot, parent ); }
TDEAction *zoomOut( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( ZoomOut, name, recvr, slot, parent ); }
TDEAction *zoom( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Zoom, name, recvr, slot, parent ); }
TDEAction *redisplay( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Redisplay, name, recvr, slot, parent ); }
TDEAction *up( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Up, name, recvr, slot, parent ); }
TDEAction *back( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Back, name, recvr, slot, parent ); }
TDEAction *forward( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Forward, name, recvr, slot, parent ); }
TDEAction *home( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Home, name, recvr, slot, parent ); }
TDEAction *prior( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Prior, name, recvr, slot, parent ); }
TDEAction *next( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Next, name, recvr, slot, parent ); }
TDEAction *goTo( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Goto, name, recvr, slot, parent ); }
TDEAction *gotoPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( GotoPage, name, recvr, slot, parent ); }
TDEAction *gotoLine( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( GotoLine, name, recvr, slot, parent ); }
TDEAction *firstPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( FirstPage, name, recvr, slot, parent ); }
TDEAction *lastPage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( LastPage, name, recvr, slot, parent ); }
TDEAction *addBookmark( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( AddBookmark, name, recvr, slot, parent ); }
TDEAction *editBookmarks( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( EditBookmarks, name, recvr, slot, parent ); }
TDEAction *spelling( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Spelling, name, recvr, slot, parent ); }

TDEToggleAction *showMenubar( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *_name )
{
    TDEToggleAction *ret;
    ret = new TDEToggleAction(i18n("Show &Menubar"), "showmenu", TDEStdAccel::shortcut(TDEStdAccel::ShowMenubar), recvr, slot,
                            parent, _name ? _name : name(ShowMenubar));
    ret->setWhatsThis( i18n( "Show Menubar<p>"
                             "Shows the menubar again after it has been hidden" ) );
    KGuiItem guiItem( i18n("Hide &Menubar"), 0 /*same icon*/, TQString::null,
                      i18n( "Hide Menubar<p>"
                            "Hide the menubar. You can usually get it back using the right mouse button inside the window itself." ) );
    ret->setCheckedState( guiItem );
    ret->setChecked(true);
    return ret;
}

// obsolete
TDEToggleAction *showToolbar( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *_name )
{
    TDEToggleAction *ret;
    ret = new TDEToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent,
                            _name ? _name : name(ShowToolbar));
    ret->setChecked(true);
    return ret;

}

// obsolete
TDEToggleToolBarAction *showToolbar( const char* toolBarName, TDEActionCollection* parent, const char *_name )
{
    TDEToggleToolBarAction *ret;
    ret = new TDEToggleToolBarAction(toolBarName, i18n("Show &Toolbar"), parent,
                            _name ? _name : name(ShowToolbar));
    return ret;
}

TDEToggleAction *showStatusbar( const TQObject *recvr, const char *slot,
                                         TDEActionCollection* parent, const char *_name )
{
    TDEToggleAction *ret;
    ret = new TDEToggleAction(i18n("Show St&atusbar"), 0, recvr, slot, parent,
                            _name ? _name : name(ShowStatusbar));
    ret->setWhatsThis( i18n( "Show Statusbar<p>"
                             "Shows the statusbar, which is the bar at the bottom of the window used for status information." ) );
    KGuiItem guiItem( i18n("Hide St&atusbar"), TQString::null, TQString::null,
                      i18n( "Hide Statusbar<p>"
                            "Hides the statusbar, which is the bar at the bottom of the window used for status information." ) );
    ret->setCheckedState( guiItem );

    ret->setChecked(true);
    return ret;
}

TDEToggleFullScreenAction *fullScreen( const TQObject *recvr, const char *slot, TDEActionCollection* parent,
    TQWidget* window, const char *name )
{
    TDEToggleFullScreenAction *ret;
    ret = static_cast< TDEToggleFullScreenAction* >( KStdAction::create( FullScreen, name, recvr, slot, parent ));
    ret->setWindow( window );
    return ret;
}

TDEAction *saveOptions( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( SaveOptions, name, recvr, slot, parent ); }
TDEAction *keyBindings( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( KeyBindings, name, recvr, slot, parent ); }
TDEAction *preferences( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Preferences, name, recvr, slot, parent ); }
TDEAction *configureToolbars( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( ConfigureToolbars, name, recvr, slot, parent ); }
TDEAction *configureNotifications( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( ConfigureNotifications, name, recvr, slot, parent ); }
TDEAction *help( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( Help, name, recvr, slot, parent ); }
TDEAction *helpContents( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( HelpContents, name, recvr, slot, parent ); }
TDEAction *whatsThis( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( WhatsThis, name, recvr, slot, parent ); }
TDEAction *tipOfDay( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( TipofDay, name, recvr, slot, parent ); }
TDEAction *reportBug( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( ReportBug, name, recvr, slot, parent ); }
TDEAction *switchApplicationLanguage( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( SwitchApplicationLanguage, name, recvr, slot, parent ); }
TDEAction *aboutApp( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( AboutApp, name, recvr, slot, parent ); }
TDEAction *aboutKDE( const TQObject *recvr, const char *slot, TDEActionCollection* parent, const char *name )
	{ return KStdAction::create( AboutKDE, name, recvr, slot, parent ); }

}