summaryrefslogtreecommitdiffstats
path: root/experimental/qt5-intro-android/main.cpp
blob: f68e26c602f04ea877787d9652035bce3e4921dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <QtGui>
#include <QtQuick>

QtMessageHandler oldMessageHandler = 0;
void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg)
{
    if (type == QtCriticalMsg || type == QtFatalMsg)
        oldMessageHandler(type, ctx, msg);
}

int main(int argc, char **argv)
{
#if defined(QT_NO_DEBUG)
    oldMessageHandler = qInstallMessageHandler(messageHandler);
#endif

    QGuiApplication app(argc, argv);

    QString videoPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
    if (!QFile::exists(videoPath + QLatin1String("/Qt5_Animation_small.mp4"))) {
        QDir().mkpath(videoPath);
        if (!QFile::copy(QLatin1String("assets:/video/Qt5_Animation_small.mp4"), videoPath + QLatin1String("/Qt5_Animation_small.mp4")))
            qWarning("main: Couldn't copy video.");
    }

    QQuickView view;
    view.engine()->rootContext()->setContextProperty("videoPath", QLatin1String("file://") + videoPath + QLatin1String("/Qt5_Animation_small.mp4"));
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl("qrc:/main.qml"));
    view.show();

    return app.exec();
}