File indexing completed on 2024-04-28 15:32:14

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 #ifndef kstandardguiitem_h
0009 #define kstandardguiitem_h
0010 
0011 #include <kwidgetsaddons_export.h>
0012 
0013 #include <QPair>
0014 
0015 #include <kguiitem.h>
0016 
0017 class QString;
0018 
0019 /**
0020  * @short Provides a set of standardized KGuiItems.
0021  *
0022  * The various methods return standardized KGuiItem's
0023  * conforming to the KDE UI Standards. Use them instead of creating
0024  * your own.
0025  *
0026  * @author Holger Freyther <freyther@kde.org>
0027  */
0028 namespace KStandardGuiItem
0029 {
0030 /**
0031  * The back and forward items by default use the RTL settings for Hebrew
0032  * and Arab countries. If you want those actions to ignore the RTL value
0033  * and force 'Western' behavior instead, use the IgnoreRTL value instead.
0034  */
0035 enum BidiMode { UseRTL = 0, IgnoreRTL };
0036 
0037 enum StandardItem {
0038     Ok = 1,
0039     Cancel,
0040 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 100)
0041     /// @deprecated Since 5.100, use an action verb to indicate the available option.
0042     Yes KWIDGETSADDONS_ENUMERATOR_DEPRECATED_VERSION(5, 100, "Use an action verb to indicate the available option."),
0043     /// @deprecated Since 5.100, use an action verb to indicate the available option.
0044     No KWIDGETSADDONS_ENUMERATOR_DEPRECATED_VERSION(5, 100, "Use an action verb to indicate the available option."),
0045 #elif KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(5, 100)
0046     Yes_DEPRECATED_DO_NOT_USE,
0047     No_DEPRECATED_DO_NOT_USE,
0048 #endif
0049     Discard,
0050     Save,
0051     DontSave,
0052     SaveAs,
0053     Apply,
0054     Clear,
0055     Help,
0056     Defaults,
0057     Close,
0058     Back,
0059     Forward,
0060     Print,
0061     Continue,
0062     Open,
0063     Quit,
0064     AdminMode,
0065     Reset,
0066     Delete,
0067     Insert,
0068     Configure,
0069     Find,
0070     Stop,
0071     Add,
0072     Remove,
0073     Test,
0074     Properties,
0075     Overwrite,
0076     CloseWindow,
0077     CloseDocument,
0078 };
0079 
0080 /**
0081  * Returns the gui item for the given identifier @p id.
0082  *
0083  * @param id the identifier to search for
0084  */
0085 KWIDGETSADDONS_EXPORT KGuiItem guiItem(StandardItem id);
0086 
0087 /**
0088  * Returns the name of the gui item for the given identifier @p id.
0089  *
0090  * @param id the identifier to search for
0091  */
0092 KWIDGETSADDONS_EXPORT QString standardItem(StandardItem id);
0093 
0094 /**
0095  * Returns the 'Ok' gui item.
0096  */
0097 KWIDGETSADDONS_EXPORT KGuiItem ok();
0098 
0099 /**
0100  * Returns the 'Cancel' gui item.
0101  */
0102 KWIDGETSADDONS_EXPORT KGuiItem cancel();
0103 
0104 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 100)
0105 /**
0106  * Returns the 'Yes' gui item.
0107  *
0108  * @deprecated Since 5.100, use an action verb to indicate the available option..
0109  */
0110 KWIDGETSADDONS_EXPORT
0111 KWIDGETSADDONS_DEPRECATED_VERSION(5, 100, "Use an action verb to indicate the available option.")
0112 KGuiItem yes();
0113 #endif
0114 
0115 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 100)
0116 /**
0117  * Returns the 'No' gui item.
0118  *
0119  * @deprecated Since 5.100, use an action verb to indicate the available option..
0120  */
0121 KWIDGETSADDONS_EXPORT
0122 KWIDGETSADDONS_DEPRECATED_VERSION(5, 100, "Use an action verb to indicate the available option.")
0123 KGuiItem no();
0124 #endif
0125 
0126 /**
0127  * Returns the 'Insert' gui item.
0128  */
0129 KWIDGETSADDONS_EXPORT KGuiItem insert();
0130 
0131 /**
0132  * Returns the 'Discard' gui item.
0133  */
0134 KWIDGETSADDONS_EXPORT KGuiItem discard();
0135 
0136 /**
0137  * Returns the 'Save' gui item.
0138  */
0139 KWIDGETSADDONS_EXPORT KGuiItem save();
0140 
0141 /**
0142  * Returns the 'Help' gui item.
0143  */
0144 KWIDGETSADDONS_EXPORT KGuiItem help();
0145 
0146 /**
0147  * Returns the 'DontSave' gui item.
0148  */
0149 KWIDGETSADDONS_EXPORT KGuiItem dontSave();
0150 
0151 /**
0152  * Returns the 'SaveAs' gui item.
0153  */
0154 KWIDGETSADDONS_EXPORT KGuiItem saveAs();
0155 
0156 /**
0157  * Returns the 'Apply' gui item.
0158  */
0159 KWIDGETSADDONS_EXPORT KGuiItem apply();
0160 
0161 /**
0162  * Returns the 'Clear' gui item.
0163  */
0164 KWIDGETSADDONS_EXPORT KGuiItem clear();
0165 
0166 /**
0167  * Returns the 'Defaults' gui item.
0168  */
0169 KWIDGETSADDONS_EXPORT KGuiItem defaults();
0170 
0171 /**
0172  * Returns the 'Close' gui item.
0173  */
0174 KWIDGETSADDONS_EXPORT KGuiItem close();
0175 
0176 /**
0177  * Returns the 'CloseWindow' gui item.
0178  * @since 4.3
0179  */
0180 KWIDGETSADDONS_EXPORT KGuiItem closeWindow();
0181 
0182 /**
0183  * Returns the 'CloseDocument' gui item.
0184  * @since 4.3
0185  */
0186 KWIDGETSADDONS_EXPORT KGuiItem closeDocument();
0187 
0188 /**
0189  * Returns the 'Print' gui item.
0190  */
0191 KWIDGETSADDONS_EXPORT KGuiItem print();
0192 
0193 /**
0194  * Returns the 'Properties' gui item.
0195  */
0196 KWIDGETSADDONS_EXPORT KGuiItem properties();
0197 
0198 /**
0199  * Returns the 'Reset' gui item.
0200  */
0201 KWIDGETSADDONS_EXPORT KGuiItem reset();
0202 
0203 /**
0204  * Returns the 'Overwrite' gui item.
0205  */
0206 KWIDGETSADDONS_EXPORT KGuiItem overwrite();
0207 
0208 /**
0209  * Returns a KGuiItem suiting for cases where code or functionality
0210  * runs under root privileges. Used in conjunction with KConfig Modules.
0211  */
0212 KWIDGETSADDONS_EXPORT KGuiItem adminMode();
0213 
0214 /**
0215  * Returns the 'Continue' gui item. The short name is due to 'continue' being a
0216  * reserved word in the C++ language.
0217  */
0218 KWIDGETSADDONS_EXPORT KGuiItem cont();
0219 
0220 /**
0221  * Returns the 'Delete' gui item. The short name is due to 'delete' being a
0222  * reserved word in the C++ language.
0223  */
0224 KWIDGETSADDONS_EXPORT KGuiItem del();
0225 
0226 /**
0227  * Returns the 'Open' gui item.
0228  */
0229 KWIDGETSADDONS_EXPORT KGuiItem open();
0230 
0231 /**
0232  * Returns the 'Back' gui item, like Konqueror's back button.
0233  * This GUI item can optionally honor the user's setting for BiDi, so the
0234  * icon for right-to-left languages (Hebrew and Arab) has the arrow
0235  * pointing in the opposite direction.
0236  * By default the arrow points in the Western 'back' direction (i.e.
0237  * to the left). This is because usually you only want the Bidi aware
0238  * GUI item if you also want the 'forward' item. Those two are available
0239  * in the separate backAndForward() method.
0240  */
0241 KWIDGETSADDONS_EXPORT KGuiItem back(BidiMode useBidi = IgnoreRTL);
0242 
0243 /**
0244  * Returns the 'Forward' gui item, like Konqueror's forward
0245  * button. This GUI item can optionally honor the user's setting for BiDi,
0246  * so the icon for right-to-left languages (Hebrew and Arab) has the arrow
0247  * pointing in the opposite direction.
0248  * By default the arrow points in the Western 'forward' direction (i.e.
0249  * to the right). This is because usually you only want the Bidi aware
0250  * GUI item if you also want the 'back' item. Those two are available
0251  * in the separate backAndForward() method.
0252  */
0253 KWIDGETSADDONS_EXPORT KGuiItem forward(BidiMode useBidi = IgnoreRTL);
0254 
0255 /**
0256  * Returns the 'Configure' gui item.
0257  */
0258 KWIDGETSADDONS_EXPORT KGuiItem configure();
0259 
0260 /**
0261  * Return both a back and a forward gui item. This function always returns
0262  * items that are aware of the Right-to-Left setting for Arab and Hebrew
0263  * locales. If you have a reason for wanting the 'Western' back/forward
0264  * buttons, please use the back() and forward() items instead.
0265  */
0266 KWIDGETSADDONS_EXPORT QPair<KGuiItem, KGuiItem> backAndForward();
0267 
0268 /**
0269  * Returns the 'Quit' gui item.
0270  */
0271 KWIDGETSADDONS_EXPORT KGuiItem quit();
0272 
0273 /**
0274  * Returns the 'Find' gui item.
0275  */
0276 KWIDGETSADDONS_EXPORT KGuiItem find();
0277 
0278 /**
0279  * Returns the 'Stop' gui item.
0280  */
0281 KWIDGETSADDONS_EXPORT KGuiItem stop();
0282 
0283 /**
0284  * Returns the 'Add' gui item.
0285  */
0286 KWIDGETSADDONS_EXPORT KGuiItem add();
0287 
0288 /**
0289  * Returns the 'Remove' gui item.
0290  */
0291 KWIDGETSADDONS_EXPORT KGuiItem remove();
0292 
0293 /**
0294  * Returns the 'Test' gui item.
0295  */
0296 KWIDGETSADDONS_EXPORT KGuiItem test();
0297 
0298 KWIDGETSADDONS_EXPORT void assign(QPushButton *button, StandardItem item);
0299 }
0300 
0301 #endif