QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskMenu.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_MENU_H
7#define QSK_MENU_H
8
9#include "QskPopup.h"
10#include <qstringlist.h>
11
12class QskTextOptions;
13class QskLabelData;
14class QUrl;
15
16class QSK_EXPORT QskMenu : public QskPopup
17{
18 Q_OBJECT
19
20 Q_PROPERTY( QPointF origin READ origin
21 WRITE setOrigin NOTIFY originChanged )
22
23 Q_PROPERTY( bool cascading READ isCascading WRITE setCascading
24 RESET resetCascading NOTIFY cascadingChanged )
25
26 Q_PROPERTY( bool wrapping READ isWrapping
27 WRITE setWrapping NOTIFY wrappingChanged )
28
29 Q_PROPERTY( QVector< QskLabelData > options READ options
30 WRITE setOptions NOTIFY optionsChanged )
31
32 Q_PROPERTY( int currentIndex READ currentIndex
33 WRITE setCurrentIndex NOTIFY currentIndexChanged )
34
35 Q_PROPERTY( int triggeredIndex READ triggeredIndex NOTIFY triggered )
36
37 Q_PROPERTY( QString triggeredText READ triggeredText NOTIFY triggered )
38 Q_PROPERTY( QString currentText READ currentText NOTIFY currentIndexChanged )
39
40 using Inherited = QskPopup;
41
42 public:
43 QSK_SUBCONTROLS( Panel, Segment, Cursor, Text, Icon, Separator )
44 QSK_STATES( Selected, Pressed )
45
46 QskMenu( QQuickItem* parentItem = nullptr );
47 ~QskMenu() override;
48
49 bool isCascading() const;
50 void setCascading( bool );
51 void resetCascading();
52
53 bool isWrapping() const;
54 void setWrapping( bool );
55
56 void setOrigin( const QPointF& );
57 QPointF origin() const;
58
59 void setTextOptions( const QskTextOptions& );
60 QskTextOptions textOptions() const;
61
62 int addOption( const QString&, const QString& );
63 int addOption( const QUrl&, const QString& );
64 int addOption( const QskLabelData& );
65 void addSeparator();
66
67 void setOptions( const QVector< QskLabelData >& );
68 void setOptions( const QStringList& );
69
70 QVector< QskLabelData > options() const;
71 QskLabelData optionAt( int ) const;
72
73 QVector< int > separators() const;
74 QVector< int > actions() const;
75
76 int currentIndex() const;
77
78 QString currentText() const;
79
80 int triggeredIndex() const;
81 QString triggeredText() const;
82
83 QRectF focusIndicatorRect() const override;
84
85 QRectF cellRect( int index ) const;
86 int indexAtPosition( const QPointF& ) const;
87
88 bool isPressed() const;
89
90 QRectF clipRect() const override;
91 QskAspect fadingAspect() const override;
92
93 Q_INVOKABLE int exec();
94
95 Q_SIGNALS:
96 void wrappingChanged( bool );
97 void cascadingChanged( bool );
98 void originChanged( const QPointF& );
99
100 void triggered( int index );
101 void currentIndexChanged( int );
102
103 void optionsChanged();
104
105 public Q_SLOTS:
106 void setCurrentIndex( int );
107 void clear();
108
109 protected:
110 void keyPressEvent( QKeyEvent* ) override;
111 void keyReleaseEvent( QKeyEvent* ) override;
112
113 void hoverEnterEvent( QHoverEvent* ) override;
114 void hoverMoveEvent( QHoverEvent* ) override;
115 void hoverLeaveEvent( QHoverEvent* ) override;
116
117#ifndef QT_NO_WHEELEVENT
118 void wheelEvent( QWheelEvent* ) override;
119#endif
120
121 void mousePressEvent( QMouseEvent* ) override;
122 void mouseUngrabEvent() override;
123 void mouseReleaseEvent( QMouseEvent* ) override;
124
125 void aboutToShow() override;
126 void trigger( int );
127
128 void updateResources() override;
129 void updateNode( QSGNode* ) override;
130
131 private:
132 void traverse( int steps );
133
134 class PrivateData;
135 std::unique_ptr< PrivateData > m_data;
136};
137
138#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15
void hoverLeaveEvent(QHoverEvent *) override
virtual QRectF focusIndicatorRect() const
void hoverEnterEvent(QHoverEvent *) override
void mouseUngrabEvent() override
Definition QskItem.cpp:1044
void aboutToShow() override
Definition QskPopup.cpp:599
virtual void updateNode(QSGNode *)