#include "app.h" #include #include #include #include #include #include #include #include #include #include void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg) { QByteArray localMsg = msg.toUtf8(); const char * format = "[" + QDate::currentDate().toString(Qt::ISODate).toUtf8() + " " + QTime::currentTime().toString(Qt::ISODate).toUtf8() + "]"; switch (type) { case QtDebugMsg: fprintf(stderr, "%s DEB: %s\n", format, localMsg.constData()); break; case QtInfoMsg: fprintf(stderr, "%s INF: %s\n", format, localMsg.constData()); break; case QtWarningMsg: fprintf(stderr, "%s WAR: %s\n", format, localMsg.constData()); break; case QtCriticalMsg: fprintf(stderr, "%s CRT: %s\n", format, localMsg.constData()); break; case QtFatalMsg: fprintf(stderr, "%s FAT: %s\n", format, localMsg.constData()); abort(); } } int main(int argc, char *argv[]){ //if (argc <= 1 || (argc > 1 && std::string(argv[1]) != std::string("-S") && std::string(argv[1]) != "-prelaunched")) // return 0; // if (app->config->getValue("General", "dpiscale") == "-1") { // QApplication a(argc, argv); // qDebug() << "No value. Detected " << ((QGuiApplication*)QCoreApplication::instance())->primaryScreen()->physicalDotsPerInch(); // app->config->setValue("General", "dpiscale", QString::number(((QGuiApplication*)QCoreApplication::instance())->primaryScreen()->physicalDotsPerInch())); // a.exit(0); // return 0; // } else { // qDebug() << app->config->getValue("general", "dpiscale").toLatin1(); // qputenv("QT_SCALE_FACTOR", app->config->getValue("general", "dpiscale").toLatin1()); // } freopen("log.txt", "w", stdout); freopen("log.txt", "a", stderr); setbuf(stdout, NULL); setbuf(stderr, NULL); setvbuf (stdout, NULL, _IONBF, BUFSIZ); setvbuf (stderr, NULL, _IONBF, BUFSIZ);/**/ qInstallMessageHandler(myMessageOutput);// вывод логов в файл QApplication a(argc, argv); QLockFile lockFile(QDir::temp().absoluteFilePath("rulotro.lock")); if(!lockFile.tryLock(100)){ QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Приложение уже запущено.\nРазрешено запускать только один экземпляр приложения."); msgBox.exec(); return 1; } MainWindow w; App *app = &App::getInstance(); app->logSectionStart("Начинаем работать"); QFile styleF; QString skin = app->helper->getSkinName(); styleF.setFileName(app->app_folder + "styles/" + skin + "/style.css"); styleF.open(QFile::ReadOnly); QString qssStr = styleF.readAll(); qApp->setStyleSheet(qssStr); w.show(); //QFuture future = QtConcurrent::run(w, &MainWindow::doStartPreparations); auto result = a.exec(); lockFile.unlock(); return result; }