2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_TAB_BAR_H
|
|
|
|
#define QSK_TAB_BAR_H
|
|
|
|
|
|
|
|
#include "QskBox.h"
|
|
|
|
|
|
|
|
class QskTabButton;
|
|
|
|
class QskTextOptions;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskTabBar : public QskBox
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2019-04-17 16:33:17 +02:00
|
|
|
Q_PROPERTY( Qsk::Position position READ position
|
|
|
|
WRITE setPosition NOTIFY positionChanged FINAL )
|
|
|
|
|
|
|
|
Q_PROPERTY( Qt::Orientation orientation READ orientation )
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2020-03-13 07:39:31 +01:00
|
|
|
Q_PROPERTY( bool autoScrollFocusButton READ autoScrollFocusButton
|
|
|
|
WRITE setAutoScrollFocusedButton NOTIFY autoScrollFocusedButtonChanged FINAL )
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
Q_PROPERTY( int count READ count NOTIFY countChanged FINAL )
|
|
|
|
|
|
|
|
Q_PROPERTY( int currentIndex READ currentIndex
|
|
|
|
WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL )
|
|
|
|
|
|
|
|
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
|
|
|
WRITE setTextOptions NOTIFY textOptionsChanged )
|
|
|
|
|
|
|
|
using Inherited = QskBox;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2017-07-21 18:21:34 +02:00
|
|
|
QSK_SUBCONTROLS( Panel )
|
|
|
|
|
|
|
|
QskTabBar( QQuickItem* parent = nullptr );
|
2019-04-17 16:33:17 +02:00
|
|
|
QskTabBar( Qsk::Position, QQuickItem* parent = nullptr );
|
2018-07-31 17:32:25 +02:00
|
|
|
|
|
|
|
~QskTabBar() override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2019-04-17 16:33:17 +02:00
|
|
|
void setPosition( Qsk::Position );
|
|
|
|
Qsk::Position position() const;
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
Qt::Orientation orientation() const;
|
|
|
|
|
2020-03-13 07:39:31 +01:00
|
|
|
void setAutoScrollFocusedButton( bool on );
|
|
|
|
bool autoScrollFocusButton() const;
|
|
|
|
|
|
|
|
void ensureButtonVisible( const QskTabButton* );
|
|
|
|
|
2017-07-21 18:21:34 +02: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 10:27:28 +01:00
|
|
|
Q_INVOKABLE void clear( bool autoDelete = false );
|
2017-07-21 18:21:34 +02: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;
|
|
|
|
|
2019-04-18 16:17:35 +02:00
|
|
|
QskAspect::Placement effectivePlacement() const override;
|
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
QskAspect::Subcontrol effectiveSubcontrol(
|
2017-07-21 18:21:34 +02:00
|
|
|
QskAspect::Subcontrol ) const override;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public Q_SLOTS:
|
2017-07-21 18:21:34 +02:00
|
|
|
void setCurrentIndex( int index );
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_SIGNALS:
|
2017-07-21 18:21:34 +02:00
|
|
|
void currentIndexChanged( int index );
|
2019-04-17 16:33:17 +02:00
|
|
|
void countChanged( int );
|
|
|
|
void textOptionsChanged( const QskTextOptions& );
|
|
|
|
void positionChanged( Qsk::Position );
|
2020-03-13 07:39:31 +01:00
|
|
|
void autoScrollFocusedButtonChanged( bool );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
protected:
|
2018-07-31 17:32:25 +02:00
|
|
|
void componentComplete() override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2019-02-13 10:27:23 +01:00
|
|
|
void adjustCurrentIndex();
|
2017-07-21 18:21:34 +02: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 16:17:35 +02:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
#endif
|