#include "navlistwidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDebug>
#include <QButtonGroup>
NavListWidget::NavListWidget(QFrame * parent )
{
    init();
    initLay();
    initConnect();
    m_size =QSize(200,60);
}
NavListWidget::~NavListWidget( )
{

}

 void NavListWidget::setCustomSize(QSize tempSize)
 {
     m_size = tempSize;
 }
void  NavListWidget::init()
{

}
void  NavListWidget::initLay()
{

}
bool  NavListWidget::initConnect()
{

}
 void  NavListWidget::onButtonClicked( QAbstractButton *button)
 {

     if(button == nullptr)
     {
         return;
     }
     emit SigClicked(button->objectName() );
     qDebug()<< button->objectName()<<endl;
 }
 void  NavListWidget::setList(QStringList strlist,QStringList strlistObjectName)
 {

     QVBoxLayout   * vlay =  new  QVBoxLayout;
    // QGridLayout * gridlay  = new QGridLayout;
     QVBoxLayout * gridlay  = new QVBoxLayout;
     vlay->addLayout(gridlay);
     vlay->addStretch();
     setLayout(vlay);
     QButtonGroup *pButtonGroup = new QButtonGroup(this);

     // 设置互斥
     pButtonGroup->setExclusive(true);


     bool ok = connect(pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onButtonClicked(QAbstractButton*)));




     for (int i =0;i<strlist.size();i++)
     {
        QPushButton *btn =  new QPushButton(strlist.at(i));
        btn->setObjectName(strlistObjectName.at(i));
        btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        pButtonGroup->addButton(btn);
        //btn->setFixedSize(m_size);
       // btn->setMinimumSize(QSize(200,80));
        //btn->setMaximumSize(QSize(80,20));
        btn->setMaximumHeight(50);
        btn->setCheckable(true);
        gridlay->addWidget( btn);
        gridlay->setSpacing(10);

     }
     gridlay->addStretch();
//#263749
#if  0
 setObjectName("NavList");
 setStyleSheet("QPushButton{\
               background: rgba(51, 71, 75);\
               color: white;\
               border-radius: 30px;\
               font-size: 16px;\
font-weight: bold;\
       }\
       QPushButton:hover{\
               background: rgb(85, 85, 85);\
border-radius: 30px;\
       }\
       QPushButton:pressed{\
               background: rgb(80, 80, 80);\
border-radius: 30px;\
       }\
       QPushButton:checked{\
               background: #0d9ddb;\
border-radius: 30px;\
       }"\
 "QWidget#NavList{background-color:rgb(47, 61, 82);}"\
 );
#endif

 }
