2021-12-06 19:20:59 +01:00

90 lines
2.3 KiB
C++

/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "label/LabelPage.h"
#include "progressbar/ProgressBarPage.h"
#include "slider/SliderPage.h"
#include "switchbutton/SwitchButtonPage.h"
#include <SkinnyFont.h>
#include <SkinnyShortcut.h>
#include <SkinnyShapeProvider.h>
#include <QskFocusIndicator.h>
#include <QskObjectCounter.h>
#include <QskTabView.h>
#include <QskWindow.h>
#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[] )
{
#ifdef ITEM_STATISTICS
QskObjectCounter counter( true );
#endif
Qsk::addGraphicProvider( "shapes", new SkinnyShapeProvider() );
QGuiApplication app( argc, argv );
SkinnyFont::init( &app );
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
auto tabView = new TabView();
tabView->addTab( "Labels", new LabelPage() );
tabView->addTab( "Sliders", new SliderPage() );
tabView->addTab( "Progress\nBars", new ProgressBarPage() );
tabView->addTab( "Switches", new SwitchButtonPage() );
QSize size( 800, 600 );
size = size.expandedTo( tabView->sizeHint().toSize() );
QskWindow window;
window.addItem( tabView );
window.addItem( new QskFocusIndicator() );
window.resize( size );
window.show();
return app.exec();
}