#include "GuiMain.h"
#include <QWindowStateChangeEvent>

CGuiMain::CGuiMain(QWidget *parent)
    : QMainWindow(parent)
{
    mSMSGui = new CSMSGui(this);
    mSprinklerGui = new CSprinklerGui(this);
    mAvReceiverGui = new CAvReceiverGui(this);
    mMainTabWidget = new QTabWidget(this);
    mChaletGui = new CChaletGui(this);
    mChaletGuiLTE = new CChaletGui(this);
    mIspindelGui = new CIspindelGUI(this);
    mTowerLightShowGui = new CTowerLightShowGui;
    mPICUploaderGui = new CPICUploaderGui;
    setCentralWidget(mMainTabWidget);
    mMainTabWidget->addTab(mSMSGui,"SMS");
    mMainTabWidget->addTab(mSprinklerGui,"Sprinkler");
    mMainTabWidget->addTab(mAvReceiverGui,"AV Receiver");
    mMainTabWidget->addTab(mChaletGui,"Chalet");
    mMainTabWidget->addTab(mTowerLightShowGui,"Lightshow");
    mMainTabWidget->addTab(mPICUploaderGui,"Firmware Upload");
    mMainTabWidget->addTab(mIspindelGui,"ISpindel");
    mMainTabWidget->addTab(mChaletGuiLTE,"Chalet LTE");

    resize(1700,768);
}

CGuiMain::~CGuiMain()
{
   // delete mSMSGui;
}

int CGuiMain::RespawnMainWindow()
{
 //   qDebug("Respawn");
    activateWindow();
    showNormal();
    raise();
    return RET_OK;
}

void CGuiMain::changeEvent(QEvent *event)
{
  //  qDebug("State Changed");
    if (event->type() == QEvent::WindowStateChange)
    {
     //   qDebug("Window state");
        QWindowStateChangeEvent* WinEvent = (QWindowStateChangeEvent*)event;
        if(window()->isMinimized()  && ((WinEvent->oldState() != Qt::WindowMinimized)))
        {
            qDebug("Minimized");

            hide();
        }

    }
}
