QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSegmentedBar.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_SEGMENTED_BAR_H
7#define QSK_SEGMENTED_BAR_H
8
9#include "QskControl.h"
10#include <qstringlist.h>
11
12class QskTextOptions;
13class QskLabelData;
14class QUrl;
15
16class QSK_EXPORT QskSegmentedBar : public QskControl
17{
18 Q_OBJECT
19
20 Q_PROPERTY( Qt::Orientation orientation READ orientation
21 WRITE setOrientation NOTIFY orientationChanged )
22
23 Q_PROPERTY( QVector< QskLabelData > options READ options
24 WRITE setOptions NOTIFY optionsChanged )
25
26 Q_PROPERTY( int count READ count )
27
28 Q_PROPERTY( int selectedIndex READ selectedIndex
29 WRITE setSelectedIndex NOTIFY selectedIndexChanged USER true )
30
31 Q_PROPERTY( int currentIndex READ currentIndex
32 WRITE setCurrentIndex NOTIFY currentIndexChanged )
33
34 Q_PROPERTY( QString currentText READ currentText )
35
36 using Inherited = QskControl;
37
38 public:
39 QSK_SUBCONTROLS( Panel, Splash, Segment, Separator, Cursor, Text, Icon )
40 QSK_STATES( Selected, Pressed )
41
42 QskSegmentedBar( QQuickItem* parent = nullptr );
43 QskSegmentedBar( Qt::Orientation, QQuickItem* parent = nullptr );
44
45 ~QskSegmentedBar() override;
46
47 void setOrientation( Qt::Orientation );
48 Qt::Orientation orientation() const;
49
50 void setTextOptions( const QskTextOptions& );
51 QskTextOptions textOptions() const;
52
53 int addOption( const QUrl&, const QString& );
54 int addOption( const QskLabelData& );
55
56 void setOptions( const QVector< QskLabelData >& );
57 void setOptions( const QStringList& );
58
59 QVector< QskLabelData > options() const;
60 QskLabelData optionAt( int ) const;
61
62 void clear();
63
64 int selectedIndex() const;
65 int currentIndex() const;
66
67 QString currentText() const;
68
69 int count() const;
70
71 void setSegmentEnabled( int, bool );
72 bool isSegmentEnabled( int ) const;
73
74 int indexAtPosition( const QPointF& ) const;
75
76 QRectF focusIndicatorRect() const override final;
78
79 public Q_SLOTS:
80 void setSelectedIndex( int index );
81 void setCurrentIndex( int index );
82
83 Q_SIGNALS:
84 void selectedIndexChanged( int );
85 void currentIndexChanged( int );
86 void optionsChanged();
87 void orientationChanged();
88
89 protected:
90 void mousePressEvent( QMouseEvent* ) override;
91 void mouseReleaseEvent( QMouseEvent* ) override;
92 void mouseUngrabEvent() override;
93
94 void keyPressEvent( QKeyEvent* ) override;
95 void keyReleaseEvent( QKeyEvent* ) override;
96
97 void hoverEnterEvent( QHoverEvent* ) override;
98 void hoverMoveEvent( QHoverEvent* ) override;
99 void hoverLeaveEvent( QHoverEvent* ) override;
100
101 void focusInEvent( QFocusEvent* ) override;
102 void focusOutEvent( QFocusEvent* ) override;
103
104 private:
105 int nextIndex( int index, bool forward ) const;
106
107 class PrivateData;
108 std::unique_ptr< PrivateData > m_data;
109};
110
111#endif
Variation
Some sort of variation.
Definition QskAspect.h:82
Base class of all controls.
Definition QskControl.h:23
void hoverLeaveEvent(QHoverEvent *) override
virtual QRectF focusIndicatorRect() const
void hoverEnterEvent(QHoverEvent *) override
void mouseUngrabEvent() override
Definition QskItem.cpp:1044
virtual QskAspect::Variation effectiveVariation() const