QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskTabBar.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_TAB_BAR_H
7#define QSK_TAB_BAR_H
8
9#include "QskBox.h"
10#include "QskNamespace.h"
11
12class QskTabButton;
13class QskTextOptions;
14
15class QSK_EXPORT QskTabBar : public QskBox
16{
17 Q_OBJECT
18
19 Q_PROPERTY( Qt::Edge edge READ edge
20 WRITE setEdge RESET resetEdge NOTIFY edgeChanged FINAL )
21
22 Q_PROPERTY( Qt::Orientation orientation READ orientation )
23
24 Q_PROPERTY( bool autoScrollFocusButton READ autoScrollFocusButton
25 WRITE setAutoScrollFocusedButton NOTIFY autoScrollFocusedButtonChanged FINAL )
26
27 Q_PROPERTY( bool autoFitTabs READ autoFitTabs
28 WRITE setAutoFitTabs NOTIFY autoFitTabsChanged FINAL )
29
30 Q_PROPERTY( int count READ count NOTIFY countChanged FINAL )
31
32 Q_PROPERTY( int currentIndex READ currentIndex
33 WRITE setCurrentIndex NOTIFY currentIndexChanged USER true FINAL )
34
35 Q_PROPERTY( QskTextOptions textOptions READ textOptions
36 WRITE setTextOptions NOTIFY textOptionsChanged )
37
38 using Inherited = QskBox;
39
40 public:
41 QSK_SUBCONTROLS( Panel )
42
43 QskTabBar( QQuickItem* parent = nullptr );
44 QskTabBar( Qt::Edge, QQuickItem* parent = nullptr );
45
46 ~QskTabBar() override;
47
48 void setEdge( Qt::Edge );
49 void resetEdge();
50 Qt::Edge edge() const;
51
52 Qt::Orientation orientation() const;
53
54 void setAutoScrollFocusedButton( bool );
55 bool autoScrollFocusButton() const;
56
57 void setAutoFitTabs( bool );
58 bool autoFitTabs() const;
59
60 void ensureButtonVisible( const QskTabButton* );
61
62 void setTextOptions( const QskTextOptions& );
63 QskTextOptions textOptions() const;
64
65 Q_INVOKABLE int addTab( const QString& text );
66 Q_INVOKABLE int insertTab( int index, const QString& text );
67
68 Q_INVOKABLE int addTab( QskTabButton* );
69 Q_INVOKABLE int insertTab( int index, QskTabButton* );
70
71 Q_INVOKABLE void removeTab( int index );
72 Q_INVOKABLE void clear( bool autoDelete = false );
73
74 bool isTabEnabled( int index ) const;
75 void setTabEnabled( int index, bool );
76
77 int currentIndex() const;
78 int count() const;
79
80 Q_INVOKABLE QskTabButton* buttonAt( int );
81 Q_INVOKABLE const QskTabButton* buttonAt( int ) const;
82
83 Q_INVOKABLE QskTabButton* currentButton();
84 Q_INVOKABLE const QskTabButton* currentButton() const;
85
86 Q_INVOKABLE QString currentButtonText() const;
87 Q_INVOKABLE QString buttonTextAt( int index ) const;
88
89 int indexOf( const QskTabButton* ) const;
90 Q_INVOKABLE int indexOf( QskTabButton* ) const;
91
93
94 public Q_SLOTS:
95 void setCurrentIndex( int index );
96
97 Q_SIGNALS:
98 void currentIndexChanged( int index );
99 void buttonClicked( int index );
100 void countChanged( int );
101 void textOptionsChanged( const QskTextOptions& );
102 void edgeChanged( Qt::Edge );
103 void autoScrollFocusedButtonChanged( bool );
104 void autoFitTabsChanged( bool );
105
106 protected:
107 void componentComplete() override;
108
109 QskAspect::Subcontrol substitutedSubcontrol(
110 QskAspect::Subcontrol ) const override;
111
112 private:
113 void adjustCurrentIndex();
114 void handleButtonClick();
115
116 class PrivateData;
117 std::unique_ptr< PrivateData > m_data;
118};
119
120// Qml does not like const versions
121inline int QskTabBar::indexOf( const QskTabButton* tabButton ) const
122{
123 return QskTabBar::indexOf( const_cast< QskTabButton* >( tabButton ) );
124}
125
126#endif
Variation
Some sort of variation.
Definition QskAspect.h:82
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
Definition QskAspect.h:104
void componentComplete() override
Definition QskItem.cpp:272
virtual QskAspect::Variation effectiveVariation() const