#include <QApplication>
#include <qdir.h>
#include <qdebug.h>

#include "mainwindow.h"
#include "centralwidget.h"
#include "serialport/serialport.h"
#include "realtimedataform.h"
#include "experimentsettingform.h"
#include "filemanager.h"
#include "logger.h"
#include "xlsxhandler.h"
#include "aboutform.h"
#include "confighandler.h"

int main(int argc, char *argv[])
{
    //    system("chcp 65001");
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForLocale(codec);

    Logger::instance();
    logde<<"main...";
    //
    ConfigHandler::reader();

    // 启用高DPI支持
    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 启用高DPI缩放
    QApplication a(argc, argv);

    logde<<"version:"<<a.applicationVersion().toStdString();

    QIcon icon;
    icon.addFile(":/images/logo.ico", QSize(16, 16));
    icon.addFile(":/images/logo.ico", QSize(32, 32));
    icon.addFile(":/images/logo.ico", QSize(64, 64));

    a.setWindowIcon(icon);

#if 1
    MainWindow w;
    w.setWindowTitle("DSC Analysis Tool");
    w.setWindowIcon(icon);
    w.show();
#endif

    //    EnthalpyDataCorrectionForm edf;
    //    edf.show();

    //    CoefficientSelectionForm csf;
    //    csf.show();

    //    AboutForm af;
    //    af.show();

    //        XlsxHandler::test();


    //   FileManager::test();

    //    ExperimentSettingForm es;
    //    es.show();

    //        CentralWidget central;
    //        central.show();

    //    SerialPort::parserTest();

    //    SerialPort sp;

    //    RealTimeDataForm r;
    //    r.show();

    //    QObject::connect(&sp,&SerialPort::sigSendSerialPortData,
    //                     &r,&RealTimeDataForm::slotRevSerialPortData);

    return a.exec();
}
