123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #include <QApplication>
- #include <QFontDatabase>
- #include <QMessageBox>
- #include <QDebug>
- #include "spdlog/spdlog.h"
- #include "logs/loginit.h"
- #include "EyeMapWidget.h"
- #include "EyeMapInfo.h"
- #include "OscDataInfo.h"
- #include "softdog.h"
- void addFont(const QString& appPath);
- int main(int argc, char* argv[])
- {
- QApplication app(argc, argv);
- /* 初始化日志库 */
- init_log();
- auto logger = spdlog::get("main");
- if(logger == nullptr)
- {
- SPDLOG_ERROR("main logger is nullptr");
- return -1;
- }
- SPDLOG_LOGGER_INFO(logger, "★ ★ ★ ★ ★ Oscilloscope ★ ★ ★ ★ ★");
- /* 加载字体 */
- auto appPath = QApplication::applicationDirPath();
- addFont(appPath);
- /* 验证加密狗 */
- #ifdef C_RELEASE
- // QString errMsg;
- // if(!(SoftDog::DogCheck(errMsg, 30, QLatin1String("eqmyt"))))
- // {
- // SPDLOG_LOGGER_ERROR(logger, "加密狗错误信息:{}", errMsg.toStdString());
- // QMessageBox::critical(nullptr, "错误", errMsg);
- // // MessageBox::execTip(errMsg, MessageBox::ERROR, true);
- // return 0;
- // }
- #endif
- /* 初始化眼图组件 */
- GEyeMapInfo.initEyeMapInfo();
- /* 初始化示波器实例 */
- GOscDataInfo.initOscData();
- EyeMapWidget w;
- w.show();
- w.startCapture();
- // std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
- // double a = 330.2, b = 2.2;
- // for (long long i = 0; i < 1000000000; ++i)
- // {
- // b = a * b;
- // }
- // std::chrono::steady_clock::time_point end1 = std::chrono::steady_clock::now();
- // long long c = 3200, d = 22;
- // for (long long i = 0; i < 1000000000; ++i) {
- // d = c * d;
- // }
- // std::chrono::steady_clock::time_point end2 = std::chrono::steady_clock::now();
- // SPDLOG_LOGGER_INFO(logger, "double time: {}", std::chrono::duration_cast<std::chrono::milliseconds>(end1 - begin).count());
- // SPDLOG_LOGGER_INFO(logger, "long long time: {}", std::chrono::duration_cast<std::chrono::milliseconds>(end2 - end1).count());
- return app.exec();
- }
- /* 加载字体 */
- void addFont(const QString& appPath)
- {
- QString fontPath = appPath + "/Rec/SiYuanBlack_ttf";
- SPDLOG_DEBUG("font path:{}", fontPath.toStdString());
- /* 加载字体 */
- int id1 = QFontDatabase::addApplicationFont(fontPath + "/SiYuanBlack_Bold.ttf");
- int id2 = QFontDatabase::addApplicationFont(fontPath + "/SiYuanBlack_M.ttf");
- int id3 = QFontDatabase::addApplicationFont(fontPath + "/SiYuanBlack_R.ttf");
- /***************************************************
- * 字体使用方式
- * id1 ("思源黑体-粗")
- * id2 ("思源黑体M")
- * id3 ("思源黑体R")
- ****************************************************/
- if (id1 == -1 || id2 == -1 || id3 == -1) {
- SPDLOG_ERROR("Failed to load one or more fonts");
- } else {
- // qDebug() << "font id1" << QFontDatabase::applicationFontFamilies(id1);
- // qDebug() << "font id2" << QFontDatabase::applicationFontFamilies(id2);
- // qDebug() << "font id3" << QFontDatabase::applicationFontFamilies(id3);
- SPDLOG_INFO("font id1:{}", QFontDatabase::applicationFontFamilies(id1).at(0).toStdString());
- SPDLOG_INFO("font id2:{}", QFontDatabase::applicationFontFamilies(id2).at(0).toStdString());
- SPDLOG_INFO("font id3:{}", QFontDatabase::applicationFontFamilies(id3).at(0).toStdString());
- }
- QFont font_main;
- font_main.setFamily("思源黑体R");
- font_main.setPixelSize(14);
- QApplication::setFont(font_main);
- }
|