12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- // *****************************************************************************
- // 版权所有(C)2023~2099 上海骄成超声波技术有限公司
- // 保留所有权利
- // *****************************************************************************
- // 作者 : 杨坚
- // 版本 : 1.0
- // 功能说明:
- // 侧边栏日志状态
- // *****************************************************************************
- #include "LogStatePage.h"
- #include "QGraphicsEffect"
- LogStateSidebar::LogStateSidebar(QWidget* parent /*= nullptr*/) : QWidget(parent)
- {
- setGraphicsEffect(new QGraphicsDropShadowEffect(this));
- setFixedWidth(200);
- setStyleSheet("background-color: #333; color: white;");
- //setStyleSheet("background-color: rgba(51, 51, 51, 220);");
- // 创建动画
- m_pAnimation = new QPropertyAnimation(this, "pos");
- m_pAnimation->setDuration(300);
- m_pAnimation->setEasingCurve(QEasingCurve::InOutQuad);
- // 添加一些内容
- auto layout = new QVBoxLayout(this);
- layout->addWidget(new QPushButton("Option 1", this));
- layout->addWidget(new QPushButton("Option 2", this));
- layout->addWidget(new QPushButton("Option 3", this));
- layout->addStretch();
- }
- void LogStateSidebar::ShowSidebar()
- {
- m_pAnimation->stop();
- m_pAnimation->setStartValue(QPoint(-width(), y()));
- m_pAnimation->setEndValue(QPoint(0, y()));
- show();
- m_pAnimation->start();
- m_expanded = true;
- }
- void LogStateSidebar::HideSidebar()
- {
- m_pAnimation->stop();
- m_pAnimation->setStartValue(QPoint(x(), y()));
- m_pAnimation->setEndValue(QPoint(-width(), y()));
- connect(m_pAnimation, &QPropertyAnimation::finished, this, [this]() {
- // hide(); // 完成了不要隐藏
- m_expanded = false;
- });
- m_pAnimation->start();
- }
- bool LogStateSidebar::isExpanded()
- {
- return x() >= 0;
- }
|