KWidgetsAddons

kstandardguiitem.cpp
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
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
151{
152 return KGuiItem(QApplication::translate("KStandardGuiItem", "&OK"), QStringLiteral("dialog-ok"));
153}
154
156{
157 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Cancel"), QStringLiteral("dialog-cancel"));
158}
159
161{
162 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Discard"),
163 QStringLiteral("edit-delete"),
164 QApplication::translate("KStandardGuiItem", "Discard changes"),
165 QApplication::translate("KStandardGuiItem",
166 "Pressing this button will discard all recent "
167 "changes made in this dialog."));
168}
169
171{
172 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Save"),
173 QStringLiteral("document-save"),
174 QApplication::translate("KStandardGuiItem", "Save data"));
175}
176
178{
179 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Do Not Save"), QString(), QApplication::translate("KStandardGuiItem", "Do not save data"));
180}
181
183{
184 return KGuiItem(QApplication::translate("KStandardGuiItem", "Save &As…"),
185 QStringLiteral("document-save-as"),
186 QApplication::translate("KStandardGuiItem", "Save file with another name"));
187}
188
190{
191 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Apply"),
192 QStringLiteral("dialog-ok-apply"),
193 QApplication::translate("KStandardGuiItem", "Apply changes"),
194 QApplication::translate("KStandardGuiItem",
195 "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
202{
203 return KGuiItem(QApplication::translate("KStandardGuiItem", "Administrator &Mode…"),
204 QString(),
205 QApplication::translate("KStandardGuiItem", "Enter Administrator Mode"),
206 QApplication::translate("KStandardGuiItem",
207 "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
213{
214 return KGuiItem(QApplication::translate("KStandardGuiItem", "C&lear"),
215 QStringLiteral("edit-clear"),
216 QApplication::translate("KStandardGuiItem", "Clear input"),
217 QApplication::translate("KStandardGuiItem", "Clear the input in the edit field"));
218}
219
221{
222 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Help", "show help"),
223 QStringLiteral("help-contents"),
224 QApplication::translate("KStandardGuiItem", "Show help"));
225}
226
228{
229 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close"),
230 QStringLiteral("window-close"),
231 QApplication::translate("KStandardGuiItem", "Close the current window or document"));
232}
233
235{
236 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close Window"),
237 QStringLiteral("window-close"),
238 QApplication::translate("KStandardGuiItem", "Close the current window."));
239}
240
242{
243 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close Document"),
244 QStringLiteral("document-close"),
245 QApplication::translate("KStandardGuiItem", "Close the current document."));
246}
247
249{
250 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Defaults"),
251 QStringLiteral("document-revert"),
252 QApplication::translate("KStandardGuiItem", "Reset all items to their default values"));
253}
254
256{
257 QString icon = (useBidi == UseRTL && QApplication::isRightToLeft()) ? QStringLiteral("go-next") : QStringLiteral("go-previous");
258 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Back", "go back"), icon, QApplication::translate("KStandardGuiItem", "Go back one step"));
259}
260
262{
263 QString icon = (useBidi == UseRTL && QApplication::isRightToLeft()) ? QStringLiteral("go-previous") : QStringLiteral("go-next");
264 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Forward", "go forward"),
265 icon,
266 QApplication::translate("KStandardGuiItem", "Go forward one step"));
267}
268
269QPair<KGuiItem, KGuiItem> backAndForward()
270{
271 return qMakePair(back(UseRTL), forward(UseRTL));
272}
273
275{
276 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Print…"),
277 QStringLiteral("document-print"),
278 QApplication::translate("KStandardGuiItem",
279 "Opens the print dialog to print "
280 "the current document"));
281}
282
284{
285 return KGuiItem(QApplication::translate("KStandardGuiItem", "C&ontinue"),
286 QStringLiteral("arrow-right"),
287 QApplication::translate("KStandardGuiItem", "Continue operation"));
288}
289
291{
292 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Delete"),
293 QStringLiteral("edit-delete"),
294 QApplication::translate("KStandardGuiItem", "Delete item(s)"));
295}
296
298{
299 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Open…"),
300 QStringLiteral("document-open"),
301 QApplication::translate("KStandardGuiItem", "Open file"));
302}
303
305{
306 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Quit"),
307 QStringLiteral("application-exit"),
308 QApplication::translate("KStandardGuiItem", "Quit application"));
309}
310
312{
313 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Reset"),
314 QStringLiteral("edit-undo"),
315 QApplication::translate("KStandardGuiItem", "Reset configuration"));
316}
317
319{
320 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Insert", "Verb"));
321}
322
324{
325 return KGuiItem(QApplication::translate("KStandardGuiItem", "Confi&gure…"), QStringLiteral("configure"));
326}
327
329{
330 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Find"), QStringLiteral("edit-find"));
331}
332
334{
335 return KGuiItem(QApplication::translate("KStandardGuiItem", "Stop"), QStringLiteral("process-stop"));
336}
337
339{
340 return KGuiItem(QApplication::translate("KStandardGuiItem", "Add"), QStringLiteral("list-add"));
341}
342
344{
345 return KGuiItem(QApplication::translate("KStandardGuiItem", "Remove"), QStringLiteral("list-remove"));
346}
347
349{
350 return KGuiItem(QApplication::translate("KStandardGuiItem", "Test"));
351}
352
354{
355 return KGuiItem(QApplication::translate("KStandardGuiItem", "Properties"), QStringLiteral("document-properties"));
356}
357
359{
360 return KGuiItem(QApplication::translate("KStandardGuiItem", "&Overwrite"), QStringLiteral("document-replace"));
361}
362
363void assign(QPushButton *button, StandardItem item)
364{
366}
367
368} // KStandardGuiItem namespace
An abstract class for setting the text, icon, tooltip and WhatsThis data on a GUI item (e....
Definition kguiitem.h:34
static void assign(QPushButton *button, const KGuiItem &item)
A static method that can be used to set the text, icon, tooltip and WhatThis properties from item on ...
Definition kguiitem.cpp:172
Provides a set of standardized KGuiItems.
KGuiItem reset()
Returns the 'Reset' gui item.
KGuiItem add()
Returns the 'Add' gui item.
BidiMode
The back and forward items by default use the RTL settings for Hebrew and Arab countries.
KGuiItem remove()
Returns the 'Remove' gui item.
KGuiItem print()
Returns the 'Print' gui item.
KGuiItem overwrite()
Returns the 'Overwrite' gui item.
KGuiItem insert()
Returns the 'Insert' gui item.
KGuiItem properties()
Returns the 'Properties' gui item.
KGuiItem cont()
Returns the 'Continue' gui item.
KGuiItem stop()
Returns the 'Stop' gui item.
KGuiItem configure()
Returns the 'Configure' gui item.
KGuiItem saveAs()
Returns the 'SaveAs' gui item.
QString standardItem(StandardItem ui_enum)
Returns the name of the gui item for the given identifier id.
KGuiItem cancel()
Returns the 'Cancel' gui item.
KGuiItem open()
Returns the 'Open' gui item.
KGuiItem defaults()
Returns the 'Defaults' gui item.
KGuiItem find()
Returns the 'Find' gui item.
KGuiItem dontSave()
Returns the 'DontSave' gui item.
KGuiItem apply()
Returns the 'Apply' gui item.
KGuiItem ok()
Returns the 'Ok' gui item.
KGuiItem save()
Returns the 'Save' gui item.
KGuiItem test()
Returns the 'Test' gui item.
KGuiItem quit()
Returns the 'Quit' gui item.
KGuiItem discard()
Returns the 'Discard' gui item.
KGuiItem clear()
Returns the 'Clear' gui item.
KGuiItem del()
Returns the 'Delete' gui item.
KGuiItem closeDocument()
Returns the 'CloseDocument' gui item.
KGuiItem back(BidiMode useBidi)
Returns the 'Back' gui item, like Konqueror's back button.
KGuiItem help()
Returns the 'Help' gui item.
KGuiItem close()
Returns the 'Close' gui item.
QPair< KGuiItem, KGuiItem > backAndForward()
Return both a back and a forward gui item.
KGuiItem guiItem(StandardItem ui_enum)
Returns the gui item for the given identifier id.
KGuiItem closeWindow()
Returns the 'CloseWindow' gui item.
KGuiItem forward(BidiMode useBidi)
Returns the 'Forward' gui item, like Konqueror's forward button.
KGuiItem adminMode()
Returns a KGuiItem suiting for cases where code or functionality runs under root privileges.
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
bool isRightToLeft()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.