using Qt::Edge instead of Qsk::Position
This commit is contained in:
parent
15e04de169
commit
d0b926b868
@ -32,7 +32,7 @@ namespace
|
||||
: QskTabView( parent )
|
||||
{
|
||||
setMargins( 10 );
|
||||
setTabPosition( Qsk::Left );
|
||||
setTabBarEdge( Qt::LeftEdge );
|
||||
setAutoFitTabs( true );
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ int main( int argc, char* argv[] )
|
||||
auto tabView = new QskTabView();
|
||||
|
||||
tabView->setMargins( 10 );
|
||||
tabView->setTabPosition( Qsk::Left );
|
||||
tabView->setTabBarEdge( Qt::LeftEdge );
|
||||
tabView->setAutoFitTabs( true );
|
||||
|
||||
tabView->addTab( "Grid Layout", new GridLayoutPage() );
|
||||
|
@ -75,7 +75,8 @@ class GraphicLabel : public QskGraphicLabel
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
m_tabView = new QskTabView( Qsk::Left );
|
||||
m_tabView = new QskTabView();
|
||||
m_tabView->setTabBarEdge( Qt::LeftEdge );
|
||||
|
||||
const QString resourceDir( ":/qvg" );
|
||||
const QStringList icons = QDir( resourceDir ).entryList();
|
||||
|
@ -110,13 +110,14 @@ class TabView : public QskTabView
|
||||
|
||||
void rotate()
|
||||
{
|
||||
const Qsk::Position pos[] = { Qsk::Top, Qsk::Right, Qsk::Bottom, Qsk::Left };
|
||||
using namespace Qt;
|
||||
const Edge edges[] = { TopEdge, RightEdge, BottomEdge, LeftEdge };
|
||||
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
{
|
||||
if ( tabPosition() == pos[i] )
|
||||
if ( tabBarEdge() == edges[i] )
|
||||
{
|
||||
setTabPosition( pos[ ( i + 1 ) % 4 ] );
|
||||
setTabBarEdge( edges[ ( i + 1 ) % 4 ] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,11 @@ class QSK_EXPORT QskBoxBorderMetrics
|
||||
Q_PROPERTY( QskMargins widths READ widths WRITE setWidths )
|
||||
Q_PROPERTY( Qt::SizeMode sizeMode READ sizeMode WRITE setSizeMode )
|
||||
|
||||
Q_PROPERTY( qreal left READ left WRITE setLeft )
|
||||
Q_PROPERTY( qreal top READ top WRITE setTop )
|
||||
Q_PROPERTY( qreal right READ right WRITE setRight )
|
||||
Q_PROPERTY( qreal bottom READ bottom WRITE setBottom )
|
||||
|
||||
public:
|
||||
constexpr QskBoxBorderMetrics() noexcept;
|
||||
|
||||
@ -47,6 +52,16 @@ class QSK_EXPORT QskBoxBorderMetrics
|
||||
void setWidths( const QskMargins& ) noexcept;
|
||||
constexpr const QskMargins& widths() const noexcept;
|
||||
|
||||
constexpr qreal left() const noexcept;
|
||||
constexpr qreal top() const noexcept;
|
||||
constexpr qreal right() const noexcept;
|
||||
constexpr qreal bottom() const noexcept;
|
||||
|
||||
void setLeft( qreal ) noexcept;
|
||||
void setTop( qreal ) noexcept;
|
||||
void setRight( qreal ) noexcept;
|
||||
void setBottom( qreal ) noexcept;
|
||||
|
||||
void setSizeMode( Qt::SizeMode ) noexcept;
|
||||
constexpr Qt::SizeMode sizeMode() const noexcept;
|
||||
|
||||
@ -132,6 +147,46 @@ inline qreal QskBoxBorderMetrics::widthAt( Qt::Edge edge ) const noexcept
|
||||
return m_widths.marginAt( edge );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskBoxBorderMetrics::left() const noexcept
|
||||
{
|
||||
return m_widths.left();
|
||||
}
|
||||
|
||||
inline constexpr qreal QskBoxBorderMetrics::top() const noexcept
|
||||
{
|
||||
return m_widths.top();
|
||||
}
|
||||
|
||||
inline constexpr qreal QskBoxBorderMetrics::right() const noexcept
|
||||
{
|
||||
return m_widths.right();
|
||||
}
|
||||
|
||||
inline constexpr qreal QskBoxBorderMetrics::bottom() const noexcept
|
||||
{
|
||||
return m_widths.bottom();
|
||||
}
|
||||
|
||||
inline void QskBoxBorderMetrics::setLeft( qreal left ) noexcept
|
||||
{
|
||||
return m_widths.setLeft( left );
|
||||
}
|
||||
|
||||
inline void QskBoxBorderMetrics::setTop( qreal top ) noexcept
|
||||
{
|
||||
return m_widths.setTop( top );
|
||||
}
|
||||
|
||||
inline void QskBoxBorderMetrics::setRight( qreal right ) noexcept
|
||||
{
|
||||
return m_widths.setRight( right );
|
||||
}
|
||||
|
||||
inline void QskBoxBorderMetrics::setBottom( qreal bottom ) noexcept
|
||||
{
|
||||
return m_widths.setBottom( bottom );
|
||||
}
|
||||
|
||||
inline constexpr Qt::SizeMode QskBoxBorderMetrics::sizeMode() const noexcept
|
||||
{
|
||||
return m_sizeMode;
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
QSK_SUBCONTROL( QskTabBar, Panel )
|
||||
|
||||
static inline Qt::Orientation qskOrientation( int position )
|
||||
static inline Qt::Orientation qskOrientation( Qt::Edge edge )
|
||||
{
|
||||
if ( ( position == Qsk::Top ) || ( position == Qsk::Bottom ) )
|
||||
if ( ( edge == Qt::TopEdge ) || ( edge == Qt::BottomEdge ) )
|
||||
return Qt::Horizontal;
|
||||
else
|
||||
return Qt::Vertical;
|
||||
@ -250,8 +250,8 @@ namespace
|
||||
class QskTabBar::PrivateData
|
||||
{
|
||||
public:
|
||||
PrivateData( Qsk::Position position )
|
||||
: position( position )
|
||||
PrivateData( Qt::Edge edge )
|
||||
: edge( edge )
|
||||
{
|
||||
}
|
||||
|
||||
@ -274,21 +274,21 @@ class QskTabBar::PrivateData
|
||||
int currentIndex = -1;
|
||||
|
||||
QskTextOptions textOptions;
|
||||
uint position : 2;
|
||||
Qt::Edge edge;
|
||||
};
|
||||
|
||||
QskTabBar::QskTabBar( QQuickItem* parent )
|
||||
: QskTabBar( Qsk::Top, parent )
|
||||
: QskTabBar( Qt::TopEdge, parent )
|
||||
{
|
||||
}
|
||||
|
||||
QskTabBar::QskTabBar( Qsk::Position position, QQuickItem* parent )
|
||||
QskTabBar::QskTabBar( Qt::Edge edge, QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData( position ) )
|
||||
, m_data( new PrivateData( edge ) )
|
||||
{
|
||||
setAutoLayoutChildren( true );
|
||||
|
||||
const auto orientation = qskOrientation( position );
|
||||
const auto orientation = qskOrientation( edge );
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
initSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Fixed );
|
||||
@ -310,14 +310,14 @@ QskTabBar::~QskTabBar()
|
||||
{
|
||||
}
|
||||
|
||||
void QskTabBar::setTabPosition( Qsk::Position position )
|
||||
void QskTabBar::setEdge( Qt::Edge edge )
|
||||
{
|
||||
if ( position == m_data->position )
|
||||
if ( edge == m_data->edge )
|
||||
return;
|
||||
|
||||
m_data->position = position;
|
||||
m_data->edge = edge;
|
||||
|
||||
const auto orientation = qskOrientation( position );
|
||||
const auto orientation = qskOrientation( edge );
|
||||
|
||||
if ( orientation != m_data->buttonBox->orientation() )
|
||||
{
|
||||
@ -334,17 +334,17 @@ void QskTabBar::setTabPosition( Qsk::Position position )
|
||||
for ( int i = 0; i < count(); i++ )
|
||||
buttonAt( i )->update();
|
||||
|
||||
Q_EMIT tabPositionChanged( position );
|
||||
Q_EMIT edgeChanged( edge );
|
||||
}
|
||||
|
||||
Qsk::Position QskTabBar::tabPosition() const
|
||||
Qt::Edge QskTabBar::edge() const
|
||||
{
|
||||
return static_cast< Qsk::Position >( m_data->position );
|
||||
return m_data->edge;
|
||||
}
|
||||
|
||||
Qt::Orientation QskTabBar::orientation() const
|
||||
{
|
||||
return qskOrientation( m_data->position );
|
||||
return qskOrientation( m_data->edge );
|
||||
}
|
||||
|
||||
void QskTabBar::setAutoScrollFocusedButton( bool on )
|
||||
@ -363,7 +363,7 @@ bool QskTabBar::autoScrollFocusButton() const
|
||||
|
||||
void QskTabBar::setAutoFitTabs( bool on )
|
||||
{
|
||||
const auto orientation = qskOrientation( m_data->position );
|
||||
const auto orientation = qskOrientation( m_data->edge );
|
||||
int policy = m_data->buttonBox->sizePolicy( orientation );
|
||||
|
||||
if ( ( policy & QskSizePolicy::GrowFlag ) != on )
|
||||
@ -682,18 +682,18 @@ QskAspect::Subcontrol QskTabBar::substitutedSubcontrol(
|
||||
|
||||
QskAspect::Placement QskTabBar::effectivePlacement() const
|
||||
{
|
||||
switch ( m_data->position )
|
||||
switch ( m_data->edge )
|
||||
{
|
||||
case Qsk::Left:
|
||||
case Qt::LeftEdge:
|
||||
return QskAspect::Left;
|
||||
|
||||
case Qsk::Right:
|
||||
case Qt::RightEdge:
|
||||
return QskAspect::Right;
|
||||
|
||||
case Qsk::Top:
|
||||
case Qt::TopEdge:
|
||||
return QskAspect::Top;
|
||||
|
||||
case Qsk::Bottom:
|
||||
case Qt::BottomEdge:
|
||||
return QskAspect::Bottom;
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,7 @@ class QSK_EXPORT QskTabBar : public QskBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( Qsk::Position tabPosition READ tabPosition
|
||||
WRITE setTabPosition NOTIFY tabPositionChanged FINAL )
|
||||
Q_PROPERTY( Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged FINAL )
|
||||
|
||||
Q_PROPERTY( Qt::Orientation orientation READ orientation )
|
||||
|
||||
@ -41,12 +40,12 @@ class QSK_EXPORT QskTabBar : public QskBox
|
||||
QSK_SUBCONTROLS( Panel )
|
||||
|
||||
QskTabBar( QQuickItem* parent = nullptr );
|
||||
QskTabBar( Qsk::Position, QQuickItem* parent = nullptr );
|
||||
QskTabBar( Qt::Edge, QQuickItem* parent = nullptr );
|
||||
|
||||
~QskTabBar() override;
|
||||
|
||||
void setTabPosition( Qsk::Position );
|
||||
Qsk::Position tabPosition() const;
|
||||
void setEdge( Qt::Edge );
|
||||
Qt::Edge edge() const;
|
||||
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
@ -98,7 +97,7 @@ class QSK_EXPORT QskTabBar : public QskBox
|
||||
void buttonClicked( int index );
|
||||
void countChanged( int );
|
||||
void textOptionsChanged( const QskTextOptions& );
|
||||
void tabPositionChanged( Qsk::Position );
|
||||
void edgeChanged( Qt::Edge );
|
||||
void autoScrollFocusedButtonChanged( bool );
|
||||
void autoFitTabsChanged( bool );
|
||||
|
||||
|
@ -29,17 +29,12 @@ class QskTabView::PrivateData
|
||||
};
|
||||
|
||||
QskTabView::QskTabView( QQuickItem* parent )
|
||||
: QskTabView( Qsk::Top, parent )
|
||||
{
|
||||
}
|
||||
|
||||
QskTabView::QskTabView( Qsk::Position tabPosition, QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData() )
|
||||
{
|
||||
setPolishOnResize( true );
|
||||
|
||||
m_data->tabBar = new QskTabBar( tabPosition, this );
|
||||
m_data->tabBar = new QskTabBar( Qt::TopEdge, this );
|
||||
|
||||
m_data->stackBox = new QskStackBox( this );
|
||||
m_data->stackBox->setObjectName( QStringLiteral( "QskTabViewStackBox" ) );
|
||||
@ -67,8 +62,8 @@ QskTabView::QskTabView( Qsk::Position tabPosition, QQuickItem* parent )
|
||||
connect( m_data->tabBar, &QskTabBar::countChanged,
|
||||
this, &QskTabView::countChanged );
|
||||
|
||||
connect( m_data->tabBar, &QskTabBar::tabPositionChanged,
|
||||
this, &QskTabView::tabPositionChanged );
|
||||
connect( m_data->tabBar, &QskTabBar::edgeChanged,
|
||||
this, &QskTabView::tabBarEdgeChanged );
|
||||
|
||||
connect( m_data->tabBar, &QskTabBar::autoFitTabsChanged,
|
||||
this, &QskTabView::autoFitTabsChanged );
|
||||
@ -88,20 +83,14 @@ const QskTabBar* QskTabView::tabBar() const
|
||||
return m_data->tabBar;
|
||||
}
|
||||
|
||||
void QskTabView::setTabPosition( Qsk::Position position )
|
||||
void QskTabView::setTabBarEdge( Qt::Edge edge )
|
||||
{
|
||||
if ( position == tabPosition() )
|
||||
return;
|
||||
|
||||
m_data->tabBar->setTabPosition( position );
|
||||
|
||||
polish();
|
||||
update();
|
||||
m_data->tabBar->setEdge( edge );
|
||||
}
|
||||
|
||||
Qsk::Position QskTabView::tabPosition() const
|
||||
Qt::Edge QskTabView::tabBarEdge() const
|
||||
{
|
||||
return m_data->tabBar->tabPosition();
|
||||
return m_data->tabBar->edge();
|
||||
}
|
||||
|
||||
void QskTabView::setAutoFitTabs( bool on )
|
||||
@ -310,6 +299,7 @@ bool QskTabView::event( QEvent* event )
|
||||
{
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
update();
|
||||
}
|
||||
|
||||
return Inherited::event( event );
|
||||
|
@ -18,8 +18,8 @@ class QSK_EXPORT QskTabView : public QskControl
|
||||
|
||||
Q_PROPERTY( QskTabBar* tabBar READ tabBar )
|
||||
|
||||
Q_PROPERTY( Qsk::Position tabPosition READ tabPosition
|
||||
WRITE setTabPosition NOTIFY tabPositionChanged FINAL )
|
||||
Q_PROPERTY( Qt::Edge tabBarEdge READ tabBarEdge
|
||||
WRITE setTabBarEdge NOTIFY tabBarEdgeChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool autoFitTabs READ autoFitTabs
|
||||
WRITE setAutoFitTabs NOTIFY autoFitTabsChanged FINAL )
|
||||
@ -37,15 +37,13 @@ class QSK_EXPORT QskTabView : public QskControl
|
||||
QSK_SUBCONTROLS( TabBar, Page )
|
||||
|
||||
QskTabView( QQuickItem* parent = nullptr );
|
||||
QskTabView( Qsk::Position tabPosition, QQuickItem* parent = nullptr );
|
||||
|
||||
~QskTabView() override;
|
||||
|
||||
const QskTabBar* tabBar() const;
|
||||
QskTabBar* tabBar();
|
||||
|
||||
void setTabPosition( Qsk::Position );
|
||||
Qsk::Position tabPosition() const;
|
||||
void setTabBarEdge( Qt::Edge );
|
||||
Qt::Edge tabBarEdge() const;
|
||||
|
||||
void setAutoFitTabs( bool );
|
||||
bool autoFitTabs() const;
|
||||
@ -83,7 +81,7 @@ class QSK_EXPORT QskTabView : public QskControl
|
||||
Q_SIGNALS:
|
||||
void currentIndexChanged( int index );
|
||||
void countChanged( int );
|
||||
void tabPositionChanged( Qsk::Position );
|
||||
void tabBarEdgeChanged( Qt::Edge );
|
||||
void autoFitTabsChanged( bool );
|
||||
|
||||
protected:
|
||||
|
@ -51,27 +51,27 @@ QSGNode* QskTabViewSkinlet::updateSubNode(
|
||||
QRectF QskTabViewSkinlet::pageRect(
|
||||
const QskTabView* tabView, const QRectF& rect ) const
|
||||
{
|
||||
const QRectF barRect = subControlRect( tabView, rect, QskTabView::TabBar );
|
||||
const auto barRect = subControlRect( tabView, rect, QskTabView::TabBar );
|
||||
|
||||
#if 1
|
||||
QRectF r = tabView->layoutRect();
|
||||
auto r = tabView->layoutRect();
|
||||
#endif
|
||||
|
||||
switch( tabView->tabPosition() )
|
||||
switch( tabView->tabBarEdge() )
|
||||
{
|
||||
case Qsk::Top:
|
||||
case Qt::TopEdge:
|
||||
r.setTop( barRect.bottom() );
|
||||
break;
|
||||
|
||||
case Qsk::Bottom:
|
||||
case Qt::BottomEdge:
|
||||
r.setBottom( barRect.top() );
|
||||
break;
|
||||
|
||||
case Qsk::Left:
|
||||
case Qt::LeftEdge:
|
||||
r.setLeft( barRect.right() );
|
||||
break;
|
||||
|
||||
case Qsk::Right:
|
||||
case Qt::RightEdge:
|
||||
r.setRight( barRect.left() );
|
||||
break;
|
||||
}
|
||||
@ -90,21 +90,21 @@ QRectF QskTabViewSkinlet::tabBarRect(
|
||||
QRectF r = tabView->layoutRect();
|
||||
#endif
|
||||
|
||||
switch( tabView->tabPosition() )
|
||||
switch( tabView->tabBarEdge() )
|
||||
{
|
||||
case Qsk::Top:
|
||||
case Qt::TopEdge:
|
||||
r.setHeight( barSize.height() );
|
||||
break;
|
||||
|
||||
case Qsk::Bottom:
|
||||
case Qt::BottomEdge:
|
||||
r.setTop( r.bottom() - barSize.height() );
|
||||
break;
|
||||
|
||||
case Qsk::Left:
|
||||
case Qt::LeftEdge:
|
||||
r.setWidth( barSize.width() );
|
||||
break;
|
||||
|
||||
case Qsk::Right:
|
||||
case Qt::RightEdge:
|
||||
r.setLeft( r.right() - barSize.width() );
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user