2019-05-10 07:33:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2019-05-10 07:33:41 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "GridLayoutPage.h"
|
|
|
|
#include <QskRgbValue.h>
|
2019-07-19 12:14:58 +02:00
|
|
|
|
|
|
|
#define USE_QML 1
|
|
|
|
|
|
|
|
#if USE_QML
|
|
|
|
|
2019-07-09 10:16:04 +02:00
|
|
|
#include <QtQml>
|
2019-05-10 07:33:41 +02:00
|
|
|
|
2019-07-19 12:14:58 +02:00
|
|
|
static void insertItemQml( QQuickItem* parentItem, const QUrl& url )
|
2019-05-10 07:33:41 +02:00
|
|
|
{
|
2019-07-09 10:16:04 +02:00
|
|
|
QQmlEngine engine( nullptr );
|
|
|
|
|
|
|
|
QQmlComponent component( &engine );
|
|
|
|
component.loadUrl( url, QQmlComponent::PreferSynchronous );
|
|
|
|
|
2019-07-19 12:14:58 +02:00
|
|
|
if( auto item = qobject_cast< QQuickItem* >( component.create() ) )
|
|
|
|
{
|
|
|
|
item->setParentItem( parentItem );
|
|
|
|
item->setParent( parentItem );
|
|
|
|
}
|
2019-05-10 07:33:41 +02:00
|
|
|
}
|
|
|
|
|
2019-07-19 12:14:58 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
#include <QskGridBox.h>
|
|
|
|
#include "TestRectangle.h"
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class Box : public QskGridBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Box( QQuickItem* parent = nullptr )
|
|
|
|
: QskGridBox( parent )
|
|
|
|
{
|
|
|
|
setObjectName( "GridBox" );
|
|
|
|
|
|
|
|
setBackgroundColor( Qt::white );
|
|
|
|
setMargins( 10 );
|
|
|
|
|
|
|
|
addItem( new TestRectangle( "PaleVioletRed" ), 0, 0, 1, 2 );
|
|
|
|
addItem( new TestRectangle( "DarkSeaGreen" ), 1, 0, 2, 1 );
|
|
|
|
addItem( new TestRectangle( "SkyBlue" ), 2, 1, 1, 1 );
|
|
|
|
addItem( new TestRectangle( "NavajoWhite" ), 0, 2, -1, 1 );
|
|
|
|
|
|
|
|
setRowStretchFactor( 0, 1 );
|
|
|
|
setRowStretchFactor( 1, 2 );
|
|
|
|
setRowStretchFactor( 2, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void mirror()
|
|
|
|
{
|
|
|
|
setLayoutMirroring( !layoutMirroring() );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-05-10 07:33:41 +02:00
|
|
|
GridLayoutPage::GridLayoutPage( QQuickItem* parent )
|
|
|
|
: QskControl( parent )
|
|
|
|
{
|
|
|
|
setMargins( 10 );
|
2020-08-15 13:29:17 +02:00
|
|
|
setBackgroundColor( QskRgb::LightSteelBlue );
|
2019-05-10 07:33:41 +02:00
|
|
|
|
|
|
|
setAutoLayoutChildren( true );
|
2019-07-09 10:16:04 +02:00
|
|
|
|
2019-07-19 12:14:58 +02:00
|
|
|
#if USE_QML
|
|
|
|
insertItemQml( this, QUrl( "qrc:/qml/layouts.qml" ) );
|
|
|
|
#else
|
|
|
|
new Box( this );
|
|
|
|
#endif
|
2019-05-10 07:33:41 +02:00
|
|
|
}
|