1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7
8#include "kstandardguiitem.h"
9
10#include <QApplication>
11
12namespace KStandardGuiItem
13{
14KGuiItem guiItem(StandardItem ui_enum)
15{
16 switch (ui_enum) {
17 case Ok:
18 return ok();
19 case Cancel:
20 return cancel();
21 case Discard:
22 return discard();
23 case Save:
24 return save();
25 case DontSave:
26 return dontSave();
27 case SaveAs:
28 return saveAs();
29 case Apply:
30 return apply();
31 case Clear:
32 return clear();
33 case Help:
34 return help();
35 case Close:
36 return close();
37 case CloseWindow:
38 return closeWindow();
39 case CloseDocument:
40 return closeDocument();
41 case Defaults:
42 return defaults();
43 case Back:
44 return back();
45 case Forward:
46 return forward();
47 case Print:
48 return print();
49 case Continue:
50 return cont();
51 case Open:
52 return open();
53 case Quit:
54 return quit();
55 case AdminMode:
56 return adminMode();
57 case Reset:
58 return reset();
59 case Delete:
60 return del();
61 case Insert:
62 return insert();
63 case Configure:
64 return configure();
65 case Find:
66 return find();
67 case Stop:
68 return stop();
69 case Add:
70 return add();
71 case Remove:
72 return remove();
73 case Test:
74 return test();
75 case Properties:
76 return properties();
77 case Overwrite:
78 return overwrite();
79 default:
80 return KGuiItem();
81 };
82}
83
84QString standardItem(StandardItem ui_enum)
85{
86 switch (ui_enum) {
87 case Ok:
88 return QStringLiteral("ok");
89 case Cancel:
90 return QStringLiteral("cancel");
91 case Discard:
92 return QStringLiteral("discard");
93 case Save:
94 return QStringLiteral("save");
95 case DontSave:
96 return QStringLiteral("dontSave");
97 case SaveAs:
98 return QStringLiteral("saveAs");
99 case Apply:
100 return QStringLiteral("apply");
101 case Help:
102 return QStringLiteral("help");
103 case Close:
104 return QStringLiteral("close");
105 case CloseWindow:
106 return QStringLiteral("closeWindow");
107 case CloseDocument:
108 return QStringLiteral("closeDocument");
109 case Defaults:
110 return QStringLiteral("defaults");
111 case Back:
112 return QStringLiteral("back");
113 case Forward:
114 return QStringLiteral("forward");
115 case Print:
116 return QStringLiteral("print");
117 case Continue:
118 return QStringLiteral("continue");
119 case Open:
120 return QStringLiteral("open");
121 case Quit:
122 return QStringLiteral("quit");
123 case AdminMode:
124 return QStringLiteral("adminMode");
125 case Delete:
126 return QStringLiteral("delete");
127 case Insert:
128 return QStringLiteral("insert");
129 case Configure:
130 return QStringLiteral("configure");
131 case Find:
132 return QStringLiteral("find");
133 case Stop:
134 return QStringLiteral("stop");
135 case Add:
136 return QStringLiteral("add");
137 case Remove:
138 return QStringLiteral("remove");
139 case Test:
140 return QStringLiteral("test");
141 case Properties:
142 return QStringLiteral("properties");
143 case Overwrite:
144 return QStringLiteral("overwrite");
145 default:
146 return QString();
147 };
148}
149
150KGuiItem ok()
151{
152 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&OK"), QStringLiteral("dialog-ok"));
153}
154
155KGuiItem cancel()
156{
157 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Cancel"), QStringLiteral("dialog-cancel"));
158}
159
160KGuiItem discard()
161{
162 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Discard"),
163 QStringLiteral("edit-delete"),
164 QApplication::translate(context: "KStandardGuiItem", key: "Discard changes"),
165 QApplication::translate(context: "KStandardGuiItem",
166 key: "Pressing this button will discard all recent "
167 "changes made in this dialog."));
168}
169
170KGuiItem save()
171{
172 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Save"),
173 QStringLiteral("document-save"),
174 QApplication::translate(context: "KStandardGuiItem", key: "Save data"));
175}
176
177KGuiItem dontSave()
178{
179 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Do Not Save"), QString(), QApplication::translate(context: "KStandardGuiItem", key: "Do not save data"));
180}
181
182KGuiItem saveAs()
183{
184 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Save &As..."),
185 QStringLiteral("document-save-as"),
186 QApplication::translate(context: "KStandardGuiItem", key: "Save file with another name"));
187}
188
189KGuiItem apply()
190{
191 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Apply"),
192 QStringLiteral("dialog-ok-apply"),
193 QApplication::translate(context: "KStandardGuiItem", key: "Apply changes"),
194 QApplication::translate(context: "KStandardGuiItem",
195 key: "When you click <b>Apply</b>, the settings will be "
196 "handed over to the program, but the dialog "
197 "will not be closed.\n"
198 "Use this to try different settings."));
199}
200
201KGuiItem adminMode()
202{
203 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Administrator &Mode..."),
204 QString(),
205 QApplication::translate(context: "KStandardGuiItem", key: "Enter Administrator Mode"),
206 QApplication::translate(context: "KStandardGuiItem",
207 key: "When you click <b>Administrator Mode</b> you will be prompted "
208 "for the administrator (root) password in order to make changes "
209 "which require root privileges."));
210}
211
212KGuiItem clear()
213{
214 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "C&lear"),
215 QStringLiteral("edit-clear"),
216 QApplication::translate(context: "KStandardGuiItem", key: "Clear input"),
217 QApplication::translate(context: "KStandardGuiItem", key: "Clear the input in the edit field"));
218}
219
220KGuiItem help()
221{
222 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Help", disambiguation: "show help"),
223 QStringLiteral("help-contents"),
224 QApplication::translate(context: "KStandardGuiItem", key: "Show help"));
225}
226
227KGuiItem close()
228{
229 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Close"),
230 QStringLiteral("window-close"),
231 QApplication::translate(context: "KStandardGuiItem", key: "Close the current window or document"));
232}
233
234KGuiItem closeWindow()
235{
236 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Close Window"),
237 QStringLiteral("window-close"),
238 QApplication::translate(context: "KStandardGuiItem", key: "Close the current window."));
239}
240
241KGuiItem closeDocument()
242{
243 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Close Document"),
244 QStringLiteral("document-close"),
245 QApplication::translate(context: "KStandardGuiItem", key: "Close the current document."));
246}
247
248KGuiItem defaults()
249{
250 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Defaults"),
251 QStringLiteral("document-revert"),
252 QApplication::translate(context: "KStandardGuiItem", key: "Reset all items to their default values"));
253}
254
255KGuiItem back(BidiMode useBidi)
256{
257 QString icon = (useBidi == UseRTL && QApplication::isRightToLeft()) ? QStringLiteral("go-next") : QStringLiteral("go-previous");
258 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Back", disambiguation: "go back"), icon, QApplication::translate(context: "KStandardGuiItem", key: "Go back one step"));
259}
260
261KGuiItem forward(BidiMode useBidi)
262{
263 QString icon = (useBidi == UseRTL && QApplication::isRightToLeft()) ? QStringLiteral("go-previous") : QStringLiteral("go-next");
264 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Forward", disambiguation: "go forward"),
265 icon,
266 QApplication::translate(context: "KStandardGuiItem", key: "Go forward one step"));
267}
268
269QPair<KGuiItem, KGuiItem> backAndForward()
270{
271 return qMakePair(value1: back(useBidi: UseRTL), value2: forward(useBidi: UseRTL));
272}
273
274KGuiItem print()
275{
276 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Print..."),
277 QStringLiteral("document-print"),
278 QApplication::translate(context: "KStandardGuiItem",
279 key: "Opens the print dialog to print "
280 "the current document"));
281}
282
283KGuiItem cont()
284{
285 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "C&ontinue"),
286 QStringLiteral("arrow-right"),
287 QApplication::translate(context: "KStandardGuiItem", key: "Continue operation"));
288}
289
290KGuiItem del()
291{
292 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Delete"),
293 QStringLiteral("edit-delete"),
294 QApplication::translate(context: "KStandardGuiItem", key: "Delete item(s)"));
295}
296
297KGuiItem open()
298{
299 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Open..."),
300 QStringLiteral("document-open"),
301 QApplication::translate(context: "KStandardGuiItem", key: "Open file"));
302}
303
304KGuiItem quit()
305{
306 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Quit"),
307 QStringLiteral("application-exit"),
308 QApplication::translate(context: "KStandardGuiItem", key: "Quit application"));
309}
310
311KGuiItem reset()
312{
313 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Reset"),
314 QStringLiteral("edit-undo"),
315 QApplication::translate(context: "KStandardGuiItem", key: "Reset configuration"));
316}
317
318KGuiItem insert()
319{
320 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Insert", disambiguation: "Verb"));
321}
322
323KGuiItem configure()
324{
325 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Confi&gure..."), QStringLiteral("configure"));
326}
327
328KGuiItem find()
329{
330 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Find"), QStringLiteral("edit-find"));
331}
332
333KGuiItem stop()
334{
335 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Stop"), QStringLiteral("process-stop"));
336}
337
338KGuiItem add()
339{
340 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Add"), QStringLiteral("list-add"));
341}
342
343KGuiItem remove()
344{
345 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Remove"), QStringLiteral("list-remove"));
346}
347
348KGuiItem test()
349{
350 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Test"));
351}
352
353KGuiItem properties()
354{
355 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "Properties"), QStringLiteral("document-properties"));
356}
357
358KGuiItem overwrite()
359{
360 return KGuiItem(QApplication::translate(context: "KStandardGuiItem", key: "&Overwrite"), QStringLiteral("document-replace"));
361}
362
363void assign(QPushButton *button, StandardItem item)
364{
365 KGuiItem::assign(button, item: KStandardGuiItem::guiItem(ui_enum: item));
366}
367
368} // KStandardGuiItem namespace
369

source code of kwidgetsaddons/src/kstandardguiitem.cpp