File indexing completed on 2024-04-28 15:32:02

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2010 Aurélien Gâteau <agateau@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 #ifndef KDUALACTION_P_H
0008 #define KDUALACTION_P_H
0009 
0010 #include "kguiitem.h"
0011 
0012 class KDualActionPrivate
0013 {
0014 public:
0015     KDualAction *q;
0016 
0017     KGuiItem items[2];
0018     bool autoToggle;
0019     bool isActive;
0020 
0021     void init(KDualAction *q_ptr);
0022     void updateFromCurrentState();
0023     KGuiItem &item(bool active)
0024     {
0025         return active ? items[1] : items[0];
0026     }
0027     void slotTriggered();
0028 
0029     void updatedItem(bool active)
0030     {
0031         if (active == isActive) {
0032             updateFromCurrentState();
0033         }
0034     }
0035 
0036     void setGuiItem(bool active, const KGuiItem &_item)
0037     {
0038         item(active) = _item;
0039         updatedItem(active);
0040     }
0041 
0042     void setIcon(bool active, const QIcon &icon)
0043     {
0044         item(active).setIcon(icon);
0045         updatedItem(active);
0046     }
0047 
0048     void setText(bool active, const QString &text)
0049     {
0050         item(active).setText(text);
0051         updatedItem(active);
0052     }
0053 
0054     void setToolTip(bool active, const QString &toolTip)
0055     {
0056         item(active).setToolTip(toolTip);
0057         updatedItem(active);
0058     }
0059 };
0060 
0061 #endif /* KDUALACTION_P_H */