KWidgetsAddons

ktoggleaction.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <[email protected]>
4  SPDX-FileCopyrightText: 1999 Simon Hausmann <[email protected]>
5  SPDX-FileCopyrightText: 2000 Nicolas Hadacek <[email protected]>
6  SPDX-FileCopyrightText: 2000 Kurt Granroth <[email protected]>
7  SPDX-FileCopyrightText: 2000 Michael Koch <[email protected]>
8  SPDX-FileCopyrightText: 2001 Holger Freyther <[email protected]>
9  SPDX-FileCopyrightText: 2002 Ellis Whitehead <[email protected]>
10  SPDX-FileCopyrightText: 2003 Andras Mantia <[email protected]>
11  SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <[email protected]>
12 
13  SPDX-License-Identifier: LGPL-2.0-only
14 */
15 
16 #ifndef KTOGGLEACTION_H
17 #define KTOGGLEACTION_H
18 
19 #include <QAction>
20 #include <memory>
21 
22 #include <kwidgetsaddons_export.h>
23 
24 class KGuiItem;
25 class KToggleActionPrivate;
26 
27 /**
28  * @class KToggleAction ktoggleaction.h KToggleAction
29  *
30  * @short Checkbox like action.
31  *
32  * This action provides two states: checked or not.
33  *
34  */
35 class KWIDGETSADDONS_EXPORT KToggleAction : public QAction
36 {
37  Q_OBJECT
38 
39 public:
40  /**
41  * Constructs an action with the specified parent.
42  *
43  * @param parent The action's parent object.
44  */
45  explicit KToggleAction(QObject *parent);
46 
47  /**
48  * Constructs an action with text; a shortcut may be specified by
49  * the ampersand character (e.g.\ "&Option" creates a shortcut with key \e O )
50  *
51  * This is the most common QAction used when you do not have a
52  * corresponding icon (note that it won't appear in the current version
53  * of the "Edit ToolBar" dialog, because an action needs an icon to be
54  * plugged in a toolbar...).
55  *
56  * @param text The text that will be displayed.
57  * @param parent The action's parent object.
58  */
59  KToggleAction(const QString &text, QObject *parent);
60 
61  /**
62  * Constructs an action with text and an icon; a shortcut may be specified by
63  * the ampersand character (e.g.\ "&Option" creates a shortcut with key \e O )
64  *
65  * This is the other common QAction used. Use it when you
66  * \e do have a corresponding icon.
67  *
68  * @param icon The icon to display.
69  * @param text The text that will be displayed.
70  * @param parent The action's parent object.
71  */
72  KToggleAction(const QIcon &icon, const QString &text, QObject *parent);
73 
74  /**
75  * Destructor
76  */
77  virtual ~KToggleAction();
78 
79  /**
80  * Defines the text (and icon, tooltip, whatsthis) that should be displayed
81  * instead of the normal text, when the action is checked.
82  * Note that this does <em>not</em> replace the check box in front of the
83  * menu. So you should not use it to replace the text "Show <foo>" with
84  * "Hide <foo>", for example.
85  *
86  * If hasIcon(), the icon is kept for the 'checked state', unless
87  * @p checkedItem defines an icon explicitly. Same thing for tooltip and whatsthis.
88  */
89  void setCheckedState(const KGuiItem &checkedItem);
90 
91 protected Q_SLOTS:
92  virtual void slotToggled(bool checked);
93 
94 protected:
95  KToggleAction(KToggleActionPrivate &dd, QObject *parent);
96 
97 private:
98  friend class KToggleFullScreenAction;
99  Q_DECLARE_PRIVATE_D(d, KToggleAction)
100  std::unique_ptr<class KToggleActionPrivate> const d;
101  // KF6 TODO: change private d to protected d_ptr, use normal Q_DECLARE_PRIVATE, remove friend
102 };
103 
104 #endif
An abstract class for setting the text, icon, tooltip and WhatsThis data on a GUI item (e...
Definition: kguiitem.h:33
Checkbox like action.
Definition: ktoggleaction.h:35
An action for switching between to/from full screen mode.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Apr 22 2021 22:44:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.