qskinny/src/controls/QskTabView.h

106 lines
2.7 KiB
C
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
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_VIEW_H
#define QSK_TAB_VIEW_H
#include "QskControl.h"
#include "QskNamespace.h"
2017-07-21 16:21:34 +00:00
class QskTabBar;
class QskTabButton;
class QSK_EXPORT QskTabView : public QskControl
{
Q_OBJECT
2020-03-13 12:59:17 +00:00
Q_PROPERTY( QskTabBar* tabBar READ tabBar )
Q_PROPERTY( Qt::Edge tabBarEdge READ tabBarEdge
WRITE setTabBarEdge NOTIFY tabBarEdgeChanged FINAL )
2020-03-13 13:50:09 +00:00
Q_PROPERTY( bool autoFitTabs READ autoFitTabs
WRITE setAutoFitTabs NOTIFY autoFitTabsChanged FINAL )
Q_PROPERTY( Qt::Orientation orientation READ orientation )
2017-07-21 16:21:34 +00:00
Q_PROPERTY( int count READ count NOTIFY countChanged FINAL )
2018-08-03 06:15:28 +00:00
2017-07-21 16:21:34 +00:00
Q_PROPERTY( int currentIndex READ currentIndex
WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL )
typedef QskControl Inherited;
2018-08-03 06:15:28 +00:00
public:
2017-07-21 16:21:34 +00:00
QSK_SUBCONTROLS( TabBar, Page )
QskTabView( QQuickItem* parent = nullptr );
2018-07-31 15:32:25 +00:00
~QskTabView() override;
2017-07-21 16:21:34 +00:00
const QskTabBar* tabBar() const;
2020-03-13 12:59:17 +00:00
QskTabBar* tabBar();
2017-07-21 16:21:34 +00:00
void setTabBarEdge( Qt::Edge );
Qt::Edge tabBarEdge() const;
2020-03-13 13:50:09 +00:00
void setAutoFitTabs( bool );
bool autoFitTabs() const;
2017-07-21 16:21:34 +00:00
Qt::Orientation orientation() const;
2022-12-03 16:17:21 +00:00
Q_INVOKABLE int addTab( const QString&, QQuickItem* );
Q_INVOKABLE int insertTab( int index, const QString&, QQuickItem* );
2017-07-21 16:21:34 +00:00
2022-12-03 16:17:21 +00:00
Q_INVOKABLE void removeTab( int index );
Q_INVOKABLE void clear( bool autoDelete = false );
2017-07-21 16:21:34 +00:00
QQuickItem* pageAt( int index ) const;
int pageIndex( const QQuickItem* );
2017-07-21 16:21:34 +00:00
QQuickItem* currentPage() const;
2017-07-21 16:21:34 +00:00
int currentIndex() const;
int count() const;
QRectF tabRect() const;
QskAspect::Variation effectiveVariation() const override;
2020-08-10 12:24:42 +00:00
void setTabEnabled( int , bool );
bool isTabEnabled( int index ) const;
#if 1
// see: https://github.com/uwerat/qskinny/issues/283
int addTab( QskTabButton*, QQuickItem* );
int insertTab( int index, QskTabButton*, QQuickItem* );
QskTabButton* buttonAt( int index ) const;
int buttonIndex( const QskTabButton* );
QskTabButton* currentButton() const;
#endif
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 );
void countChanged( int );
void tabBarEdgeChanged( Qt::Edge );
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
bool event( QEvent* event ) override;
void updateLayout() override;
2017-07-21 16:21:34 +00:00
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
2019-09-05 13:16:33 +00:00
2018-08-03 06:15:28 +00:00
private:
2017-07-21 16:21:34 +00:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif