17 #include "ShellView.h" 20 #include <QQmlContext> 22 #include <QtQuick/private/qquickitem_p.h> 23 #include <QtQuick/private/qquickrectangle_p.h> 24 #include <QtQuick/private/qquicktext_p.h> 29 ShellView::ShellView(QQmlEngine *engine, QObject *qmlArgs)
30 : QQuickView(engine, nullptr)
32 setResizeMode(QQuickView::SizeRootObjectToView);
34 setTitle(QStringLiteral(
"Unity8"));
36 rootContext()->setContextProperty(QStringLiteral(
"applicationArguments"), qmlArgs);
38 connect(
this, &QQuickView::statusChanged,
this, [
this] {
39 if (status() == QQuickView::Error) {
40 QQuickRectangle *rect =
new QQuickRectangle(contentItem());
41 rect->setColor(Qt::white);
42 QQuickItemPrivate::get(rect)->anchors()->setFill(contentItem());
45 for(
const QQmlError &e: errors()) {
46 errorsString += e.toString() +
"\n";
48 QQuickText *text =
new QQuickText(rect);
49 text->setColor(Qt::black);
50 text->setWrapMode(QQuickText::Wrap);
51 text->setText(QString(
"There was an error loading Unity8:\n%1").arg(errorsString));
52 QQuickItemPrivate::get(text)->anchors()->setFill(rect);
57 QUrl source(::qmlDirectory() +
"/OrientedShell.qml");
60 connect(
this, &QWindow::widthChanged,
this, &ShellView::onWidthChanged);
61 connect(
this, &QWindow::heightChanged,
this, &ShellView::onHeightChanged);
64 void ShellView::onWidthChanged(
int w)
75 rootObject()->setWidth(w);
79 void ShellView::onHeightChanged(
int h)
83 rootObject()->setHeight(h);