1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-02-06 21:48:24 +08:00

54 lines
1.4 KiB
C++
Raw Normal View History

2020-06-04 00:37:09 +08:00
#include "TaoView.h"
2020-07-01 00:16:13 +08:00
#include "Trans.h"
2020-06-30 00:34:25 +08:00
#include "logger.h"
2019-07-18 10:17:02 +08:00
#include <QGuiApplication>
#include <QQmlContext>
#include <QQmlEngine>
2020-07-01 00:16:13 +08:00
#include <QUrl>
#include <QDir>
static void prepareApp()
2019-07-18 10:17:02 +08:00
{
2019-08-03 17:47:27 +08:00
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
2020-07-01 00:16:13 +08:00
QCoreApplication::setOrganizationName("JaredTao");
QCoreApplication::setOrganizationDomain("https://JaredTao.gitee.io");
QCoreApplication::setApplicationName("TaoQuickApp");
}
static void beforeUiReady(QQmlContext *ctx)
{
Q_UNUSED(ctx)
}
static void afterUiReady()
{
2019-08-03 17:47:27 +08:00
2020-07-01 00:16:13 +08:00
}
int main(int argc, char** argv)
{
prepareApp();
2019-07-18 10:17:02 +08:00
QGuiApplication app(argc, argv);
2020-07-01 00:16:13 +08:00
2019-07-18 10:17:02 +08:00
Logger::initLog();
2020-06-14 00:57:36 +08:00
Trans trans;
2020-07-01 00:16:13 +08:00
2019-07-18 10:17:02 +08:00
TaoView view;
2020-06-14 00:57:36 +08:00
2020-07-01 00:16:13 +08:00
beforeUiReady(view.rootContext());
view.engine()->addImportPath(qmlPath);
view.rootContext()->setContextProperty("qmlPath", qmlPath);
view.rootContext()->setContextProperty("imgPath", imgPath);
view.rootContext()->setContextProperty("appPath", app.applicationDirPath());
2019-07-18 10:17:02 +08:00
view.rootContext()->setContextProperty("view", &view);
2020-06-14 00:57:36 +08:00
view.rootContext()->setContextProperty("trans", &trans);
2020-07-01 00:16:13 +08:00
const QUrl url(qmlPath + QStringLiteral("main.qml"));
QObject::connect(&view, &QQuickView::statusChanged, [=](QQuickView::Status status){
if (status == QQuickView::Status::Ready) {
afterUiReady();
}
});
view.setSource(url);
2019-08-03 17:47:27 +08:00
view.moveToScreenCenter();
2019-07-18 10:17:02 +08:00
view.show();
return app.exec();
}