Files
CuboBmsTool/main.cpp
2022-11-11 12:56:22 +03:00

85 lines
3.0 KiB
C++

/*
Original copyright 2018 Benjamin Vedder benjamin@vedder.se and the VESC Tool project (
https://github.com/vedderb/vesc_tool ) Now forked to: Danny Bokma github@diebie.nl
This file is part of BMS Tool.
ENNOID-BMS Tool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ENNOID-BMS Tool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bmsinterface.h"
#include "utility.h"
#include "translator.h"
#include "firmwareupdatehelper.h"
#include <QApplication>
#include <QFontDatabase>
#include <QQmlApplicationEngine>
#include <QtSvg>
QObject *bmsInterfaceSingletontypeProvider(QQmlEngine */*engine*/, QJSEngine */*scriptEngine*/)
{
auto *bmsInterface = new BMSInterface();
bmsInterface->bmsConfig()->loadParamsXml("://res/config.xml");
bmsInterface->infoConfig()->loadParamsXml("://res/info.xml");
return bmsInterface;
}
QObject *utilitySingletontypeProvider(QQmlEngine */*engine*/, QJSEngine */*scriptEngine*/)
{
auto *utility = new Utility();
return utility;
}
QObject *translatorSingletontypeProvider(QQmlEngine *engine, QJSEngine */*scriptEngine*/)
{
auto *translator = new Translator(engine);
return translator;
}
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(res);
Q_INIT_RESOURCE(translations);
Q_INIT_RESOURCE(qml_icons);
Q_INIT_RESOURCE(qml_items);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setOrganizationName("Cubo");
QCoreApplication::setOrganizationDomain("Cubo.rus");
QCoreApplication::setApplicationName("Cubo Verde BMS Tool");
QApplication app(argc, argv);
QFontDatabase::addApplicationFont("://res/fonts/Artifakt-Element.ttf");
QFont font("Artifakt Element", 16, QFont::Normal);
font.setStyleStrategy(QFont::PreferAntialias);
app.setFont(font);
QQmlApplicationEngine engine;
qmlRegisterSingletonType<BMSInterface>("Cubo", 1, 0, "BmsInterface", bmsInterfaceSingletontypeProvider);
qmlRegisterSingletonType<Utility>("Cubo", 1, 0, "Utility", utilitySingletontypeProvider);
qmlRegisterSingletonType<Translator>("Cubo", 1, 0, "Translator", translatorSingletontypeProvider);
qmlRegisterType<Commands>("Cubo", 1, 0, "Commands");
qmlRegisterType<ConfigParams>("Cubo", 1, 0, "ConfigParams");
qmlRegisterType<FirmwareUpdateHelper>("Cubo", 1, 0, "FirmwareUpdateHelper");
engine.addImportPath(QStringLiteral("qrc:/"));
engine.load(QUrl(QStringLiteral("qrc:/MainWindow.qml")));
return app.exec();
}