2017-07-21 16:21:34 +00:00
|
|
|
/******************************************************************************
|
2024-01-17 13:31:45 +00:00
|
|
|
* QSkinny - Copyright (C) The authors
|
2023-04-06 07:23:37 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2017-07-21 16:21:34 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_TAB_BAR_H
|
|
|
|
#define QSK_TAB_BAR_H
|
|
|
|
|
|
|
|
#include "QskBox.h"
|
2020-12-15 06:21:12 +00:00
|
|
|
#include "QskNamespace.h"
|
2017-07-21 16:21:34 +00:00
|
|
|
|
|
|
|
class QskTabButton;
|
|
|
|
class QskTextOptions;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskTabBar : public QskBox
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2022-07-15 08:44:32 +00:00
|
|
|
Q_PROPERTY( Qt::Edge edge READ edge
|
|
|
|
WRITE setEdge RESET resetEdge NOTIFY edgeChanged FINAL )
|
2019-04-17 14:33:17 +00:00
|
|
|
|
|
|
|
Q_PROPERTY( Qt::Orientation orientation READ orientation )
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2020-03-13 06:39:31 +00:00
|
|
|
Q_PROPERTY( bool autoScrollFocusButton READ autoScrollFocusButton
|
|
|
|
WRITE setAutoScrollFocusedButton NOTIFY autoScrollFocusedButtonChanged FINAL )
|
|
|
|
|
2020-03-13 13:50:09 +00:00
|
|
|
Q_PROPERTY( bool autoFitTabs READ autoFitTabs
|
|
|
|
WRITE setAutoFitTabs NOTIFY autoFitTabsChanged FINAL )
|
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
Q_PROPERTY( int count READ count NOTIFY countChanged FINAL )
|
|
|
|
|
|
|
|
Q_PROPERTY( int currentIndex READ currentIndex
|
2024-02-23 22:44:07 +00:00
|
|
|
WRITE setCurrentIndex NOTIFY currentIndexChanged USER true FINAL )
|
2017-07-21 16:21:34 +00:00
|
|
|
|
|
|
|
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
|
|
|
WRITE setTextOptions NOTIFY textOptionsChanged )
|
|
|
|
|
|
|
|
using Inherited = QskBox;
|
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
public:
|
2017-07-21 16:21:34 +00:00
|
|
|
QSK_SUBCONTROLS( Panel )
|
|
|
|
|
|
|
|
QskTabBar( QQuickItem* parent = nullptr );
|
2022-04-17 10:37:13 +00:00
|
|
|
QskTabBar( Qt::Edge, QQuickItem* parent = nullptr );
|
2018-07-31 15:32:25 +00:00
|
|
|
|
|
|
|
~QskTabBar() override;
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2022-04-17 10:37:13 +00:00
|
|
|
void setEdge( Qt::Edge );
|
2022-07-15 08:44:32 +00:00
|
|
|
void resetEdge();
|
2022-04-17 10:37:13 +00:00
|
|
|
Qt::Edge edge() const;
|
2019-04-17 14:33:17 +00:00
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
Qt::Orientation orientation() const;
|
|
|
|
|
2020-03-13 13:50:09 +00:00
|
|
|
void setAutoScrollFocusedButton( bool );
|
2020-03-13 06:39:31 +00:00
|
|
|
bool autoScrollFocusButton() const;
|
|
|
|
|
2020-03-13 13:50:09 +00:00
|
|
|
void setAutoFitTabs( bool );
|
|
|
|
bool autoFitTabs() const;
|
|
|
|
|
2020-03-13 06:39:31 +00:00
|
|
|
void ensureButtonVisible( const QskTabButton* );
|
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
void setTextOptions( const QskTextOptions& );
|
|
|
|
QskTextOptions textOptions() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE int addTab( const QString& text );
|
|
|
|
Q_INVOKABLE int insertTab( int index, const QString& text );
|
|
|
|
|
|
|
|
Q_INVOKABLE int addTab( QskTabButton* );
|
|
|
|
Q_INVOKABLE int insertTab( int index, QskTabButton* );
|
|
|
|
|
|
|
|
Q_INVOKABLE void removeTab( int index );
|
2020-03-10 09:27:28 +00:00
|
|
|
Q_INVOKABLE void clear( bool autoDelete = false );
|
2017-07-21 16:21:34 +00:00
|
|
|
|
|
|
|
bool isTabEnabled( int index ) const;
|
|
|
|
void setTabEnabled( int index, bool );
|
|
|
|
|
|
|
|
int currentIndex() const;
|
|
|
|
int count() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE QskTabButton* buttonAt( int );
|
|
|
|
Q_INVOKABLE const QskTabButton* buttonAt( int ) const;
|
|
|
|
|
|
|
|
Q_INVOKABLE QskTabButton* currentButton();
|
|
|
|
Q_INVOKABLE const QskTabButton* currentButton() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE QString currentButtonText() const;
|
|
|
|
Q_INVOKABLE QString buttonTextAt( int index ) const;
|
|
|
|
|
|
|
|
int indexOf( const QskTabButton* ) const;
|
|
|
|
Q_INVOKABLE int indexOf( QskTabButton* ) const;
|
|
|
|
|
2023-02-15 15:37:54 +00:00
|
|
|
QskAspect::Variation effectiveVariation() const override;
|
2019-04-18 14:17:35 +00:00
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
public Q_SLOTS:
|
2017-07-21 16:21:34 +00:00
|
|
|
void setCurrentIndex( int index );
|
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
Q_SIGNALS:
|
2017-07-21 16:21:34 +00:00
|
|
|
void currentIndexChanged( int index );
|
2021-02-19 11:31:00 +00:00
|
|
|
void buttonClicked( int index );
|
2019-04-17 14:33:17 +00:00
|
|
|
void countChanged( int );
|
|
|
|
void textOptionsChanged( const QskTextOptions& );
|
2022-04-17 10:37:13 +00:00
|
|
|
void edgeChanged( Qt::Edge );
|
2020-03-13 06:39:31 +00:00
|
|
|
void autoScrollFocusedButtonChanged( bool );
|
2020-03-13 13:50:09 +00:00
|
|
|
void autoFitTabsChanged( bool );
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
protected:
|
2018-07-31 15:32:25 +00:00
|
|
|
void componentComplete() override;
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2021-08-04 13:06:04 +00:00
|
|
|
QskAspect::Subcontrol substitutedSubcontrol(
|
|
|
|
QskAspect::Subcontrol ) const override;
|
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
private:
|
2019-02-13 09:27:23 +00:00
|
|
|
void adjustCurrentIndex();
|
2021-02-19 11:31:00 +00:00
|
|
|
void handleButtonClick();
|
2017-07-21 16:21:34 +00:00
|
|
|
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Qml does not like const versions
|
|
|
|
inline int QskTabBar::indexOf( const QskTabButton* tabButton ) const
|
|
|
|
{
|
|
|
|
return QskTabBar::indexOf( const_cast< QskTabButton* >( tabButton ) );
|
|
|
|
}
|
2019-04-18 14:17:35 +00:00
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
#endif
|