File: kstandardguiitem.cpp

package info (click to toggle)
kwidgetsaddons 5.28.0-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 62,388 kB
  • ctags: 3,611
  • sloc: cpp: 26,647; python: 682; sh: 23; makefile: 6
file content (313 lines) | stat: -rw-r--r-- 11,558 bytes parent folder | download
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
/* This file is part of the KDE libraries
   Copyright (C) 2001 Holger Freyther <freyther@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 "kstandardguiitem.h"

#include <QApplication>

#include <kguiitem.h>

namespace KStandardGuiItem
{

KGuiItem guiItem(StandardItem ui_enum)
{
    switch (ui_enum) {
    case Ok       : return ok();
    case Cancel   : return cancel();
    case Yes      : return yes();
    case No       : return no();
    case Discard  : return discard();
    case Save     : return save();
    case DontSave : return dontSave();
    case SaveAs   : return saveAs();
    case Apply    : return apply();
    case Clear    : return clear();
    case Help     : return help();
    case Close    : return close();
    case CloseWindow : return closeWindow();
    case CloseDocument : return closeDocument();
    case Defaults : return defaults();
    case Back     : return back();
    case Forward  : return forward();
    case Print    : return print();
    case Continue : return cont();
    case Open     : return open();
    case Quit     : return quit();
    case AdminMode: return adminMode();
    case Reset    : return reset();
    case Delete   : return del();
    case Insert   : return insert();
    case Configure: return configure();
    case Find     : return find();
    case Stop     : return stop();
    case Add      : return add();
    case Remove   : return remove();
    case Test     : return test();
    case Properties : return properties();
    case Overwrite : return overwrite();
    default       : return KGuiItem();
    };
}

QString standardItem(StandardItem ui_enum)
{
    switch (ui_enum) {
    case Ok       : return QStringLiteral("ok");
    case Cancel   : return QStringLiteral("cancel");
    case Yes      : return QStringLiteral("yes");
    case No       : return QStringLiteral("no");
    case Discard  : return QStringLiteral("discard");
    case Save     : return QStringLiteral("save");
    case DontSave : return QStringLiteral("dontSave");
    case SaveAs   : return QStringLiteral("saveAs");
    case Apply    : return QStringLiteral("apply");
    case Help     : return QStringLiteral("help");
    case Close    : return QStringLiteral("close");
    case CloseWindow : return QStringLiteral("closeWindow");
    case CloseDocument : return QStringLiteral("closeDocument");
    case Defaults : return QStringLiteral("defaults");
    case Back     : return QStringLiteral("back");
    case Forward  : return QStringLiteral("forward");
    case Print    : return QStringLiteral("print");
    case Continue : return QStringLiteral("continue");
    case Open     : return QStringLiteral("open");
    case Quit     : return QStringLiteral("quit");
    case AdminMode: return QStringLiteral("adminMode");
    case Delete   : return QStringLiteral("delete");
    case Insert   : return QStringLiteral("insert");
    case Configure: return QStringLiteral("configure");
    case Find     : return QStringLiteral("find");
    case Stop     : return QStringLiteral("stop");
    case Add      : return QStringLiteral("add");
    case Remove   : return QStringLiteral("remove");
    case Test     : return QStringLiteral("test");
    case Properties : return QStringLiteral("properties");
    case Overwrite : return QStringLiteral("overwrite");
    default       : return QString();
    };
}

KGuiItem ok()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&OK"), QStringLiteral("dialog-ok"));
}

KGuiItem cancel()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Cancel"), QStringLiteral("dialog-cancel"));
}

KGuiItem yes()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Yes"), QStringLiteral("dialog-ok"), QApplication::translate("KStandardGuiItem", "Yes"));
}

KGuiItem no()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&No"), QStringLiteral("process-stop"), QApplication::translate("KStandardGuiItem", "No"));
}

KGuiItem discard()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Discard"), QStringLiteral("edit-clear"), QApplication::translate("KStandardGuiItem", "Discard changes"),
                    QApplication::translate("KStandardGuiItem", "Pressing this button will discard all recent "
                         "changes made in this dialog."));
}

KGuiItem save()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Save"), QStringLiteral("document-save"), QApplication::translate("KStandardGuiItem", "Save data"));
}

KGuiItem dontSave()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Do Not Save"), QStringLiteral(""),
                    QApplication::translate("KStandardGuiItem", "Do not save data"));
}

KGuiItem saveAs()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Save &As..."), QStringLiteral("document-save-as"),
                    QApplication::translate("KStandardGuiItem", "Save file with another name"));
}

KGuiItem apply()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Apply"), QStringLiteral("dialog-ok-apply"), QApplication::translate("KStandardGuiItem", "Apply changes"),
                    QApplication::translate("KStandardGuiItem", "When you click <b>Apply</b>, the settings will be "
                         "handed over to the program, but the dialog "
                         "will not be closed.\n"
                         "Use this to try different settings."));
}

KGuiItem adminMode()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Administrator &Mode..."), QStringLiteral(""), QApplication::translate("KStandardGuiItem", "Enter Administrator Mode"),
                    QApplication::translate("KStandardGuiItem", "When you click <b>Administrator Mode</b> you will be prompted "
                         "for the administrator (root) password in order to make changes "
                         "which require root privileges."));
}

KGuiItem clear()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "C&lear"), QStringLiteral("edit-clear"),
                    QApplication::translate("KStandardGuiItem", "Clear input"),
                    QApplication::translate("KStandardGuiItem", "Clear the input in the edit field"));
}

KGuiItem help()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Help", "show help"), QStringLiteral("help-contents"),
                    QApplication::translate("KStandardGuiItem", "Show help"));
}

KGuiItem close()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close"), QStringLiteral("window-close"),
                    QApplication::translate("KStandardGuiItem", "Close the current window or document"));
}

KGuiItem closeWindow()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close Window"), QStringLiteral("window-close"),
                    QApplication::translate("KStandardGuiItem", "Close the current window."));
}

KGuiItem closeDocument()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close Document"), QStringLiteral("document-close"),
                    QApplication::translate("KStandardGuiItem", "Close the current document."));
}

KGuiItem defaults()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Defaults"), QStringLiteral("document-revert"),
                    QApplication::translate("KStandardGuiItem", "Reset all items to their default values"));
}

KGuiItem back(BidiMode useBidi)
{
    QString icon = (useBidi == UseRTL && QApplication::isRightToLeft())
                   ? QStringLiteral("go-next") : QStringLiteral("go-previous");
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Back", "go back"), icon,
                    QApplication::translate("KStandardGuiItem", "Go back one step"));
}

KGuiItem forward(BidiMode useBidi)
{
    QString icon = (useBidi == UseRTL && QApplication::isRightToLeft())
                   ? QStringLiteral("go-previous") : QStringLiteral("go-next");
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Forward", "go forward"), icon,
                    QApplication::translate("KStandardGuiItem", "Go forward one step"));
}

QPair<KGuiItem, KGuiItem> backAndForward()
{
    return qMakePair(back(UseRTL), forward(UseRTL));
}

KGuiItem print()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Print..."), QStringLiteral("document-print"),
                    QApplication::translate("KStandardGuiItem", "Opens the print dialog to print "
                         "the current document"));
}

KGuiItem cont()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "C&ontinue"), QStringLiteral("arrow-right"),
                    QApplication::translate("KStandardGuiItem", "Continue operation"));
}

KGuiItem del()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Delete"), QStringLiteral("edit-delete"),
                    QApplication::translate("KStandardGuiItem", "Delete item(s)"));
}

KGuiItem open()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Open..."), QStringLiteral("document-open"),
                    QApplication::translate("KStandardGuiItem", "Open file"));
}

KGuiItem quit()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Quit"), QStringLiteral("application-exit"),
                    QApplication::translate("KStandardGuiItem", "Quit application"));
}

KGuiItem reset()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Reset"), QStringLiteral("edit-undo"),
                    QApplication::translate("KStandardGuiItem", "Reset configuration"));
}

KGuiItem insert()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Insert", "Verb"));
}

KGuiItem configure()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Confi&gure..."), QStringLiteral("configure"));
}

KGuiItem find()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Find"), QStringLiteral("edit-find"));
}

KGuiItem stop()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Stop"), QStringLiteral("process-stop"));
}

KGuiItem add()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Add"), QStringLiteral("list-add"));
}

KGuiItem remove()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Remove"), QStringLiteral("list-remove"));
}

KGuiItem test()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Test"));
}

KGuiItem properties()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "Properties"), QStringLiteral("document-properties"));
}

KGuiItem overwrite()
{
    return KGuiItem(QApplication::translate("KStandardGuiItem", "&Overwrite"));
}

void assign(QPushButton *button, StandardItem item)
{
    KGuiItem::assign(button, KStandardGuiItem::guiItem(item));
}

} // KStandardGuiItem namespace