2022-04-20 15:25:15 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "SelectorPage.h"
|
|
|
|
#include <QskSegmentedBar.h>
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class Box : public QskLinearBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Box( Qt::Orientation orientation, QQuickItem* parent = nullptr )
|
|
|
|
: QskLinearBox( orientation, parent )
|
|
|
|
{
|
|
|
|
setSpacing( 20 );
|
|
|
|
|
|
|
|
orientation = ( orientation == Qt::Horizontal )
|
|
|
|
? Qt::Vertical : Qt::Horizontal;
|
|
|
|
|
2023-01-21 16:53:58 +01:00
|
|
|
const char* texts[] =
|
|
|
|
{
|
|
|
|
"airport",
|
|
|
|
"flight",
|
|
|
|
"pizza",
|
|
|
|
"soccer"
|
|
|
|
};
|
|
|
|
|
2022-04-20 15:25:15 +02:00
|
|
|
{
|
|
|
|
auto bar = new QskSegmentedBar( orientation, this );
|
|
|
|
|
2023-01-21 16:53:58 +01:00
|
|
|
for ( const auto text: texts )
|
|
|
|
bar->addText( text );
|
2022-04-20 15:25:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const char* icons[] =
|
|
|
|
{
|
2023-01-21 16:53:58 +01:00
|
|
|
"airport_shuttle",
|
|
|
|
"flight",
|
|
|
|
"local_pizza",
|
|
|
|
"sports_soccer"
|
2022-04-20 15:25:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
auto bar = new QskSegmentedBar( orientation, this );
|
2023-01-21 16:53:58 +01:00
|
|
|
for ( uint i = 0; i < sizeof( icons ) / sizeof( icons[ 0 ] ); ++i )
|
|
|
|
bar->addGraphicAndText( QUrl( QString( icons[ i ] ) ), texts[ i ] );
|
2022-04-20 15:25:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setExtraSpacingAt( Qt::LeftEdge | Qt::BottomEdge );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectorPage::SelectorPage( QQuickItem* parent )
|
|
|
|
: Page( Qt::Horizontal, parent )
|
|
|
|
{
|
|
|
|
populate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SelectorPage::populate()
|
|
|
|
{
|
|
|
|
setSpacing( 20 );
|
|
|
|
|
|
|
|
new Box( Qt::Horizontal, this );
|
|
|
|
new Box( Qt::Vertical, this );
|
|
|
|
|
|
|
|
setStretchFactor( 0, 0 );
|
|
|
|
setStretchFactor( 1, 10 );
|
|
|
|
}
|