/* QAD - Qt ADvanced Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef stateicon_H #define stateicon_H #include "iconedlabel.h" #include "qad_widgets_export.h" #include class QAD_WIDGETS_EXPORT StateIcon: public IconedLabel { Q_OBJECT Q_PROPERTY(QString rawStates READ saveStates WRITE loadStates DESIGNABLE false) Q_PROPERTY(int state READ state WRITE setState) Q_PROPERTY(bool changeIcon READ isChangeIcon WRITE setChangeIcon) Q_PROPERTY(bool changeText READ isChangeText WRITE setChangeText) public: explicit StateIcon(QWidget * parent = nullptr); QString saveStates() const; void loadStates(const QString & ba); void clearStates(); void addState(int st, QString text, QIcon icon); void addState(int st, QString text, QString icon_path); QList allStates() const; QString stateText(int st) const; QString stateIcon(int st) const; bool isChangeIcon() const { return m_changeIcon; } void setChangeIcon(bool newChangeIcon); bool isChangeText() const { return m_changeText; } void setChangeText(bool newChangeText); int state() const { return m_state; } private: void prepare(); QMap> src_states; QMap> prepared_states; int m_state = 0; bool m_changeIcon = true, m_changeText = true; public slots: void setState(int newState); }; #endif