/* This file is part of the KDE libraries SPDX-FileCopyrightText: 1999 Reginald Stadlbauer SPDX-FileCopyrightText: 1999 Simon Hausmann SPDX-FileCopyrightText: 2000 Nicolas Hadacek SPDX-FileCopyrightText: 2000 Kurt Granroth SPDX-FileCopyrightText: 2000 Michael Koch SPDX-FileCopyrightText: 2001 Holger Freyther SPDX-FileCopyrightText: 2002 Ellis Whitehead SPDX-FileCopyrightText: 2002 Joseph Wenninger SPDX-FileCopyrightText: 2003 Andras Mantia SPDX-FileCopyrightText: 2005-2006 Hamish Rodda SPDX-License-Identifier: LGPL-2.0-only */ #include "ktoggleaction.h" #include "ktoggleaction_p.h" KToggleAction::KToggleAction(QObject *parent) : KToggleAction(*new KToggleActionPrivate(this), parent) { } KToggleAction::KToggleAction(KToggleActionPrivate &dd, QObject *parent) : QAction(parent) , d_ptr(&dd) { Q_D(KToggleAction); d->init(); } KToggleAction::KToggleAction(const QString &text, QObject *parent) : QAction(parent) , d_ptr(new KToggleActionPrivate(this)) { Q_D(KToggleAction); setText(text); d->init(); } KToggleAction::KToggleAction(const QIcon &icon, const QString &text, QObject *parent) : QAction(parent) , d_ptr(new KToggleActionPrivate(this)) { Q_D(KToggleAction); setIcon(icon); setText(text); d->init(); } KToggleAction::~KToggleAction() = default; void KToggleAction::setCheckedState(const KGuiItem &checkedItem) { Q_D(KToggleAction); delete d->checkedGuiItem; d->checkedGuiItem = new KGuiItem(checkedItem); } void KToggleAction::slotToggled(bool) { Q_D(KToggleAction); if (d->checkedGuiItem) { QString string = d->checkedGuiItem->text(); d->checkedGuiItem->setText(text()); setText(string); string = d->checkedGuiItem->toolTip(); d->checkedGuiItem->setToolTip(toolTip()); setToolTip(string); if (d->checkedGuiItem->hasIcon()) { QIcon icon = d->checkedGuiItem->icon(); d->checkedGuiItem->setIcon(this->icon()); QAction::setIcon(icon); } } } #include "moc_ktoggleaction.cpp"