| 1 | /* |
|---|---|
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2010 Aurélien Gâteau <agateau@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | */ |
| 7 | #ifndef KDUALACTION_P_H |
| 8 | #define KDUALACTION_P_H |
| 9 | |
| 10 | #include "kguiitem.h" |
| 11 | |
| 12 | class KDualActionPrivate |
| 13 | { |
| 14 | public: |
| 15 | KDualAction *q; |
| 16 | |
| 17 | KGuiItem items[2]; |
| 18 | bool autoToggle; |
| 19 | bool isActive; |
| 20 | |
| 21 | void init(KDualAction *q_ptr); |
| 22 | void updateFromCurrentState(); |
| 23 | KGuiItem &item(bool active) |
| 24 | { |
| 25 | return active ? items[1] : items[0]; |
| 26 | } |
| 27 | void slotTriggered(); |
| 28 | |
| 29 | void updatedItem(bool active) |
| 30 | { |
| 31 | if (active == isActive) { |
| 32 | updateFromCurrentState(); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | void setGuiItem(bool active, const KGuiItem &_item) |
| 37 | { |
| 38 | item(active) = _item; |
| 39 | updatedItem(active); |
| 40 | } |
| 41 | |
| 42 | void setIcon(bool active, const QIcon &icon) |
| 43 | { |
| 44 | item(active).setIcon(icon); |
| 45 | updatedItem(active); |
| 46 | } |
| 47 | |
| 48 | void setText(bool active, const QString &text) |
| 49 | { |
| 50 | item(active).setText(text); |
| 51 | updatedItem(active); |
| 52 | } |
| 53 | |
| 54 | void setToolTip(bool active, const QString &toolTip) |
| 55 | { |
| 56 | item(active).setToolTip(toolTip); |
| 57 | updatedItem(active); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | #endif /* KDUALACTION_P_H */ |
| 62 |
