main.cpp 1.13 KB
Newer Older
Artem Sidyakin's avatar
Artem Sidyakin committed
1 2 3
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
Artem Sidyakin's avatar
Artem Sidyakin committed
4
#include <QDebug>
Artem Sidyakin's avatar
Artem Sidyakin committed
5
#include <QCameraInfo>
Artem Sidyakin's avatar
Artem Sidyakin committed
6 7
#include <QDir>
#include "backend.h"
Artem Sidyakin's avatar
Artem Sidyakin committed
8 9 10 11 12

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

13 14
    //qputenv("QT_QPA_PLATFORM", "webgl:port=8998");

Artem Sidyakin's avatar
Artem Sidyakin committed
15 16 17 18 19 20
    QGuiApplication app(argc, argv);

    qDebug() << "cameras found: " << QCameraInfo::availableCameras().count();

    QQmlApplicationEngine engine;

Artem Sidyakin's avatar
Artem Sidyakin committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    QString basePath = Backend::getBasePath(app.applicationDirPath());
    //qDebug() << basePath;
    engine.rootContext()->setContextProperty("basePath", basePath);

    // create the folder for shots, if it doesn't exist
    QString shotsPath = QDir(basePath).filePath("shots");
    if (!QDir(shotsPath).exists())
    {
        if (!QDir().mkdir(shotsPath))
        {
            qCritical("Error: couldn't create the folder for shots");
            return -1;
        }
    }

    qmlRegisterType<Backend>("io.qt.Backend", 1, 0, "Backend");
Artem Sidyakin's avatar
Artem Sidyakin committed
37 38 39 40 41 42

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty()) { return -1; }

    return app.exec();
}