KWidgetsAddons

ktoggleaction.cpp
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: 2002 Joseph Wenninger <jowenn@kde.org>
11 SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
12 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
13
14 SPDX-License-Identifier: LGPL-2.0-only
15*/
16
17#include "ktoggleaction.h"
18#include "ktoggleaction_p.h"
19
21 : KToggleAction(*new KToggleActionPrivate(this), parent)
22{
23}
24
25KToggleAction::KToggleAction(KToggleActionPrivate &dd, QObject *parent)
26 : QAction(parent)
27 , d_ptr(&dd)
28{
30
31 d->init();
32}
33
35 : QAction(parent)
36 , d_ptr(new KToggleActionPrivate(this))
37{
39
41 d->init();
42}
43
44KToggleAction::KToggleAction(const QIcon &icon, const QString &text, QObject *parent)
45 : QAction(parent)
46 , d_ptr(new KToggleActionPrivate(this))
47{
49
52 d->init();
53}
54
56
58{
60
61 delete d->checkedGuiItem;
62 d->checkedGuiItem = new KGuiItem(checkedItem);
63}
64
65void KToggleAction::slotToggled(bool)
66{
68
69 if (d->checkedGuiItem) {
70 QString string = d->checkedGuiItem->text();
71 d->checkedGuiItem->setText(text());
72 setText(string);
73
74 string = d->checkedGuiItem->toolTip();
75 d->checkedGuiItem->setToolTip(toolTip());
76 setToolTip(string);
77
78 if (d->checkedGuiItem->hasIcon()) {
79 QIcon icon = d->checkedGuiItem->icon();
80 d->checkedGuiItem->setIcon(this->icon());
81 QAction::setIcon(icon);
82 }
83 }
84}
85
86#include "moc_ktoggleaction.cpp"
An abstract class for setting the text, icon, tooltip and WhatsThis data on a GUI item (e....
Definition kguiitem.h:34
Checkbox like action.
void setCheckedState(const KGuiItem &checkedItem)
Defines the text (and icon, tooltip, whatsthis) that should be displayed instead of the normal text,...
~KToggleAction() override
Destructor.
KToggleAction(QObject *parent)
Constructs an action with the specified parent.
void setIcon(const QIcon &icon)
void setText(const QString &text)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:19:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.