mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
107 lines
4.5 KiB
C++
107 lines
4.5 KiB
C++
|
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
// Copyright (c) 2020-2021, The Monero Project.
|
||
|
|
||
|
#include <iostream>
|
||
|
#include <QResource>
|
||
|
#include <QApplication>
|
||
|
#include <QCoreApplication>
|
||
|
#include <QQmlComponent>
|
||
|
#include <QtCore>
|
||
|
#include <QtGui>
|
||
|
#include <QQmlApplicationEngine>
|
||
|
#include <QtQml>
|
||
|
#include <QQuickView>
|
||
|
#include <QQuickItem>
|
||
|
|
||
|
#include "openvr.h"
|
||
|
#include "vr/openvr_init.h"
|
||
|
#include "vr/main.h"
|
||
|
|
||
|
#include "libwalletqt/TransactionInfo.h"
|
||
|
#include "libwalletqt/TransactionHistory.h"
|
||
|
#include "model/TransactionHistoryModel.h"
|
||
|
#include "model/TransactionHistoryProxyModel.h"
|
||
|
#include "libwalletqt/WalletManager.h"
|
||
|
|
||
|
#include "utils/keysfiles.h"
|
||
|
|
||
|
namespace wowletvr {
|
||
|
|
||
|
void check_error(int line, vr::EVRInitError error) { if (error != 0) printf("%d: error %s\n", line, VR_GetVRInitErrorAsSymbol(error)); }
|
||
|
|
||
|
WowletVR::WowletVR(AppContext *ctx, QCommandLineParser *parser, QObject *parent) :
|
||
|
QObject(parent), ctx(ctx), m_parser(parser) {
|
||
|
desktopMode = m_parser->isSet("openvr-debug");
|
||
|
|
||
|
#ifdef Q_OS_WIN
|
||
|
if(desktopMode)
|
||
|
qputenv("QMLSCENE_DEVICE", "softwarecontext");
|
||
|
#endif
|
||
|
|
||
|
qDebug() << "QMLSCENE_DEVICE: " << qgetenv("QMLSCENE_DEVICE");
|
||
|
|
||
|
m_engine.rootContext()->setContextProperty("homePath", QDir::homePath());
|
||
|
m_engine.rootContext()->setContextProperty("applicationDirectory", QApplication::applicationDirPath());
|
||
|
m_engine.rootContext()->setContextProperty("idealThreadCount", QThread::idealThreadCount());
|
||
|
m_engine.rootContext()->setContextProperty("qtRuntimeVersion", qVersion());
|
||
|
m_engine.rootContext()->setContextProperty("ctx", ctx);
|
||
|
|
||
|
// qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard");
|
||
|
qRegisterMetaType<NetworkType::Type>();
|
||
|
qmlRegisterType<NetworkType>("wowlet.NetworkType", 1, 0, "NetworkType");
|
||
|
|
||
|
qmlRegisterUncreatableType<WalletKeysFiles>("wowlet.WalletKeysFiles", 1, 0, "WalletKeysFiles", "lol");
|
||
|
qmlRegisterUncreatableType<Wallet>("wowlet.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
||
|
qmlRegisterType<WalletManager>("wowlet.WalletManager", 1, 0, "WalletManager");
|
||
|
|
||
|
qmlRegisterUncreatableType<TransactionHistoryProxyModel>("wowlet.TransactionHistoryProxyModel", 1, 0, "TransactionHistoryProxyModel", "TransactionHistoryProxyModel can't be instantiated directly");
|
||
|
qmlRegisterUncreatableType<TransactionHistoryModel>("wowlet.TransactionHistoryModel", 1, 0, "TransactionHistoryModel", "TransactionHistoryModel can't be instantiated directly");
|
||
|
qmlRegisterUncreatableType<TransactionInfo>("wowlet.TransactionInfo", 1, 0, "TransactionInfo", "TransactionHistory can't be instantiated directly");
|
||
|
qmlRegisterUncreatableType<TransactionHistory>("wowlet.TransactionHistory", 1, 0, "TransactionHistory", "TransactionHistory can't be instantiated directly");
|
||
|
|
||
|
qRegisterMetaType<PendingTransaction::Priority>();
|
||
|
qRegisterMetaType<TransactionInfo::Direction>();
|
||
|
qRegisterMetaType<TransactionHistoryModel::TransactionInfoRole>();
|
||
|
|
||
|
// @TODO: custom DPI / AA
|
||
|
// QCoreApplication::setAttribute( Qt::AA_UseDesktopOpenGL );
|
||
|
// QCoreApplication::setAttribute( Qt::AA_Use96Dpi );
|
||
|
|
||
|
auto widgetUrl = QUrl(QStringLiteral("qrc:///main"));
|
||
|
m_component = new QQmlComponent(&m_engine, widgetUrl);
|
||
|
|
||
|
this->errors = m_component->errors();
|
||
|
for (auto &e : this->errors)
|
||
|
qCritical() << "QML Error: " << e.toString().toStdString().c_str();
|
||
|
|
||
|
if(!desktopMode) {
|
||
|
openvr_init::initializeOpenVR(openvr_init::OpenVrInitializationType::Overlay);
|
||
|
m_controller = new wowletvr::OverlayController(desktopMode, m_engine);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void WowletVR::render() {
|
||
|
auto quickObj = m_component->create();
|
||
|
QQuickItem *quickObjItem = qobject_cast<QQuickItem*>(quickObj);
|
||
|
|
||
|
auto displayName = application_strings::applicationDisplayName;
|
||
|
auto appKey = application_strings::applicationKey;
|
||
|
|
||
|
if(desktopMode) {
|
||
|
auto m_pWindow = new QQuickWindow();
|
||
|
qobject_cast<QQuickItem *>(quickObj)->setParentItem(m_pWindow->contentItem());
|
||
|
m_pWindow->setGeometry(0, 0,
|
||
|
static_cast<int>(qobject_cast<QQuickItem *>(quickObj)->width()),
|
||
|
static_cast<int>(qobject_cast<QQuickItem *>(quickObj)->height()));
|
||
|
m_pWindow->show();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
m_controller->SetWidget(quickObjItem, displayName, appKey);
|
||
|
}
|
||
|
|
||
|
WowletVR::~WowletVR() {
|
||
|
int weoignwieog = 1;
|
||
|
};
|
||
|
|
||
|
}
|