2022-04-20 15:25:15 +02:00
|
|
|
/******************************************************************************
|
2024-01-17 14:31:45 +01:00
|
|
|
* QSkinny - Copyright (C) The authors
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2022-04-20 15:25:15 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "SelectorPage.h"
|
2023-02-14 08:58:37 +01:00
|
|
|
|
|
|
|
#include <QskComboBox.h>
|
2022-04-20 15:25:15 +02:00
|
|
|
#include <QskSegmentedBar.h>
|
2023-03-09 17:59:54 +01:00
|
|
|
#include <QskLabelData.h>
|
2022-04-20 15:25:15 +02:00
|
|
|
|
|
|
|
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-02-26 17:04:47 +01:00
|
|
|
for ( const auto text : texts )
|
2023-02-01 15:47:13 +01:00
|
|
|
bar->addOption( {}, 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 )
|
2023-02-01 15:47:13 +01:00
|
|
|
bar->addOption( 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()
|
|
|
|
{
|
2023-02-14 08:58:37 +01:00
|
|
|
setSpacing( 40 );
|
2022-04-20 15:25:15 +02:00
|
|
|
|
|
|
|
new Box( Qt::Horizontal, this );
|
2023-02-14 08:58:37 +01:00
|
|
|
auto* horizontalButtonsBox = new Box( Qt::Vertical, this );
|
|
|
|
|
|
|
|
auto* comboBoxBox = new QskLinearBox( Qt::Horizontal, horizontalButtonsBox );
|
2023-03-03 18:11:09 +01:00
|
|
|
comboBoxBox->setExtraSpacingAt( Qt::BottomEdge );
|
|
|
|
|
2023-02-14 08:58:37 +01:00
|
|
|
auto* comboBox1 = new QskComboBox( comboBoxBox );
|
2023-03-03 19:01:40 +01:00
|
|
|
comboBox1->setPlaceholderText( "< options >" );
|
2023-03-07 13:26:36 +01:00
|
|
|
comboBox1->addOption( "airport" );
|
|
|
|
comboBox1->addOption( "flight" );
|
|
|
|
comboBox1->addOption( "pizza" );
|
|
|
|
comboBox1->addOption( "soccer" );
|
2023-02-14 08:58:37 +01:00
|
|
|
|
|
|
|
auto* comboBox2 = new QskComboBox( comboBoxBox );
|
2023-03-07 13:26:36 +01:00
|
|
|
comboBox2->addOption( "airport_shuttle", "airport" );
|
|
|
|
comboBox2->addOption( "flight", "flight" );
|
|
|
|
comboBox2->addOption( "local_pizza", "pizza" );
|
|
|
|
comboBox2->addOption( "sports_soccer", "soccer" );
|
2023-03-03 19:01:40 +01:00
|
|
|
comboBox2->setCurrentIndex( 2 );
|
2022-04-20 15:25:15 +02:00
|
|
|
|
|
|
|
setStretchFactor( 0, 0 );
|
|
|
|
setStretchFactor( 1, 10 );
|
|
|
|
}
|