#include <QApplication>
#include <QDir>
#include "mainwindow.h"
#include "logger.h"
#include "appcontext.h"

#define SCREEN_WIDTH    1280
#define SCREEN_HEIGHT   720

int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
    QApplication app(argc, argv);

#ifdef NDEBUG
    Logger::setup(Logger::INFO);
#else
    Logger::setup(Logger::TRACE);
#endif

    AppContext &appCtx = AppContext::instance();
    ProjectManager &projectMgr = appCtx.projectManager();
    QString fileName = QString("%1/%2").arg(QDir::currentPath(), "conf/monitor.xml");
    bool result = projectMgr.openProject(fileName);
    if(result)
    {
        LOG_INFO("open monitor config xml success: {}, canvas count: {}", fileName.toUtf8().data(), projectMgr.canvasCount());
    }
    else
    {
        LOG_ERROR("open monitor config xml failed: {}", fileName.toUtf8().data());
    }
    
    MainWindow w;
    w.resize(SCREEN_WIDTH, SCREEN_HEIGHT);
    w.showFullScreen();

    int ret = app.exec();
    return ret;
}