#include "titlewidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDebug>
#include <QApplication>
TitleWidget::TitleWidget(QWidget * parent ):QFrame(parent)
{
    init();
    initLay();
    initConnect();
}
TitleWidget::~TitleWidget()
{

}

void  TitleWidget::init()
{
    setObjectName("title");

    m_labDes.setText("Sunnyou 翔宇");
    m_labDes.setObjectName("titleDes");
    m_btnRet.setObjectName("titleBtn");
    m_labSystemName.setObjectName("titleSystemName");
    m_labSystemName.setText("Sunlink 多通道无线脑电采集系统");
    m_labDes.setFixedSize(QSize(360,59));

    m_btnRet.setFixedSize(QSize(89,90));

    m_labDes.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_labSystemName.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_btnRet.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

}
void  TitleWidget::initLay()
{
#if 1
    QHBoxLayout * hlay = new QHBoxLayout;
    hlay->addSpacing(85);
    hlay->addWidget(&m_labDes,1,Qt::AlignLeft);
    hlay->addWidget(&m_labSystemName,1,Qt::AlignHCenter);
    //hlay->addStretch();
    hlay->addWidget(&m_btnRet,1,Qt::AlignRight);
    hlay->addSpacing(85);
    setLayout(hlay);
#else
    QGridLayout * hlay = new   QGridLayout;
    hlay->addWidget(&m_labDes,0,0 );
    hlay->addWidget(&m_labSystemName,0,1,Qt::AlignHCenter );
    //hlay->addStretch();
    hlay->addWidget(&m_btnRet,0,2 );
    hlay->setContentsMargins(1,1,1,1);
    setLayout(hlay);
#endif

}

bool  TitleWidget::initConnect()
{
    bool bCon = true;
    bCon = connect(&m_btnRet,SIGNAL(clicked(bool)),qApp,SLOT(quit()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;


    }
 return bCon;
}

