| 31 | Q_PROPERTY_CREATE_Q_CPP(ElaAppBar, bool, IsOnlyAllowMinAndClose) |
| 32 | |
| 33 | ElaAppBar::ElaAppBar(QWidget* parent) |
| 34 | : QWidget{parent}, d_ptr(new ElaAppBarPrivate()) |
| 35 | { |
| 36 | Q_D(ElaAppBar); |
| 37 | d->_buttonFlags = ElaAppBarType::RouteBackButtonHint | ElaAppBarType::RouteForwardButtonHint | ElaAppBarType::StayTopButtonHint | ElaAppBarType::ThemeChangeButtonHint | ElaAppBarType::MinimizeButtonHint | ElaAppBarType::MaximizeButtonHint | ElaAppBarType::CloseButtonHint; |
| 38 | window()->setAttribute(Qt::WA_Mapped); |
| 39 | d->_pAppBarHeight = 45; |
| 40 | setFixedHeight(d->_pAppBarHeight); |
| 41 | window()->setContentsMargins(0, this->height(), 0, 0); |
| 42 | d->q_ptr = this; |
| 43 | d->_pIsStayTop = false; |
| 44 | d->_pIsFixedSize = false; |
| 45 | d->_pIsDefaultClosed = true; |
| 46 | d->_pIsOnlyAllowMinAndClose = false; |
| 47 | d->_pCustomMenu = nullptr; |
| 48 | window()->installEventFilter(this); |
| 49 | #ifdef Q_OS_WIN |
| 50 | if (!eWinHelper->getIsWinVersionGreater10()) |
| 51 | { |
| 52 | d->_win7Margins = 8; |
| 53 | } |
| 54 | #if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 3) && QT_VERSION <= QT_VERSION_CHECK(6, 6, 1)) |
| 55 | window()->setWindowFlags((window()->windowFlags()) | Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint); |
| 56 | #endif |
| 57 | #else |
| 58 | window()->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint | Qt::WindowFullscreenButtonHint | Qt::WindowSystemMenuHint); |
| 59 | #endif |
| 60 | setMouseTracking(true); |
| 61 | setObjectName("ElaAppBar"); |
| 62 | setStyleSheet("#ElaAppBar{background-color:transparent;}"); |
| 63 | d->_routeBackButton = new ElaToolButton(this); |
| 64 | d->_routeBackButton->setElaIcon(ElaIconType::ArrowLeft); |
| 65 | d->_routeBackButton->setFixedSize(35, 30); |
| 66 | d->_routeBackButton->setEnabled(false); |
| 67 | // 路由跳转 |
| 68 | connect(d->_routeBackButton, &ElaIconButton::clicked, this, &ElaAppBar::routeBackButtonClicked); |
| 69 | |
| 70 | d->_routeForwardButton = new ElaToolButton(this); |
| 71 | d->_routeForwardButton->setElaIcon(ElaIconType::ArrowRight); |
| 72 | d->_routeForwardButton->setFixedSize(35, 30); |
| 73 | d->_routeForwardButton->setEnabled(false); |
| 74 | connect(d->_routeForwardButton, &ElaToolButton::clicked, this, &ElaAppBar::routeForwardButtonClicked); |
| 75 | |
| 76 | // 导航栏展开按钮 |
| 77 | d->_navigationButton = new ElaToolButton(this); |
| 78 | d->_navigationButton->setElaIcon(ElaIconType::Bars); |
| 79 | d->_navigationButton->setFixedSize(40, 30); |
| 80 | d->_navigationButton->setObjectName("NavigationButton"); |
| 81 | d->_navigationButton->setVisible(false); |
| 82 | // 展开导航栏 |
| 83 | connect(d->_navigationButton, &ElaToolButton::clicked, this, &ElaAppBar::navigationButtonClicked); |
| 84 | |
| 85 | // 设置置顶 |
| 86 | d->_stayTopButton = new ElaToolButton(this); |
| 87 | d->_stayTopButton->setElaIcon(ElaIconType::Thumbtack, 45); |
| 88 | d->_stayTopButton->setFixedSize(40, 30); |
| 89 | connect(d->_stayTopButton, &ElaToolButton::clicked, this, [=]() { |
| 90 | this->setIsStayTop(!this->getIsStayTop()); |
nothing calls this directly
no test coverage detected