qskinny/examples/automotive/MainWindow.cpp

76 lines
1.7 KiB
C++
Raw Normal View History

2017-07-25 07:24:27 +02:00
#include "MainWindow.h"
#include "ButtonBar.h"
2017-07-25 07:24:27 +02:00
#include "SoundControl.h"
#include "SkinFactory.h"
2017-07-25 07:24:27 +02:00
#include <QskGraphic.h>
2017-07-25 21:34:27 +02:00
#include <QskGraphicIO.h>
2017-07-25 07:24:27 +02:00
#include <QskGraphicLabel.h>
#include <QskLinearBox.h>
#include <QskTextLabel.h>
#include <QDate>
2017-07-25 11:33:33 +02:00
#include <QImage>
2017-07-25 07:24:27 +02:00
MainWindow::MainWindow()
2017-07-25 11:33:33 +02:00
{
const QImage image( ":/images/background.jpg" );
2017-07-25 07:24:27 +02:00
auto backgroundImage = new QskGraphicLabel( contentItem() );
backgroundImage->setGraphic( QskGraphic::fromImage( image ) );
backgroundImage->setFillMode( QskGraphicLabel::Stretch );
2017-07-25 11:33:33 +02:00
auto header = headerBar();
auto content = mainContent();
auto footer = footerBar();
auto layout = new QskLinearBox( Qt::Vertical, contentItem() );
2017-07-25 07:24:27 +02:00
2017-07-25 11:33:33 +02:00
layout->addItem( header );
2017-07-25 21:34:27 +02:00
layout->setStretchFactor( header, 1 );
2017-07-25 11:33:33 +02:00
layout->addItem( content );
2017-07-25 21:34:27 +02:00
layout->setStretchFactor( content, 10 );
2017-07-25 11:33:33 +02:00
layout->addItem( footer );
2017-07-25 21:34:27 +02:00
layout->setStretchFactor( footer, 1 );
setAutoLayoutChildren( true );
2017-07-25 07:24:27 +02:00
}
2017-07-25 11:33:33 +02:00
QQuickItem* MainWindow::headerBar() const
2017-07-25 07:24:27 +02:00
{
2017-07-25 11:33:33 +02:00
auto* header = new ButtonBar();
header->addIndicator( "bluetooth" );
header->addIndicator( "location" );
header->addIndicator( "phone" );
2017-07-25 11:33:33 +02:00
(void) new QskTextLabel( QDate::currentDate().toString(), header );
2017-07-25 07:24:27 +02:00
header->addIndicator( "user" );
header->addIndicator( "bookmark" );
header->addIndicator( "menu" );
2017-07-25 11:33:33 +02:00
return header;
2017-07-25 07:24:27 +02:00
}
2017-07-25 11:33:33 +02:00
QQuickItem* MainWindow::mainContent() const
2017-07-25 07:24:27 +02:00
{
2017-07-25 11:33:33 +02:00
return new SoundControl();
2017-07-25 07:24:27 +02:00
}
2017-07-25 11:33:33 +02:00
QQuickItem* MainWindow::footerBar() const
2017-07-25 07:24:27 +02:00
{
2017-07-25 11:33:33 +02:00
auto* footer = new ButtonBar();
footer->addIndicator( "cloud" );
footer->addIndicator( "man" );
footer->addIndicator( "bus" );
footer->addIndicator( "plane" );
footer->addIndicator( "train" );
2017-07-25 21:34:27 +02:00
2017-07-25 11:33:33 +02:00
footer->addStretch( 10 );
return footer;
2017-07-25 07:24:27 +02:00
}