You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Src/nmNum/nmGUI/nmGUIDrawerWidget.cpp

76 lines
2.0 KiB
C++

#include "nmGUIDrawerWidget.h"
nmGUIDrawerWidget::nmGUIDrawerWidget(const QString &sTitle, QWidget *parent)
: QWidget(parent), m_bExpanded(true), m_sTitle(sTitle)
{
initUI();
this->setStyleSheet("");
}
void nmGUIDrawerWidget::initUI()
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QWidget *headerWidget = new QWidget(this);
headerWidget->setObjectName("headerWidget");
m_pHeaderLayout = new QHBoxLayout(headerWidget);
m_pHeaderLayout->setContentsMargins(2, 2, 2, 2);
m_pToggleButton = new QToolButton(this);
m_pToggleButton->setArrowType(Qt::DownArrow);
m_pTitleLabel = new QLabel(m_sTitle, this);
m_pTitleLabel->setStyleSheet("font-weight: bold;");
m_pHeaderLayout->addWidget(m_pToggleButton);
m_pHeaderLayout->addWidget(m_pTitleLabel);
m_pHeaderLayout->addStretch();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_pWidgetContent = new QWidget(this);
m_pWidgetContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_pWidgetContent->setVisible(true); // Ĭ<><C4AC>չ<EFBFBD><D5B9>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(headerWidget);
mainLayout->addWidget(m_pWidgetContent);
connect(m_pToggleButton, SIGNAL(clicked()), this, SLOT(toggleExpand()));
}
void nmGUIDrawerWidget::toggleExpand()
{
setExpanded(!m_bExpanded);
}
void nmGUIDrawerWidget::setExpanded(bool expanded)
{
if (expanded != m_bExpanded) {
m_bExpanded = expanded;
m_pToggleButton->setArrowType(expanded ? Qt::DownArrow : Qt::RightArrow);
m_pWidgetContent->setVisible(expanded); // ֱ<><D6B1><EFBFBD><EFBFBD>ʾ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
emit expansionChanged(expanded);
}
}
void nmGUIDrawerWidget::setContentLayout(QLayout *layout)
{
m_pWidgetContent->setLayout(layout);
}
void nmGUIDrawerWidget::setStyleSheet(const QString &style)
{
QString customStyle =
"#headerWidget {"
" background-color: rgb(173, 216, 230);" // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫΪdz<CEAA><C7B3>ɫ
" width: 100%;"
"}"
"QToolButton {"
"}"
"QLabel {"
"}";
QWidget::setStyleSheet(customStyle); // <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><E0B7BD>
}