#include "mainobject.h"
#include "global.h"
#include "singleapplication.h"

#include <QApplication>
#include <QFile>
#include <QSharedMemory>
#include <QDebug>

int main(int argc, char *argv[])
{
    SingleApplication a(argc, argv);
    Global::Instance()->setRootDirPath(qApp->applicationDirPath());


    MainObject w;

    QFile styleFile(QString("%1/style/%2/style.css")
                    .arg(Global::Instance()->resourceDirPath())
                    .arg(Global::Instance()->theme()));
    if(styleFile.open(QIODevice::ReadOnly))
    {
        qApp->setStyleSheet(styleFile.readAll());
        styleFile.close();
    }

    QObject::connect( &a, &SingleApplication::instanceStarted, [ &w ]() {
        w.secondary();
    });
//    w.showLogin();
    w.showMainWindow();

    return a.exec();
}
