qskinny/examples/automotive/MainWindow.cpp

88 lines
2.1 KiB
C++
Raw Normal View History

2019-06-20 10:02:28 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
2017-07-25 05:24:27 +00:00
#include "MainWindow.h"
#include "ButtonBar.h"
#include "SkinFactory.h"
#include "SoundControl.h"
#include "SpeedometerDisplay.h"
2017-07-25 05:24:27 +00:00
#include <QskGraphic.h>
2017-07-25 19:34:27 +00:00
#include <QskGraphicIO.h>
2017-07-25 05:24:27 +00:00
#include <QskGraphicLabel.h>
#include <QskLinearBox.h>
#include <QskTextLabel.h>
#include <QDate>
2017-07-25 09:33:33 +00:00
#include <QImage>
2017-07-25 05:24:27 +00:00
#define SPEEDO 0
MainWindow::MainWindow()
2017-07-25 09:33:33 +00:00
{
const QImage image( QStringLiteral( ":/images/background.jpg" ) );
2017-07-25 05:24:27 +00:00
auto backgroundImage = new QskGraphicLabel( contentItem() );
backgroundImage->setGraphic( QskGraphic::fromImage( image ) );
backgroundImage->setFillMode( QskGraphicLabel::Stretch );
2017-07-25 09:33:33 +00:00
auto header = headerBar();
auto content = mainContent();
auto footer = footerBar();
auto layout = new QskLinearBox( Qt::Vertical, contentItem() );
layout->addItem( header );
layout->setStretchFactor( header, 1 );
2017-07-25 19:34:27 +00:00
layout->addItem( content );
layout->setStretchFactor( content, 8 );
2017-07-25 19:34:27 +00:00
layout->addItem( footer );
layout->setStretchFactor( footer, 1 );
2017-07-25 19:34:27 +00:00
setAutoLayoutChildren( true );
2017-07-25 05:24:27 +00:00
}
2017-07-25 09:33:33 +00:00
QQuickItem* MainWindow::headerBar() const
2017-07-25 05:24:27 +00:00
{
auto* header = new ButtonBar();
header->addIndicator( "bluetooth" );
header->addIndicator( "location" );
header->addIndicator( "phone" );
2017-07-25 09:33:33 +00:00
2018-08-03 06:15:28 +00:00
( void ) new QskTextLabel( QDate::currentDate().toString(), header );
2017-07-25 05:24:27 +00:00
header->addIndicator( "user" );
header->addIndicator( "bookmark" );
header->addIndicator( "menu" );
2017-07-25 09:33:33 +00:00
return header;
2017-07-25 05:24:27 +00:00
}
2017-07-25 09:33:33 +00:00
QQuickItem* MainWindow::mainContent() const
2017-07-25 05:24:27 +00:00
{
#if SPEEDO
return new SpeedometerDisplay();
#else
return new SoundControl();
#endif
2017-07-25 05:24:27 +00:00
}
2017-07-25 09:33:33 +00:00
QQuickItem* MainWindow::footerBar() const
2017-07-25 05:24:27 +00:00
{
auto* footer = new ButtonBar();
2017-07-25 09:33:33 +00:00
footer->addIndicator( "cloud" );
footer->addIndicator( "man" );
footer->addIndicator( "bus" );
footer->addIndicator( "plane" );
footer->addIndicator( "train" );
2017-07-25 19:34:27 +00:00
2017-07-25 09:33:33 +00:00
footer->addStretch( 10 );
return footer;
2017-07-25 05:24:27 +00:00
}