2010-11-01 17:03:46 +01:00
|
|
|
/*
|
2013-10-16 17:18:07 +02:00
|
|
|
This file was generated by the Qt Quick 1 Application wizard of Qt Creator.
|
|
|
|
|
QtQuick1ApplicationViewer is a convenience class containing mobile device
|
|
|
|
|
specific code such as screen orientation handling. Also QML paths are
|
2010-11-01 17:03:46 +01:00
|
|
|
handled here.
|
|
|
|
|
It is recommended not to modify this file, since newer versions of Qt Creator
|
|
|
|
|
may offer an updated version of it.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
#include "qtquick1applicationviewer.h"
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDeclarativeComponent>
|
|
|
|
|
#include <QDeclarativeEngine>
|
|
|
|
|
#include <QDeclarativeContext>
|
2010-07-15 11:58:37 +02:00
|
|
|
|
2010-08-16 20:27:30 +02:00
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
QtQuick1ApplicationViewer::QtQuick1ApplicationViewer(QWidget *parent)
|
2011-08-17 12:27:24 +02:00
|
|
|
: QDeclarativeView(parent)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
|
|
|
|
connect(engine(), SIGNAL(quit()), SLOT(close()));
|
|
|
|
|
setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
QtQuick1ApplicationViewer::~QtQuick1ApplicationViewer()
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2011-08-17 12:27:24 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
QtQuick1ApplicationViewer *QtQuick1ApplicationViewer::create()
|
2011-08-17 12:27:24 +02:00
|
|
|
{
|
2013-10-16 17:18:07 +02:00
|
|
|
return new QtQuick1ApplicationViewer();
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
void QtQuick1ApplicationViewer::setMainQmlFile(const QString &file)
|
2010-08-16 20:27:30 +02:00
|
|
|
{
|
2014-03-18 19:10:47 +01:00
|
|
|
setSource(file);
|
2010-08-16 20:27:30 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
void QtQuick1ApplicationViewer::addImportPath(const QString &path)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2014-03-18 19:10:47 +01:00
|
|
|
engine()->addImportPath(path);
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
void QtQuick1ApplicationViewer::setOrientation(ScreenOrientation orientation)
|
2010-07-15 11:58:37 +02:00
|
|
|
{
|
2012-08-10 18:08:18 +02:00
|
|
|
#if QT_VERSION < 0x050000
|
2010-09-10 13:54:31 +02:00
|
|
|
Qt::WidgetAttribute attribute;
|
|
|
|
|
switch (orientation) {
|
2011-02-02 13:41:22 +01:00
|
|
|
case ScreenOrientationLockPortrait:
|
|
|
|
|
attribute = Qt::WA_LockPortraitOrientation;
|
|
|
|
|
break;
|
|
|
|
|
case ScreenOrientationLockLandscape:
|
|
|
|
|
attribute = Qt::WA_LockLandscapeOrientation;
|
|
|
|
|
break;
|
2010-09-10 13:54:31 +02:00
|
|
|
default:
|
2011-02-02 13:41:22 +01:00
|
|
|
case ScreenOrientationAuto:
|
|
|
|
|
attribute = Qt::WA_AutoOrientation;
|
2010-09-10 13:54:31 +02:00
|
|
|
break;
|
2011-02-02 13:41:22 +01:00
|
|
|
};
|
2010-09-10 13:54:31 +02:00
|
|
|
setAttribute(attribute, true);
|
2012-08-10 18:08:18 +02:00
|
|
|
#else // QT_VERSION < 0x050000
|
|
|
|
|
Q_UNUSED(orientation)
|
|
|
|
|
#endif // QT_VERSION < 0x050000
|
2010-07-15 11:58:37 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 17:18:07 +02:00
|
|
|
void QtQuick1ApplicationViewer::showExpanded()
|
2010-09-20 13:18:35 +02:00
|
|
|
{
|
2013-10-16 12:43:14 +02:00
|
|
|
#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)
|
2011-11-16 13:09:03 +01:00
|
|
|
showFullScreen();
|
2011-08-17 12:27:24 +02:00
|
|
|
#else
|
2011-11-16 13:09:03 +01:00
|
|
|
show();
|
2011-08-17 12:27:24 +02:00
|
|
|
#endif
|
|
|
|
|
}
|