#include "editiondirinfo.h"

editionDirInfo::editionDirInfo()
{
    m_EditionButton = new PushButtonCheck(m_edition);
    m_EditionButton->setObjectName("EditionButton");
    m_EditionButton->setStyleSheet("QPushButton{\
                                                   width: 320px;\
                                                   height: 48px;\
                                                   opacity: 1;\
                                                   border-radius: 6px;\
                                                   border:2px;\
                                                   font-size: 14px;\
                                                   font-family: Noto Sans CJK SC;\
                                                   font-weight: 500;\
                                                   text-align:left;\
                                                   line-height: 35px;\
                                                   color: #FFFFFF;\
                                                   background-color: rgba(0, 0, 0, 0.1);\
                                                }"
                                     "QPushButton:hover{background: rgba(255, 255, 255, 0.35)};"
                                     "QPushButton:foucs{background: #FF0000};"
                                     "QPushButton:checked{background: rgba(255, 255, 255, 0.1)};"
//                                   "QPushButton:pressed{background: #119A50};"
                            );

    connect(m_EditionButton,&QPushButton::clicked,this,[=](){emit checkButton_sig(this);});
}

void editionDirInfo::translater(QString langue){
    if(m_EditionButton){
        QString strValue = m_LangtoNameMap[langue];
        if(strValue.isEmpty()){
            strValue = m_edition;
        }
        m_EditionButton->setText( "     " + strValue );
        m_EditionButton->update();
    }
 }

void editionDirInfo::other_clicked_slot(editionDirInfo*  objname)
{
    if(objname){
        if(this == objname){
//            m_EditionButton->setStyleSheet("QPushButton#EditionButton{background-color: rgba(255, 255, 255, 0.1); }" );
            setChecked(true);
            m_EditionButton->setLabelShow(true);
        }else{
//            m_EditionButton->setStyleSheet("QPushButton#EditionButton{background-color: rgba(0, 0, 0, 0.1); }" );
            setChecked(false);
            m_EditionButton->setLabelShow(false);
        }
    }
}

void editionDirInfo::setChecked(bool isSet)
{
    if(isSet){
        m_EditionButton->setStyleSheet("QPushButton{\
                                                       width: 320px;\
                                                       height: 48px;\
                                                       opacity: 1;\
                                                       border-radius: 6px;\
                                                       border:2px;\
                                                       font-size: 14px;\
                                                       font-family: Noto Sans CJK SC;\
                                                       font-weight: 500;\
                                                       text-align:left;\
                                                       line-height: 35px;\
                                                       color: #FFFFFF;\
                                                       background-color: rgba(255, 255, 255, 0.1);\
                                                    }"
                                         "QPushButton:hover{background: rgba(255, 255, 255, 0.35)};"
                                         "QPushButton:foucs{background: #FF0000};"
                                         "QPushButton:checked{background: rgba(255, 255, 255, 0.1)};"
    //                                   "QPushButton:pressed{background: #119A50};"
                                );
    }else{
        m_EditionButton->setStyleSheet("QPushButton{\
                                               width: 320px;\
                                               height: 48px;\
                                               opacity: 1;\
                                               border-radius: 6px;\
                                               border:2px;\
                                               font-size: 14px;\
                                               font-family: Noto Sans CJK SC;\
                                               font-weight: 500;\
                                               text-align:left;\
                                               line-height: 35px;\
                                               color: #FFFFFF;\
                                               background-color: rgba(0, 0, 0, 0.1);\
                                            }"
                                 "QPushButton:hover{background: rgba(255, 255, 255, 0.35)};"
                                 "QPushButton:foucs{background: #FF0000};"
                                 "QPushButton:checked{background: rgba(255, 255, 255, 0.1)};"
//                                   "QPushButton:pressed{background: #119A50};"
                        );
    }
}
