#include "systemsettingwidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDebug>
SystemSettingWidget::SystemSettingWidget(QWidget * parent )
{
    init();
    initLay();
    initConnect();
    //setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);//无边框 置顶
     //  setAttribute(Qt::WA_TranslucentBackground);//透明
     // QString styleSheet = "background-color:rgb(47, 61, 82);border:1px solid white";
     // setStyleSheet(styleSheet);

}
SystemSettingWidget::~SystemSettingWidget()
{

}

void  SystemSettingWidget::init()
{

    //this->setStyleSheet("QWidget{background: rgb(47, 61, 82);border:0px}");
    this->setStyleSheet("QWidget{background: rgb(47, 61, 82);}");
    m_labDes.setStyleSheet("border-image:url(:/image/systemsetting.png);}");
    m_btnRet.setStyleSheet("border-image:url(:/image/icon_back_2.png);}");
    m_labDes.setMaximumSize(QSize(200,30));
    m_labDes.setMinimumSize(QSize(200,30));
    m_btnRet.setMaximumSize(QSize(100,30));
    m_btnRet.setMinimumSize(QSize(100,30));

     m_NavListWidget.setList(QStringList()<<"填写病例"<<"病例管理"<<"导联方案"<<"参数设置"<<"医院信息",
                             QStringList()<<"fill-in-the-Case" << "case-management" << "leading-scheme" << "Parameter-setting" << "hospital-information");

    m_NavListWidget.setStyleSheet("QPushButton{\
              background: rgba(51, 71, 75);\
              color: white;\
              border-radius: 8px;\
              border:0px ; \
      }\
      QPushButton:hover{\
              color: black;\
              background: rgb(85, 85, 85);\
              border-radius: 8px;\
      }\
      QPushButton:pressed{\
              color: black;\
              background: rgb(80, 80, 80);\
              border-radius: 8px;\
      }\
      QPushButton:checked{\
              color: white;\
                               background: #0d9ddb;\
              border-radius: 8px;\
      }"\
     "QWidget#NavList1{background-color:rgb(47, 61, 82);}"\
);
}
void  SystemSettingWidget::initLay()
{
    QHBoxLayout * hlay   = new QHBoxLayout;
    hlay->addWidget(&m_btnRet,1,Qt::AlignLeft);
    hlay->addWidget(&m_labDes,9, Qt::AlignHCenter);
    QWidget * w1  = new QWidget;
    w1->setFixedHeight(60);
    w1->setStyleSheet("QWidget{background-color:#ffffff;}");
    w1->setLayout(hlay);
    QVBoxLayout * vlay  = new QVBoxLayout;
    vlay->addWidget(w1,1);
    QWidget * w  = new QWidget;
    //w->setStyleSheet("QWidget{background-color:#ffffff;border:1px solid blcak}");
    w->setStyleSheet("QWidget{background-color:#ffffff;}");
     w->setStyleSheet("QWidget{background: rgb(47, 61, 82);}");
    vlay->addWidget(w,9);
    vlay->setContentsMargins(0,0,0,0);
    vlay->setSpacing(10);
    setLayout(vlay);

    QHBoxLayout * hlayMain = new QHBoxLayout;

    w ->setLayout(hlayMain);
    hlayMain->addWidget(&m_NavListWidget,1);
    hlayMain->addWidget(&m_stackedWidget,9);
    hlayMain->setContentsMargins(0,0,0,0);

}
bool  SystemSettingWidget::initConnect()
{
    bool bCon = true;
    bCon = connect(&m_btnRet,SIGNAL(clicked(bool)),this,SLOT(slotClickedChanged()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;

    }
    bCon = connect(&m_NavListWidget,SIGNAL(SigClicked(QString)),this,SLOT(slotClickedBtn(QString)));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;

    }
    return bCon;
}
void SystemSettingWidget::slotClickedChanged()
{

    QObject * send = static_cast<QObject *>(sender());
    if(send == nullptr)
    {
        return;
    }
    emit SigClicked(send->objectName());
    QString strName = send->objectName();
    qDebug()<<send->objectName()<<endl;
}
 void SystemSettingWidget::slotClickedBtn(QString strName)
 {


     if(strName.compare("fill-in-the-Case")==0)
     {
        m_stackedWidget.addWidget(&m_MedicalRecordWidget);
         m_stackedWidget.setCurrentWidget(&m_MedicalRecordWidget);

     }
     else if(strName.compare("case-management")==0)
     {

         m_stackedWidget.addWidget(&m_MedicalRecordManagerWidget);
         m_stackedWidget.setCurrentWidget(&m_MedicalRecordManagerWidget);

     }//Parameter setting
     else if(strName.compare("Parameter-setting")==0)
     {

         m_stackedWidget.addWidget(&m_ParameterSettingsWidget);
         m_stackedWidget.setCurrentWidget(&m_ParameterSettingsWidget);

     }//hospital-information
     else if(strName.compare("hospital-information")==0)
     {

         m_stackedWidget.addWidget(&m_hospitalinformationWidget);
         m_stackedWidget.setCurrentWidget(&m_hospitalinformationWidget);

     }
 }

