2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2017-07-21 18:21:34 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2022-04-04 17:45:49 +02:00
|
|
|
#include "CustomSlider.h"
|
|
|
|
#include "OtherSlider.h"
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <SkinnyShortcut.h>
|
|
|
|
|
|
|
|
#include <QskAspect.h>
|
2018-08-03 08:15:28 +02:00
|
|
|
#include <QskBoxBorderColors.h>
|
|
|
|
#include <QskFocusIndicator.h>
|
|
|
|
#include <QskLinearBox.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskObjectCounter.h>
|
|
|
|
#include <QskPushButton.h>
|
|
|
|
#include <QskSkin.h>
|
2018-08-03 08:15:28 +02:00
|
|
|
#include <QskTabView.h>
|
|
|
|
#include <QskTextLabel.h>
|
|
|
|
#include <QskWindow.h>
|
2019-02-13 10:25:38 +01:00
|
|
|
#include <QskShortcutMap.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
#include <QGuiApplication>
|
|
|
|
|
|
|
|
class Label : public QskTextLabel
|
|
|
|
{
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
|
|
|
Label( const QString& text, QQuickItem* parent = nullptr )
|
|
|
|
: QskTextLabel( text, parent )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2017-08-22 20:15:11 +02:00
|
|
|
setTextColor( Qt::darkRed );
|
|
|
|
setFontRole( QskSkin::LargeFont );
|
2017-07-21 18:21:34 +02:00
|
|
|
setAlignment( Qt::AlignCenter );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-04 17:45:49 +02:00
|
|
|
class SliderBox : public QskLinearBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SliderBox( QQuickItem* parent = nullptr )
|
|
|
|
: QskLinearBox( Qt::Vertical, parent )
|
|
|
|
{
|
|
|
|
setMargins( 30 );
|
|
|
|
setSpacing( 50 );
|
|
|
|
setExtraSpacingAt( Qt::BottomEdge );
|
|
|
|
|
|
|
|
{
|
|
|
|
auto slider = new OtherSlider( this );
|
2023-02-28 15:49:42 +01:00
|
|
|
|
2022-04-04 17:45:49 +02:00
|
|
|
slider->setMinimum( 0 );
|
|
|
|
slider->setMaximum( 10 );
|
|
|
|
slider->setStepSize( 1 );
|
2023-02-28 15:49:42 +01:00
|
|
|
}
|
2022-04-04 17:45:49 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
auto slider = new CustomSlider( this );
|
|
|
|
|
|
|
|
slider->setSnap( true );
|
|
|
|
slider->setMinimum( 0 );
|
|
|
|
slider->setMaximum( 2000 );
|
|
|
|
slider->setStepSize( 10 );
|
|
|
|
slider->setPageSize( 10 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
class TabView : public QskTabView
|
|
|
|
{
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
|
|
|
TabView( QQuickItem* parent = nullptr )
|
|
|
|
: QskTabView( parent )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2020-03-13 07:39:31 +01:00
|
|
|
for ( int i = 0; i < 10; i++ )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
if ( i == 4 )
|
2022-04-04 17:45:49 +02:00
|
|
|
{
|
|
|
|
const auto text = QStringLiteral( "Another Tab" );
|
|
|
|
addTab( text, new Label( text ) );
|
|
|
|
}
|
|
|
|
else if ( i == 7 )
|
|
|
|
{
|
|
|
|
addTab( "Sliders", new SliderBox() );
|
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
else
|
2022-04-04 17:45:49 +02:00
|
|
|
{
|
|
|
|
const auto text = QString( "Tab %1" ).arg( i + 1 );
|
|
|
|
addTab( text, new Label( text ) );
|
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-14 09:34:52 +01:00
|
|
|
setTabEnabled( 2, false );
|
2020-08-11 13:08:33 +02:00
|
|
|
setCurrentIndex( 4 );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2021-02-02 10:28:30 +01:00
|
|
|
void appendTab()
|
|
|
|
{
|
|
|
|
const auto text = QString( "Tab %1" ).arg( count() + 1 );
|
|
|
|
addTab( text, new Label( text ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeLastTab()
|
|
|
|
{
|
|
|
|
if ( count() > 0 )
|
|
|
|
removeTab( count() - 1 );
|
|
|
|
}
|
|
|
|
|
2019-04-17 16:33:17 +02:00
|
|
|
void rotate()
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2022-04-17 12:37:13 +02:00
|
|
|
using namespace Qt;
|
|
|
|
const Edge edges[] = { TopEdge, RightEdge, BottomEdge, LeftEdge };
|
2019-04-17 16:33:17 +02:00
|
|
|
|
|
|
|
for ( int i = 0; i < 4; i++ )
|
|
|
|
{
|
2022-04-17 12:37:13 +02:00
|
|
|
if ( tabBarEdge() == edges[i] )
|
2019-04-17 16:33:17 +02:00
|
|
|
{
|
2022-04-17 12:37:13 +02:00
|
|
|
setTabBarEdge( edges[ ( i + 1 ) % 4 ] );
|
2019-04-17 16:33:17 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
|
|
|
#ifdef ITEM_STATISTICS
|
|
|
|
QskObjectCounter counter( true );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QGuiApplication app( argc, argv );
|
|
|
|
|
|
|
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
|
|
|
|
|
|
|
auto tabView = new TabView();
|
|
|
|
|
2019-04-17 16:33:17 +02:00
|
|
|
auto rotateButton = new QskPushButton( "Rotate" );
|
|
|
|
rotateButton->setFocus( true );
|
2020-03-13 14:50:09 +01:00
|
|
|
QObject::connect( rotateButton, &QskPushButton::clicked,
|
|
|
|
tabView, &TabView::rotate );
|
|
|
|
|
|
|
|
auto autoFitButton = new QskPushButton( "Fit Tabs" );
|
|
|
|
autoFitButton->setCheckable( true );
|
|
|
|
QObject::connect( autoFitButton, &QskPushButton::toggled,
|
|
|
|
tabView, &QskTabView::setAutoFitTabs );
|
|
|
|
|
2021-02-02 10:28:30 +01:00
|
|
|
auto addButton = new QskPushButton( "Add" );
|
|
|
|
QObject::connect( addButton, &QskPushButton::clicked,
|
|
|
|
tabView, &TabView::appendTab );
|
|
|
|
|
|
|
|
auto removeButton = new QskPushButton( "Remove" );
|
|
|
|
QObject::connect( removeButton, &QskPushButton::clicked,
|
|
|
|
tabView, &TabView::removeLastTab );
|
|
|
|
|
2020-03-13 14:50:09 +01:00
|
|
|
auto buttonBox = new QskLinearBox( Qt::Horizontal );
|
|
|
|
buttonBox->addItem( rotateButton );
|
|
|
|
buttonBox->addItem( autoFitButton );
|
2021-02-02 10:28:30 +01:00
|
|
|
buttonBox->addItem( addButton );
|
|
|
|
buttonBox->addItem( removeButton );
|
2020-03-13 14:50:09 +01:00
|
|
|
buttonBox->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
auto layoutBox = new QskLinearBox( Qt::Vertical );
|
2019-09-05 10:46:42 +02:00
|
|
|
layoutBox->setDefaultAlignment( Qt::AlignLeft );
|
2020-03-16 13:17:51 +01:00
|
|
|
layoutBox->setMargins( 20 );
|
2017-07-21 18:21:34 +02:00
|
|
|
layoutBox->setSpacing( 10 );
|
2020-03-13 14:50:09 +01:00
|
|
|
layoutBox->addItem( buttonBox );
|
2017-07-21 18:21:34 +02:00
|
|
|
layoutBox->addItem( tabView );
|
|
|
|
|
|
|
|
auto focusIndicator = new QskFocusIndicator();
|
|
|
|
focusIndicator->setObjectName( "FocusIndicator" );
|
2017-10-18 20:00:06 +02:00
|
|
|
focusIndicator->setBoxBorderColorsHint( QskFocusIndicator::Panel, Qt::red );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
QskWindow window;
|
2020-03-13 14:50:09 +01:00
|
|
|
window.resize( 800, 600 );
|
2017-07-21 18:21:34 +02:00
|
|
|
window.addItem( layoutBox );
|
|
|
|
window.addItem( focusIndicator );
|
|
|
|
|
|
|
|
window.show();
|
|
|
|
|
2019-02-13 10:25:38 +01:00
|
|
|
for ( int i = 0; i < 10; i++ )
|
|
|
|
{
|
|
|
|
QskShortcutMap::addShortcut( Qt::Key_F1 + i, false,
|
|
|
|
[tabView, i] { tabView->removeTab( i ); } );
|
|
|
|
}
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
return app.exec();
|
|
|
|
}
|