KDeclarative

qiconitem.h
1 /*
2  SPDX-FileCopyrightText: 2011 Marco Martin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef QICONITEM_H
8 #define QICONITEM_H
9 
10 #include <QIcon>
11 #include <QQuickItem>
12 #include <QVariant>
13 
14 class QIconItem : public QQuickItem
15 {
16  Q_OBJECT
17 
18  Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged)
19  Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
20  Q_PROPERTY(int implicitWidth READ implicitWidth CONSTANT)
21  Q_PROPERTY(int implicitHeight READ implicitHeight CONSTANT)
22  Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
23  Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY stateChanged)
24 
25 public:
26 
27  enum State {
28  DefaultState,
29  ActiveState,
30  DisabledState,
31  SelectedState
32  };
33  Q_ENUM(State)
34 
35  explicit QIconItem(QQuickItem *parent=nullptr);
36  ~QIconItem() override;
37 
38  void setIcon(const QVariant &icon);
39  QIcon icon() const;
40 
41  QIconItem::State state() const;
42  void setState(State state);
43 
44  int implicitWidth() const;
45  int implicitHeight() const;
46 
47  void setSmooth(const bool smooth);
48  bool smooth() const;
49 
50  void setEnabled(bool enabled = true);
51  bool enabled() const;
52 
53  QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) override;
54 
55 Q_SIGNALS:
56  void iconChanged();
57  void smoothChanged();
58  void stateChanged(State state);
59 
60 protected:
61  void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
62 
63 private:
64  QIcon m_icon;
65  bool m_smooth;
66  State m_state;
67  bool m_changed;
68 };
69 
70 #endif
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
State
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 22:44:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.