qskinny/src/controls/QskTabBar.h

100 lines
2.7 KiB
C
Raw Normal View History

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
Q_PROPERTY( Qt::Orientation orientation READ orientation
WRITE setOrientation NOTIFY orientationChanged FINAL )
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 );
QskTabBar( Qt::Orientation, QQuickItem* parent = nullptr );
2018-07-31 17:32:25 +02:00
~QskTabBar() override;
2017-07-21 18:21:34 +02:00
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
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 );
Q_INVOKABLE void clear();
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;
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 );
void countChanged();
void textOptionsChanged();
void orientationChanged();
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 ) );
}
#endif