KWidgetsAddons

ktoggleaction.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org>
4 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
5 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org>
6 SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
7 SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org>
8 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
9 SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org>
10 SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
11 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
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
24class KGuiItem;
25class 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 */
35class KWIDGETSADDONS_EXPORT KToggleAction : public QAction
36{
37 Q_OBJECT
38
39public:
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 ~KToggleAction() override;
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
91protected Q_SLOTS:
92 virtual void slotToggled(bool checked);
93
94protected:
95 KWIDGETSADDONS_NO_EXPORT KToggleAction(KToggleActionPrivate &dd, QObject *parent);
96
97protected:
98 std::unique_ptr<class KToggleActionPrivate> const d_ptr;
99
100private:
101 Q_DECLARE_PRIVATE(KToggleAction)
102};
103
104#endif
An abstract class for setting the text, icon, tooltip and WhatsThis data on a GUI item (e....
Definition kguiitem.h:34
Checkbox like action.
~KToggleAction() override
Destructor.
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.