1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> |
3 | (C) 1999 Simon Hausmann <hausmann@kde.org> |
4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> |
5 | (C) 2000 Kurt Granroth <granroth@kde.org> |
6 | (C) 2000 Michael Koch <koch@kde.org> |
7 | (C) 2001 Holger Freyther <freyther@kde.org> |
8 | (C) 2002 Ellis Whitehead <ellis@kde.org> |
9 | (C) 2003 Andras Mantia <amantia@kde.org> |
10 | (C) 2005-2006 Hamish Rodda <rodda@kde.org> |
11 | |
12 | This library is free software; you can redistribute it and/or |
13 | modify it under the terms of the GNU Library General Public |
14 | License version 2 as published by the Free Software Foundation. |
15 | |
16 | This library is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | Library General Public License for more details. |
20 | |
21 | You should have received a copy of the GNU Library General Public License |
22 | along with this library; see the file COPYING.LIB. If not, write to |
23 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 | Boston, MA 02110-1301, USA. |
25 | */ |
26 | |
27 | #ifndef KTOGGLEACTION_H |
28 | #define KTOGGLEACTION_H |
29 | |
30 | #include <kaction.h> |
31 | |
32 | class KGuiItem; |
33 | |
34 | /** |
35 | * @short Checkbox like action. |
36 | * |
37 | * This action provides two states: checked or not. |
38 | * |
39 | */ |
40 | class KDEUI_EXPORT KToggleAction : public KAction |
41 | { |
42 | Q_OBJECT |
43 | |
44 | public: |
45 | /** |
46 | * Constructs an action with the specified parent. |
47 | * |
48 | * @param parent The action's parent object. |
49 | */ |
50 | explicit KToggleAction( QObject *parent ); |
51 | |
52 | /** |
53 | * Constructs an action with text; a shortcut may be specified by |
54 | * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) |
55 | * |
56 | * This is the most common KAction used when you do not have a |
57 | * corresponding icon (note that it won't appear in the current version |
58 | * of the "Edit ToolBar" dialog, because an action needs an icon to be |
59 | * plugged in a toolbar...). |
60 | * |
61 | * @param text The text that will be displayed. |
62 | * @param parent The action's parent object. |
63 | */ |
64 | KToggleAction( const QString& text, QObject *parent ); |
65 | |
66 | /** |
67 | * Constructs an action with text and an icon; a shortcut may be specified by |
68 | * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) |
69 | * |
70 | * This is the other common KAction used. Use it when you |
71 | * \e do have a corresponding icon. |
72 | * |
73 | * @param icon The icon to display. |
74 | * @param text The text that will be displayed. |
75 | * @param parent The action's parent object. |
76 | */ |
77 | KToggleAction( const KIcon& icon, const QString& text, QObject *parent ); |
78 | |
79 | /** |
80 | * Destructor |
81 | */ |
82 | virtual ~KToggleAction(); |
83 | |
84 | /** |
85 | * Defines the text (and icon, tooltip, whatsthis) that should be displayed |
86 | * instead of the normal text, when the action is checked. |
87 | * Note that this does <em>not</em> replace the check box in front of the |
88 | * menu. So you should not use it to replace the text "Show <foo>" with |
89 | * "Hide <foo>", for example. |
90 | * |
91 | * If hasIcon(), the icon is kept for the 'checked state', unless |
92 | * @p checkedItem defines an icon explicitly. Same thing for tooltip and whatsthis. |
93 | */ |
94 | void setCheckedState( const KGuiItem& checkedItem ); |
95 | |
96 | protected Q_SLOTS: |
97 | virtual void slotToggled( bool checked ); |
98 | |
99 | private: |
100 | class Private; |
101 | Private* const d; |
102 | }; |
103 | |
104 | #endif |
105 | |