tabpage background fixed
This commit is contained in:
parent
0a0c3dfb17
commit
985fcf1e2d
|
@ -4,25 +4,29 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "Page.h"
|
#include "Page.h"
|
||||||
|
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
#include <QskBoxShapeMetrics.h>
|
|
||||||
|
|
||||||
Page::Page( Qt::Orientation orientation, QQuickItem* parent )
|
Page::Page( Qt::Orientation orientation, QQuickItem* parent )
|
||||||
: QskLinearBox( orientation, parent )
|
: QskLinearBox( orientation, parent )
|
||||||
|
, m_gradient( QskRgb::GhostWhite )
|
||||||
{
|
{
|
||||||
setBackgroundColor( Qt::gray );
|
setMargins( 20 );
|
||||||
|
|
||||||
setPanel( true );
|
|
||||||
setBoxShapeHint( QskBox::Panel, 8 );
|
|
||||||
setGradient( QskRgb::GhostWhite );
|
|
||||||
|
|
||||||
setMargins( 5 );
|
|
||||||
setPadding( 10 );
|
setPadding( 10 );
|
||||||
setSpacing( 10 );
|
setSpacing( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::setGradient( const QskGradient& gradient )
|
void Page::setGradient( const QskGradient& gradient )
|
||||||
{
|
{
|
||||||
setGradientHint( QskBox::Panel, gradient );
|
if ( gradient != m_gradient )
|
||||||
|
{
|
||||||
|
m_gradient = gradient;
|
||||||
|
|
||||||
|
if ( parentItem() && isVisibleToParent() )
|
||||||
|
parentItem()->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QskGradient Page::gradient() const
|
||||||
|
{
|
||||||
|
return m_gradient;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QskLinearBox.h>
|
#include <QskLinearBox.h>
|
||||||
|
#include <QskGradient.h>
|
||||||
|
|
||||||
class Page : public QskLinearBox
|
class Page : public QskLinearBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Page( Qt::Orientation, QQuickItem* parent = nullptr );
|
Page( Qt::Orientation, QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
void setGradient( const QskGradient& );
|
void setGradient( const QskGradient& );
|
||||||
|
QskGradient gradient() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QskGradient m_gradient;
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,42 @@
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class TabView : public QskTabView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TabView( QQuickItem* parent = nullptr )
|
||||||
|
: QskTabView( parent )
|
||||||
|
{
|
||||||
|
setMargins( 10 );
|
||||||
|
setTabPosition( Qsk::Left );
|
||||||
|
setAutoFitTabs( true );
|
||||||
|
|
||||||
|
connect( this, &QskTabView::currentIndexChanged,
|
||||||
|
this, &TabView::updateViewPanel );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void aboutToShow() override
|
||||||
|
{
|
||||||
|
updateViewPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateViewPanel()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
We should have a better way to set individual colors
|
||||||
|
for each tab page background
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( auto page = dynamic_cast< const ::Page* >( currentItem() ) )
|
||||||
|
setGradientHint( QskTabView::Page, page->gradient() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
#ifdef ITEM_STATISTICS
|
#ifdef ITEM_STATISTICS
|
||||||
|
@ -32,11 +68,7 @@ int main( int argc, char* argv[] )
|
||||||
SkinnyFont::init( &app );
|
SkinnyFont::init( &app );
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||||
|
|
||||||
auto tabView = new QskTabView();
|
auto tabView = new TabView();
|
||||||
|
|
||||||
tabView->setMargins( 10 );
|
|
||||||
tabView->setTabPosition( Qsk::Left );
|
|
||||||
tabView->setAutoFitTabs( true );
|
|
||||||
|
|
||||||
tabView->addTab( "Labels", new LabelPage() );
|
tabView->addTab( "Labels", new LabelPage() );
|
||||||
tabView->addTab( "Sliders", new SliderPage() );
|
tabView->addTab( "Sliders", new SliderPage() );
|
||||||
|
|
Loading…
Reference in New Issue