the gallery should fit into 800x600

This commit is contained in:
Uwe Rathmann 2023-02-27 12:27:57 +01:00
parent c1354f49a3
commit c8b276db40
3 changed files with 88 additions and 53 deletions

View File

@ -6,65 +6,87 @@
#include "DialogPage.h"
#include <QskDialog.h>
#include <QskGridBox.h>
#include <QskLinearBox.h>
#include <QskPushButton.h>
#include <QskStandardSymbol.h>
#include <QskBoxShapeMetrics.h>
namespace
{
class Box : public QskGridBox
class Button : public QskPushButton
{
Q_OBJECT
public:
Box( QQuickItem* parent )
: QskGridBox( parent )
enum ButtonType
{
auto* messageButton = new QskPushButton( "message", this );
Message,
Information,
Warning,
Critical,
connect( messageButton, &QskPushButton::clicked, this,
[]() { qskDialog->message( "message", "text", QskStandardSymbol::Ok ); } );
Question,
Selection,
auto* informationButton = new QskPushButton( "information", this );
TypeCount
};
Q_ENUM( ButtonType );
connect( informationButton, &QskPushButton::clicked, this,
[]() { qskDialog->information( "information", "text" ); } );
Button( ButtonType type, QQuickItem* parent = nullptr )
: QskPushButton( parent )
, m_type( type )
{
setShape( 10 );
initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Ignored );
auto* warningButton = new QskPushButton( "warning", this );
const int index = metaObject()->indexOfEnumerator( "ButtonType" );
setText( metaObject()->enumerator( index ).key( m_type ) );
connect( warningButton, &QskPushButton::clicked, this,
[]() { qskDialog->warning( "warning", "text" ); } );
auto* criticalButton = new QskPushButton( "critical", this );
connect( criticalButton, &QskPushButton::clicked, this,
[]() { qskDialog->critical( "critical", "text" ); } );
auto* questionButton = new QskPushButton( "question", this );
connect( questionButton, &QskPushButton::clicked, this,
[]() { qskDialog->question( "question", "text" ); } );
auto* selectButton = new QskPushButton( "select", this );
connect( selectButton, &QskPushButton::clicked, this,
[]() { qskDialog->select( "select", "text", { "yes", "no", "maybe" } ); } );
addItem( messageButton, 0, 0 );
addItem( informationButton, 0, 1 );
addItem( warningButton, 0, 2 );
addItem( criticalButton, 1, 0 );
addItem( questionButton, 1, 1 );
addItem( selectButton, 1, 2 );
connect( this, &QskPushButton::clicked, this, &Button::showDialog );
}
private:
void showDialog()
{
switch( static_cast< int >( m_type ) )
{
case Message:
qskDialog->message( text(), text(), QskStandardSymbol::Ok );
break;
case Information:
qskDialog->information( text(), text() );
break;
case Warning:
qskDialog->warning( text(), text() );
break;
case Critical:
qskDialog->critical( text(), text() );
break;
case Question:
qskDialog->question( text(), text() );
break;
case Selection:
qskDialog->select( text(), text(), { "yes", "no", "maybe" } );
break;
}
}
const ButtonType m_type;
};
}
DialogPage::DialogPage( QQuickItem* parent )
: Page( Qt::Horizontal, parent )
{
populate();
auto box = new QskLinearBox( Qt::Horizontal, 2, this );
for ( int i = 0; i < Button::TypeCount; i++ )
new Button( static_cast< Button::ButtonType >( i ), box );
}
void DialogPage::populate()
{
new Box( this );
}
#include "DialogPage.moc"

View File

@ -11,7 +11,4 @@ class DialogPage : public Page
{
public:
DialogPage( QQuickItem* = nullptr );
private:
void populate();
};

View File

@ -21,6 +21,7 @@
#include <QskTextLabel.h>
#include <QskSwitchButton.h>
#include <QskPushButton.h>
#include <QskScrollArea.h>
#include <QskMenu.h>
#include <QskWindow.h>
#include <QskDialog.h>
@ -28,6 +29,8 @@
#include <QskSkin.h>
#include <QskSkinTransition.h>
#include <QskAnimationHint.h>
#include <QskBoxBorderMetrics.h>
#include <QskBoxShapeMetrics.h>
#include <QskSetup.h>
#include <QGuiApplication>
@ -48,6 +51,22 @@ namespace
for ( int i = 0; i < count(); i++ )
itemAt( i )->setEnabled( on );
}
void addPage( const QString& tabText, QQuickItem* page )
{
auto scrollArea = new QskScrollArea();
scrollArea->setMargins( 5 );
// hiding the viewport
scrollArea->setGradientHint( QskScrollView::Viewport, QskGradient() );
scrollArea->setBoxShapeHint( QskScrollView::Viewport, 0 );
scrollArea->setBoxBorderMetricsHint( QskScrollView::Viewport, 0 );
scrollArea->setItemResizable( true );
scrollArea->setScrolledItem( page );
addTab( tabText, scrollArea );
}
};
class MenuButton : public QskPushButton
@ -191,12 +210,12 @@ namespace
auto header = new Header( this );
auto tabView = new TabView( this );
tabView->addTab( "Buttons", new ButtonPage() );
tabView->addTab( "Labels", new LabelPage() );
tabView->addTab( "Inputs", new InputPage() );
tabView->addTab( "Progress\nBars", new ProgressBarPage() );
tabView->addTab( "Selectors", new SelectorPage() );
tabView->addTab( "Dialogs", new DialogPage() );
tabView->addPage( "Buttons", new ButtonPage() );
tabView->addPage( "Labels", new LabelPage() );
tabView->addPage( "Inputs", new InputPage() );
tabView->addPage( "Progress\nBars", new ProgressBarPage() );
tabView->addPage( "Selectors", new SelectorPage() );
tabView->addPage( "Dialogs", new DialogPage() );
connect( header, &Header::enabledToggled,
tabView, &TabView::setTabsEnabled );
@ -224,14 +243,11 @@ int main( int argc, char* argv[] )
auto mainView = new ApplicationView();
QSize size( 800, 600 );
size = size.expandedTo( mainView->sizeHint().toSize() );
QskWindow window;
window.addItem( mainView );
window.addItem( new QskFocusIndicator() );
window.resize( size );
window.resize( 800, 600 );
window.show();
return app.exec();