File indexing completed on 2024-04-28 03:59:15

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "kstandardguiitem.h"
0009 
0010 #include <QApplication>
0011 
0012 namespace KStandardGuiItem
0013 {
0014 KGuiItem guiItem(StandardItem ui_enum)
0015 {
0016     switch (ui_enum) {
0017     case Ok:
0018         return ok();
0019     case Cancel:
0020         return cancel();
0021     case Discard:
0022         return discard();
0023     case Save:
0024         return save();
0025     case DontSave:
0026         return dontSave();
0027     case SaveAs:
0028         return saveAs();
0029     case Apply:
0030         return apply();
0031     case Clear:
0032         return clear();
0033     case Help:
0034         return help();
0035     case Close:
0036         return close();
0037     case CloseWindow:
0038         return closeWindow();
0039     case CloseDocument:
0040         return closeDocument();
0041     case Defaults:
0042         return defaults();
0043     case Back:
0044         return back();
0045     case Forward:
0046         return forward();
0047     case Print:
0048         return print();
0049     case Continue:
0050         return cont();
0051     case Open:
0052         return open();
0053     case Quit:
0054         return quit();
0055     case AdminMode:
0056         return adminMode();
0057     case Reset:
0058         return reset();
0059     case Delete:
0060         return del();
0061     case Insert:
0062         return insert();
0063     case Configure:
0064         return configure();
0065     case Find:
0066         return find();
0067     case Stop:
0068         return stop();
0069     case Add:
0070         return add();
0071     case Remove:
0072         return remove();
0073     case Test:
0074         return test();
0075     case Properties:
0076         return properties();
0077     case Overwrite:
0078         return overwrite();
0079     default:
0080         return KGuiItem();
0081     };
0082 }
0083 
0084 QString standardItem(StandardItem ui_enum)
0085 {
0086     switch (ui_enum) {
0087     case Ok:
0088         return QStringLiteral("ok");
0089     case Cancel:
0090         return QStringLiteral("cancel");
0091     case Discard:
0092         return QStringLiteral("discard");
0093     case Save:
0094         return QStringLiteral("save");
0095     case DontSave:
0096         return QStringLiteral("dontSave");
0097     case SaveAs:
0098         return QStringLiteral("saveAs");
0099     case Apply:
0100         return QStringLiteral("apply");
0101     case Help:
0102         return QStringLiteral("help");
0103     case Close:
0104         return QStringLiteral("close");
0105     case CloseWindow:
0106         return QStringLiteral("closeWindow");
0107     case CloseDocument:
0108         return QStringLiteral("closeDocument");
0109     case Defaults:
0110         return QStringLiteral("defaults");
0111     case Back:
0112         return QStringLiteral("back");
0113     case Forward:
0114         return QStringLiteral("forward");
0115     case Print:
0116         return QStringLiteral("print");
0117     case Continue:
0118         return QStringLiteral("continue");
0119     case Open:
0120         return QStringLiteral("open");
0121     case Quit:
0122         return QStringLiteral("quit");
0123     case AdminMode:
0124         return QStringLiteral("adminMode");
0125     case Delete:
0126         return QStringLiteral("delete");
0127     case Insert:
0128         return QStringLiteral("insert");
0129     case Configure:
0130         return QStringLiteral("configure");
0131     case Find:
0132         return QStringLiteral("find");
0133     case Stop:
0134         return QStringLiteral("stop");
0135     case Add:
0136         return QStringLiteral("add");
0137     case Remove:
0138         return QStringLiteral("remove");
0139     case Test:
0140         return QStringLiteral("test");
0141     case Properties:
0142         return QStringLiteral("properties");
0143     case Overwrite:
0144         return QStringLiteral("overwrite");
0145     default:
0146         return QString();
0147     };
0148 }
0149 
0150 KGuiItem ok()
0151 {
0152     return KGuiItem(QApplication::translate("KStandardGuiItem", "&OK"), QStringLiteral("dialog-ok"));
0153 }
0154 
0155 KGuiItem cancel()
0156 {
0157     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Cancel"), QStringLiteral("dialog-cancel"));
0158 }
0159 
0160 KGuiItem discard()
0161 {
0162     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Discard"),
0163                     QStringLiteral("edit-delete"),
0164                     QApplication::translate("KStandardGuiItem", "Discard changes"),
0165                     QApplication::translate("KStandardGuiItem",
0166                                             "Pressing this button will discard all recent "
0167                                             "changes made in this dialog."));
0168 }
0169 
0170 KGuiItem save()
0171 {
0172     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Save"),
0173                     QStringLiteral("document-save"),
0174                     QApplication::translate("KStandardGuiItem", "Save data"));
0175 }
0176 
0177 KGuiItem dontSave()
0178 {
0179     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Do Not Save"), QString(), QApplication::translate("KStandardGuiItem", "Do not save data"));
0180 }
0181 
0182 KGuiItem saveAs()
0183 {
0184     return KGuiItem(QApplication::translate("KStandardGuiItem", "Save &As..."),
0185                     QStringLiteral("document-save-as"),
0186                     QApplication::translate("KStandardGuiItem", "Save file with another name"));
0187 }
0188 
0189 KGuiItem apply()
0190 {
0191     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Apply"),
0192                     QStringLiteral("dialog-ok-apply"),
0193                     QApplication::translate("KStandardGuiItem", "Apply changes"),
0194                     QApplication::translate("KStandardGuiItem",
0195                                             "When you click <b>Apply</b>, the settings will be "
0196                                             "handed over to the program, but the dialog "
0197                                             "will not be closed.\n"
0198                                             "Use this to try different settings."));
0199 }
0200 
0201 KGuiItem adminMode()
0202 {
0203     return KGuiItem(QApplication::translate("KStandardGuiItem", "Administrator &Mode..."),
0204                     QString(),
0205                     QApplication::translate("KStandardGuiItem", "Enter Administrator Mode"),
0206                     QApplication::translate("KStandardGuiItem",
0207                                             "When you click <b>Administrator Mode</b> you will be prompted "
0208                                             "for the administrator (root) password in order to make changes "
0209                                             "which require root privileges."));
0210 }
0211 
0212 KGuiItem clear()
0213 {
0214     return KGuiItem(QApplication::translate("KStandardGuiItem", "C&lear"),
0215                     QStringLiteral("edit-clear"),
0216                     QApplication::translate("KStandardGuiItem", "Clear input"),
0217                     QApplication::translate("KStandardGuiItem", "Clear the input in the edit field"));
0218 }
0219 
0220 KGuiItem help()
0221 {
0222     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Help", "show help"),
0223                     QStringLiteral("help-contents"),
0224                     QApplication::translate("KStandardGuiItem", "Show help"));
0225 }
0226 
0227 KGuiItem close()
0228 {
0229     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close"),
0230                     QStringLiteral("window-close"),
0231                     QApplication::translate("KStandardGuiItem", "Close the current window or document"));
0232 }
0233 
0234 KGuiItem closeWindow()
0235 {
0236     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close Window"),
0237                     QStringLiteral("window-close"),
0238                     QApplication::translate("KStandardGuiItem", "Close the current window."));
0239 }
0240 
0241 KGuiItem closeDocument()
0242 {
0243     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Close Document"),
0244                     QStringLiteral("document-close"),
0245                     QApplication::translate("KStandardGuiItem", "Close the current document."));
0246 }
0247 
0248 KGuiItem defaults()
0249 {
0250     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Defaults"),
0251                     QStringLiteral("document-revert"),
0252                     QApplication::translate("KStandardGuiItem", "Reset all items to their default values"));
0253 }
0254 
0255 KGuiItem back(BidiMode useBidi)
0256 {
0257     QString icon = (useBidi == UseRTL && QApplication::isRightToLeft()) ? QStringLiteral("go-next") : QStringLiteral("go-previous");
0258     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Back", "go back"), icon, QApplication::translate("KStandardGuiItem", "Go back one step"));
0259 }
0260 
0261 KGuiItem forward(BidiMode useBidi)
0262 {
0263     QString icon = (useBidi == UseRTL && QApplication::isRightToLeft()) ? QStringLiteral("go-previous") : QStringLiteral("go-next");
0264     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Forward", "go forward"),
0265                     icon,
0266                     QApplication::translate("KStandardGuiItem", "Go forward one step"));
0267 }
0268 
0269 QPair<KGuiItem, KGuiItem> backAndForward()
0270 {
0271     return qMakePair(back(UseRTL), forward(UseRTL));
0272 }
0273 
0274 KGuiItem print()
0275 {
0276     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Print..."),
0277                     QStringLiteral("document-print"),
0278                     QApplication::translate("KStandardGuiItem",
0279                                             "Opens the print dialog to print "
0280                                             "the current document"));
0281 }
0282 
0283 KGuiItem cont()
0284 {
0285     return KGuiItem(QApplication::translate("KStandardGuiItem", "C&ontinue"),
0286                     QStringLiteral("arrow-right"),
0287                     QApplication::translate("KStandardGuiItem", "Continue operation"));
0288 }
0289 
0290 KGuiItem del()
0291 {
0292     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Delete"),
0293                     QStringLiteral("edit-delete"),
0294                     QApplication::translate("KStandardGuiItem", "Delete item(s)"));
0295 }
0296 
0297 KGuiItem open()
0298 {
0299     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Open..."),
0300                     QStringLiteral("document-open"),
0301                     QApplication::translate("KStandardGuiItem", "Open file"));
0302 }
0303 
0304 KGuiItem quit()
0305 {
0306     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Quit"),
0307                     QStringLiteral("application-exit"),
0308                     QApplication::translate("KStandardGuiItem", "Quit application"));
0309 }
0310 
0311 KGuiItem reset()
0312 {
0313     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Reset"),
0314                     QStringLiteral("edit-undo"),
0315                     QApplication::translate("KStandardGuiItem", "Reset configuration"));
0316 }
0317 
0318 KGuiItem insert()
0319 {
0320     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Insert", "Verb"));
0321 }
0322 
0323 KGuiItem configure()
0324 {
0325     return KGuiItem(QApplication::translate("KStandardGuiItem", "Confi&gure..."), QStringLiteral("configure"));
0326 }
0327 
0328 KGuiItem find()
0329 {
0330     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Find"), QStringLiteral("edit-find"));
0331 }
0332 
0333 KGuiItem stop()
0334 {
0335     return KGuiItem(QApplication::translate("KStandardGuiItem", "Stop"), QStringLiteral("process-stop"));
0336 }
0337 
0338 KGuiItem add()
0339 {
0340     return KGuiItem(QApplication::translate("KStandardGuiItem", "Add"), QStringLiteral("list-add"));
0341 }
0342 
0343 KGuiItem remove()
0344 {
0345     return KGuiItem(QApplication::translate("KStandardGuiItem", "Remove"), QStringLiteral("list-remove"));
0346 }
0347 
0348 KGuiItem test()
0349 {
0350     return KGuiItem(QApplication::translate("KStandardGuiItem", "Test"));
0351 }
0352 
0353 KGuiItem properties()
0354 {
0355     return KGuiItem(QApplication::translate("KStandardGuiItem", "Properties"), QStringLiteral("document-properties"));
0356 }
0357 
0358 KGuiItem overwrite()
0359 {
0360     return KGuiItem(QApplication::translate("KStandardGuiItem", "&Overwrite"), QStringLiteral("document-replace"));
0361 }
0362 
0363 void assign(QPushButton *button, StandardItem item)
0364 {
0365     KGuiItem::assign(button, KStandardGuiItem::guiItem(item));
0366 }
0367 
0368 } // KStandardGuiItem namespace