#include "mainobject.h"

#include "inittip.h"
#include "framelesswindow.h"

#include <QTimer>
#include <QThread>

MainObject::MainObject(QObject *parent)
    : QObject(parent)
    , mMainWindow(nullptr)
{
    mInitTipWidget = new InitTip;
    mInitTipWidget->resize(814, 541);
    //mInitTipWidget->setAttribute(Qt::WA_StyledBackground, true);

    // 设置不在任务栏显示、无边框、顶层显示
    mInitTipWidget->setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
}

void MainObject::showInitWidget()
{
    mInitTipWidget->show();
    if(!mMainWindow)
    {
        QTimer::singleShot(10, [=](){
            mMainWindow = new FramelessWindow;
        });

        QTimer::singleShot(500, [=](){
            mInitTipWidget->hide();
            mMainWindow->showMaximized();
            mMainWindow->raise();
            mMainWindow->activateWindow();
        });
    }
}

