/* 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 . */ #include "mainwindow.h" #include "mainwindownew.h" #include "connectandenterpage.h" #include #include #include #include #include #include "mobile/qmlui.h" #define NEW_GUI 1 int main(int argc, char *argv[]) { constexpr char const *APP_NAME = "ENNOID-BMS Tool"; // Settings QCoreApplication::setOrganizationName("DieBie"); QCoreApplication::setOrganizationDomain("diebie.nl"); QCoreApplication::setApplicationName(APP_NAME); // DPI settings // TODO: http://www.qcustomplot.com/index.php/support/forum/1344 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #ifdef USE_MOBILE QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #else QCoreApplication::setAttribute(Qt::AA_Use96Dpi); QSettings set; bool scaleAuto = true; double scale = 1.0; if (set.contains("app_scale_auto")) { scaleAuto = set.value("app_scale_auto").toBool(); } else { set.setValue("app_scale_auto", scaleAuto); } if (scaleAuto) { QApplication tmp(argc, argv); QRect rec = tmp.desktop()->screenGeometry(); int height = rec.height(); int width = rec.width(); double ptFont = tmp.font().pointSizeF(); if (ptFont < 0.0) { ptFont = tmp.font().pixelSize(); } if (width > 3000 && height > 1700) { scale = 1.5; } else { if (ptFont > 11.0) { scale = ptFont / 11.0; } } set.setValue("app_scale_factor", scale); } else if (set.contains("app_scale_factor")) { scale = set.value("app_scale_factor").toDouble(); } set.setValue("app_scale_factor", scale); #ifdef Q_OS_ANDROID scale = 1.0; #endif if (scale > 1.01) { qputenv("QT_SCALE_FACTOR", QString::number(scale).toLocal8Bit()); } #endif QApplication a(argc, argv); #if NEW_GUI // Fonts QFontDatabase::addApplicationFont("://res/fonts/Artifakt-Element.ttf"); qApp->setFont(QFont("Artifakt Element", 12)); #else // Fonts QFontDatabase::addApplicationFont("://res/fonts/DejaVuSans.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSans-Bold.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSans-BoldOblique.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSans-Oblique.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSansMono.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSansMono-Bold.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSansMono-BoldOblique.ttf"); QFontDatabase::addApplicationFont("://res/fonts/DejaVuSansMono-Oblique.ttf"); qApp->setFont(QFont("DejaVu Sans", 11)); // Style a.setStyleSheet(""); a.setStyle(QStyleFactory::create("Fusion")); #endif #ifdef USE_MOBILE QmlUi q; q.startQmlUi(); #else #if NEW_GUI MainWindowNew w; w.setWindowTitle(APP_NAME); w.show(); //} else { // a.closeAllWindows(); // return 0; //} #else MainWindow w; w.show(); #endif #endif return a.exec(); }