#ifdef _DEBUG #include #endif #include "mainwindow.h" #include "qtsingleapplication.h" #include #include #include #include #include #include #include #include #include #include #include "cloggermaganer.h" int main(int argc, char *argv[]) { QString app_unique_name("emsConfigurer_application_name"); QtSingleApplication app(app_unique_name,argc, argv); if(app.isRunning()) { QMessageBox::information(nullptr, "EMS Configurer", "Another instance is already running."); app.sendMessage("raise_window_noop", 1000); //1s后激活前个实例 return EXIT_SUCCESS; } main_ctx_init(argc, argv); QString appDir = QCoreApplication::applicationDirPath(); std::string logFilePath = (appDir + QString::fromStdString("/emsConfigurer.log")).toStdString(); hlog_set_file(logFilePath.c_str()); hlogi("=========--- Welcome to the Earth ---=========\n"); hlogi("%s version: %s\n", argv[0], "1.1.0"); hlog_fsync(); hlogi("%s versionversionversionversionversionversion: %s\n", argv[0], "1.1.0"); QTranslator translator; const QStringList uiLanguages = QLocale::system().uiLanguages(); for (const QString &locale : uiLanguages) { const QString baseName = "emsConfigurer_" + QLocale(locale).name(); if (translator.load(":/i18n/" + baseName)) { app.installTranslator(&translator); break; } } MainWindow w; //获取窗口尺寸并居中 QScreen *scr = app.primaryScreen(); int scr_w = scr->size().width(); int scr_h = scr->size().height(); w.move((scr_w - w.width()) / 2, (scr_h - w.height()) / 2); w.show(); return app.exec(); }