~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to kdeui/kstdaction_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#ifndef KSTDACTION_PRIVATE_H
20
 
#define KSTDACTION_PRIVATE_H
21
 
 
22
 
#include <QtGui/QApplication>
23
 
 
24
 
#include <kaction.h>
25
 
#include <klocale.h>
26
 
#include <kstdaccel.h>
27
 
 
28
 
namespace KStdAction
29
 
{
30
 
 
31
 
struct KStdActionInfo
32
 
{
33
 
  StdAction id;
34
 
  KStdAccel::StdAccel idAccel;
35
 
  const char* psName;
36
 
  const char* psLabel;
37
 
  const char* psWhatsThis;
38
 
  const char* psIconName;
39
 
};
40
 
 
41
 
static const KStdActionInfo g_rgActionInfo[] =
42
 
{
43
 
  { New,           KStdAccel::New, "file_new", I18N_NOOP("&New"), 0, "filenew" },
44
 
  { Open,          KStdAccel::Open, "file_open", I18N_NOOP("&Open..."), 0, "fileopen" },
45
 
  { OpenRecent,    KStdAccel::AccelNone, "file_open_recent", I18N_NOOP("Open &Recent"), 0, "fileopen" },
46
 
  { Save,          KStdAccel::Save, "file_save", I18N_NOOP("&Save"), 0, "filesave" },
47
 
  { SaveAs,        KStdAccel::AccelNone, "file_save_as", I18N_NOOP("Save &As..."), 0, "filesaveas" },
48
 
  { Revert,        KStdAccel::AccelNone, "file_revert", I18N_NOOP("Re&vert"), 0, "revert" },
49
 
  { Close,         KStdAccel::Close, "file_close", I18N_NOOP("&Close"), 0, "fileclose" },
50
 
  { Print,         KStdAccel::Print, "file_print", I18N_NOOP("&Print..."), 0, "fileprint" },
51
 
  { PrintPreview,  KStdAccel::AccelNone, "file_print_preview", I18N_NOOP("Print Previe&w..."), 0, "filequickprint" },
52
 
  { Mail,          KStdAccel::AccelNone, "file_mail", I18N_NOOP("&Mail..."), 0, "mail_send" },
53
 
  { Quit,          KStdAccel::Quit, "file_quit", I18N_NOOP("&Quit"), 0, "exit" },
54
 
 
55
 
  { Undo,          KStdAccel::Undo, "edit_undo", I18N_NOOP("&Undo"), 0, "undo" },
56
 
  { Redo,          KStdAccel::Redo, "edit_redo", I18N_NOOP("Re&do"), 0, "redo" },
57
 
  { Cut,           KStdAccel::Cut, "edit_cut", I18N_NOOP("Cu&t"), 0, "editcut" },
58
 
  { Copy,          KStdAccel::Copy, "edit_copy", I18N_NOOP("&Copy"), 0, "editcopy" },
59
 
  { Paste,         KStdAccel::Paste, "edit_paste", I18N_NOOP("&Paste"), 0, "editpaste" },
60
 
  { PasteText,     KStdAccel::Paste, "edit_paste", I18N_NOOP("&Paste"), 0, "editpaste" },
61
 
  { Clear,         KStdAccel::AccelNone, "edit_clear", I18N_NOOP("C&lear"), 0, "editclear" },
62
 
  { SelectAll,     KStdAccel::SelectAll, "edit_select_all", I18N_NOOP("Select &All"), 0, 0 },
63
 
  { Deselect,      KStdAccel::Deselect, "edit_deselect", I18N_NOOP("Dese&lect"), 0, 0 },
64
 
  { Find,          KStdAccel::Find, "edit_find", I18N_NOOP("&Find..."), 0, "find" },
65
 
  { FindNext,      KStdAccel::FindNext, "edit_find_next", I18N_NOOP("Find &Next"), 0, "next" },
66
 
  { FindPrev,      KStdAccel::FindPrev, "edit_find_prev", I18N_NOOP("Find Pre&vious"), 0, "previous" },
67
 
  { Replace,       KStdAccel::Replace, "edit_replace", I18N_NOOP("&Replace..."), 0, 0 },
68
 
 
69
 
  { ActualSize,    KStdAccel::AccelNone, "view_actual_size", I18N_NOOP("&Actual Size"), 0, 0 },
70
 
  { FitToPage,     KStdAccel::AccelNone, "view_fit_to_page", I18N_NOOP("&Fit to Page"), 0, 0 },
71
 
  { FitToWidth,    KStdAccel::AccelNone, "view_fit_to_width", I18N_NOOP("Fit to Page &Width"), 0, 0 },
72
 
  { FitToHeight,   KStdAccel::AccelNone, "view_fit_to_height", I18N_NOOP("Fit to Page &Height"), 0, 0 },
73
 
  { ZoomIn,        KStdAccel::ZoomIn, "view_zoom_in", I18N_NOOP("Zoom &In"), 0, "viewmag+" },
74
 
  { ZoomOut,       KStdAccel::ZoomOut, "view_zoom_out", I18N_NOOP("Zoom &Out"), 0, "viewmag-" },
75
 
  { Zoom,          KStdAccel::AccelNone, "view_zoom", I18N_NOOP("&Zoom..."), 0, "viewmag" },
76
 
        // KDE4: give Redisplay the shortcut KStdAccel::AccelReload
77
 
  { Redisplay,     KStdAccel::AccelNone, "view_redisplay", I18N_NOOP("&Redisplay"), 0, "reload" },
78
 
 
79
 
  { Up,            KStdAccel::Up, "go_up", I18N_NOOP("&Up"), 0, "up" },
80
 
  // The following three have special i18n() needs for sLabel
81
 
  { Back,          KStdAccel::Back, "go_back", 0, 0, "back" },
82
 
  { Forward,       KStdAccel::Forward, "go_forward", 0, 0, "forward" },
83
 
  { Home,          KStdAccel::Home, "go_home", 0, 0, "gohome" },
84
 
  { Prior,         KStdAccel::Prior, "go_previous", I18N_NOOP("&Previous Page"), 0, "previous" },
85
 
  { Next,          KStdAccel::Next, "go_next", I18N_NOOP("&Next Page"), 0, "next" },
86
 
  { Goto,          KStdAccel::AccelNone, "go_goto", I18N_NOOP("&Go To..."), 0, 0 },
87
 
  { GotoPage,      KStdAccel::AccelNone, "go_goto_page", I18N_NOOP("&Go to Page..."), 0, "goto" },
88
 
  { GotoLine,      KStdAccel::GotoLine, "go_goto_line", I18N_NOOP("&Go to Line..."), 0, 0 },
89
 
  { FirstPage,     KStdAccel::Home, "go_first", I18N_NOOP("&First Page"), 0, "start" },
90
 
  { LastPage,      KStdAccel::End, "go_last", I18N_NOOP("&Last Page"), 0, "finish" },
91
 
 
92
 
  { AddBookmark,   KStdAccel::AddBookmark, "bookmark_add", I18N_NOOP("&Add Bookmark"), 0, "bookmark_add" },
93
 
  { EditBookmarks, KStdAccel::AccelNone, "bookmark_edit", I18N_NOOP("&Edit Bookmarks"), 0, "bookmark" },
94
 
 
95
 
  { Spelling,      KStdAccel::AccelNone, "tools_spelling", I18N_NOOP("&Spelling..."), 0, "spellcheck" },
96
 
 
97
 
  { ShowMenubar,   KStdAccel::ShowMenubar, "options_show_menubar", I18N_NOOP("Show &Menubar"), 0, "showmenu" },
98
 
  { ShowToolbar,   KStdAccel::AccelNone, "options_show_toolbar", I18N_NOOP("Show &Toolbar"), 0, 0 },
99
 
  { ShowStatusbar, KStdAccel::AccelNone, "options_show_statusbar", I18N_NOOP("Show St&atusbar"), 0, 0 },
100
 
  { FullScreen,    KStdAccel::FullScreen, "fullscreen", I18N_NOOP("F&ull Screen Mode"), 0, "window_fullscreen" },
101
 
  { SaveOptions,   KStdAccel::AccelNone, "options_save_options", I18N_NOOP("&Save Settings"), 0, 0 },
102
 
  { KeyBindings,   KStdAccel::AccelNone, "options_configure_keybinding", I18N_NOOP("Configure S&hortcuts..."), 0,"configure_shortcuts" },
103
 
  { Preferences,   KStdAccel::AccelNone, "options_configure", I18N_NOOP("&Configure %1..."), 0, "configure" },
104
 
  { ConfigureToolbars, KStdAccel::AccelNone, "options_configure_toolbars", I18N_NOOP("Configure Tool&bars..."), 0,"configure_toolbars" },
105
 
  { ConfigureNotifications, KStdAccel::AccelNone, "options_configure_notifications", I18N_NOOP("Configure &Notifications..."), 0, "knotify" },
106
 
 
107
 
  // the idea here is that Contents is used in menus, and Help in dialogs, so both share the same
108
 
  // shortcut
109
 
  { Help,          KStdAccel::Help, "help", 0, 0, "help" },
110
 
  { HelpContents,  KStdAccel::Help, "help_contents", I18N_NOOP("%1 &Handbook"), 0, "contents" },
111
 
  { WhatsThis,     KStdAccel::WhatsThis, "help_whats_this", I18N_NOOP("What's &This?"), 0, "contexthelp" },
112
 
  { TipofDay,      KStdAccel::AccelNone, "help_show_tip", I18N_NOOP("Tip of the &Day"), 0, "idea" },
113
 
  { ReportBug,     KStdAccel::AccelNone, "help_report_bug", I18N_NOOP("&Report Bug..."), 0, 0 },
114
 
  { AboutApp,      KStdAccel::AccelNone, "help_about_app", I18N_NOOP("&About %1"), 0, 0 },
115
 
  { AboutKDE,      KStdAccel::AccelNone, "help_about_kde", I18N_NOOP("About &KDE"), 0,"about_kde" },
116
 
  { ActionNone, KStdAccel::AccelNone, 0, 0, 0, 0 }
117
 
};
118
 
 
119
 
inline const KStdActionInfo* infoPtr( StdAction id )
120
 
{
121
 
  for ( uint i = 0; g_rgActionInfo[i].id != ActionNone; i++ ) {
122
 
    if( g_rgActionInfo[i].id == id )
123
 
      return &g_rgActionInfo[i];
124
 
  }
125
 
 
126
 
  return 0;
127
 
}
128
 
 
129
 
static inline QStringList internal_stdNames()
130
 
{
131
 
  QStringList result;
132
 
 
133
 
  for ( uint i = 0; g_rgActionInfo[i].id != ActionNone; i++ )
134
 
    if (g_rgActionInfo[i].psLabel)
135
 
      result.append(i18n(g_rgActionInfo[i].psLabel));
136
 
 
137
 
  return result;
138
 
}
139
 
 
140
 
class AutomaticAction : public KAction
141
 
{
142
 
  Q_OBJECT
143
 
 
144
 
  public:
145
 
    AutomaticAction( const KIcon &icon, const QString &text, const QKeySequence &cut, const char *slot,
146
 
                     KActionCollection *parent, const char *name );
147
 
  public Q_SLOTS:
148
 
    inline void cut() { invokeEditSlot( "cut" ); };
149
 
    inline void copy() { invokeEditSlot( "copy" ); };
150
 
    inline void paste() { invokeEditSlot( "paste" ); };
151
 
    inline void clear() { invokeEditSlot( "clear" ); };
152
 
    inline void selectAll() { invokeEditSlot( "selectAll" ); };
153
 
 
154
 
    void invokeEditSlot( const char *slot )
155
 
    {
156
 
      if ( qApp->focusWidget() )
157
 
        QMetaObject::invokeMethod( qApp->focusWidget(), slot );
158
 
    }
159
 
 
160
 
};
161
 
 
162
 
}
163
 
 
164
 
#endif