#include "mainwindow.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDebug>

MainWindow::MainWindow(QWidget * parent  ):QWidget(parent)
{
    init();
    initLay();
    initConnect();
}
MainWindow::~MainWindow()
{

}

void  MainWindow::init()
{
        setWindowTitle(" ");
        m_btnSystemSetting.setObjectName("SystemSetting");
        m_btnEEG.setObjectName("EEG");
        m_btnDataProcess.setObjectName("DataProcess");
         m_CompanyDes.setText("河南翔宇医疗设备股份有限公司");
         QFont font ("Microsoft YaHei", 10, 85);
         m_CompanyDes.setFont(font);

        m_CompanyDes.setStyleSheet("color:Gray;");


}
void  MainWindow::initLay()
{

     QHBoxLayout  * hlay  = new QHBoxLayout;

      m_btnSystemSetting.setStyleSheet("border-image:url(:/image/index_bg_setting_char.png);}");
      m_btnEEG.setStyleSheet("border-image:url(:/image/index_bg_EEG_char.png);}");
      m_btnDataProcess.setStyleSheet("border-image:url(:/image/index_bg_data_char.png);}");

      m_btnSystemSetting.setStyleSheet("QPushButton{border-image:url(:/image/index_bg_setting_char.png);}"
                             "QPushButton:hover{border-image:url(:/image/index_bg_setting_hover.png);}"
                             "QPushButton:pressed{border-image:url(:/image/index_bg_setting_checked.png);}"
                             );

      m_btnEEG.setStyleSheet("QPushButton{border-image:url(:/image/index_bg_EEG_char.png);}"
                             "QPushButton:hover{border-image:url(:/image/index_bg_EEG_hover.png);}"
                             "QPushButton:pressed{border-image:url(:/image/index_bg_EEG_checked.png);}"
                             );

      m_btnDataProcess.setStyleSheet("QPushButton{border-image:url(:/image/index_bg_data_char.png);}"
                             "QPushButton:hover{border-image:url(:/image/index_bg_data_hover.png);}"
                             "QPushButton:pressed{border-image:url(:/image/index_bg_data_checked.png);}"
                             );
      m_btnSystemSetting.setMaximumSize(QSize(400,300));
      m_btnEEG.setMaximumSize(QSize(400,300));
      m_btnDataProcess.setMaximumSize(QSize(400,300));


      m_btnSystemSetting.setMinimumSize(QSize(300,200));
      m_btnEEG.setMinimumSize(QSize(300,300));
      m_btnDataProcess.setMinimumSize(QSize(300,300));

       m_btnSystemSetting.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       m_btnEEG.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
       m_btnDataProcess.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

     hlay->addSpacing(150);
     hlay->addWidget(&m_btnSystemSetting);
     hlay->addSpacing(50);
     hlay->addWidget(&m_btnEEG);
     hlay->addSpacing(50);
     hlay->addWidget(&m_btnDataProcess);
     hlay->addSpacing(150);


     QVBoxLayout *vLay = new QVBoxLayout;

     m_titleWidget.setFixedHeight(100);

     hlay->setSpacing(1);

     vLay->addWidget(&m_titleWidget,1,Qt::AlignTop);
     vLay->addSpacing(3);

     vLay->addLayout(hlay,15);
    vLay->setContentsMargins(0,0,0,0);

     vLay->addWidget(&m_CompanyDes,1,Qt::AlignBottom | Qt::AlignHCenter);//,
     vLay->addSpacing(30);
     setLayout(vLay);
}
bool  MainWindow::initConnect()
{
    bool bCon = true;
    bCon = connect(&m_btnEEG,SIGNAL(clicked(bool)),this,SLOT(slotBtn()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;
        return bCon;

    }
    bCon = connect(&m_btnDataProcess,SIGNAL(clicked(bool)),this,SLOT(slotBtn()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;
        return bCon;;

    }
    bCon = connect(&m_btnSystemSetting,SIGNAL(clicked(bool)),this,SLOT(slotBtn()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;
        return bCon;
    }
    return bCon;
}
void MainWindow::slotBtn()
{
    QObject * send = static_cast<QObject *>(sender());
    if(send == nullptr)
    {
        return;
    }
    emit SigClicked(send->objectName());
    //qDebug()<< send->objectName()<<endl;

}
