add StateIcon
This commit is contained in:
59
libs/widgets/stateicon.h
Normal file
59
libs/widgets/stateicon.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef stateicon_H
|
||||
#define stateicon_H
|
||||
|
||||
#include "iconedlabel.h"
|
||||
#include "qad_widgets_export.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
|
||||
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)
|
||||
|
||||
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<int> allStates() const;
|
||||
QString stateText(int st) const;
|
||||
QString stateIcon(int st) const;
|
||||
|
||||
int state() const { return m_state; }
|
||||
|
||||
private:
|
||||
void prepare();
|
||||
|
||||
QMap<int, QPair<QString, QString>> src_states;
|
||||
QMap<int, QPair<QString, QIcon>> prepared_states;
|
||||
int m_state = 0;
|
||||
|
||||
public slots:
|
||||
void setState(int newState);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user