| 11 | #include <QVBoxLayout> |
| 12 | Q_TAKEOVER_NATIVEEVENT_CPP(ElaDialog, d_func()->_appBar); |
| 13 | ElaDialog::ElaDialog(QWidget* parent) |
| 14 | : QDialog{parent}, d_ptr(new ElaDialogPrivate()) |
| 15 | { |
| 16 | Q_D(ElaDialog); |
| 17 | d->q_ptr = this; |
| 18 | resize(500, 500); // 默认宽高 |
| 19 | setWindowTitle("ElaDialog"); |
| 20 | setObjectName("ElaDialog"); |
| 21 | #ifndef Q_OS_WIN |
| 22 | setAttribute(Qt::WA_Hover); |
| 23 | #endif |
| 24 | #if (QT_VERSION < QT_VERSION_CHECK(6, 5, 3) || QT_VERSION > QT_VERSION_CHECK(6, 6, 1)) |
| 25 | setStyleSheet("#ElaDialog{background-color:transparent;}"); |
| 26 | #endif |
| 27 | // 自定义AppBar |
| 28 | d->_appBar = new ElaAppBar(this); |
| 29 | d->_appBar->setIsStayTop(true); |
| 30 | d->_appBar->setWindowButtonFlags(ElaAppBarType::StayTopButtonHint | ElaAppBarType::MinimizeButtonHint | ElaAppBarType::MaximizeButtonHint | ElaAppBarType::CloseButtonHint); |
| 31 | connect(d->_appBar, &ElaAppBar::routeBackButtonClicked, this, &ElaDialog::routeBackButtonClicked); |
| 32 | connect(d->_appBar, &ElaAppBar::navigationButtonClicked, this, &ElaDialog::navigationButtonClicked); |
| 33 | connect(d->_appBar, &ElaAppBar::themeChangeButtonClicked, this, &ElaDialog::themeChangeButtonClicked); |
| 34 | connect(d->_appBar, &ElaAppBar::closeButtonClicked, this, &ElaDialog::closeButtonClicked); |
| 35 | |
| 36 | // 主题 |
| 37 | d->_themeMode = eTheme->getThemeMode(); |
| 38 | connect(eTheme, &ElaTheme::themeModeChanged, this, [=](ElaThemeType::ThemeMode themeMode) { |
| 39 | d->_themeMode = themeMode; |
| 40 | update(); |
| 41 | }); |
| 42 | |
| 43 | d->_windowDisplayMode = eApp->getWindowDisplayMode(); |
| 44 | connect(eApp, &ElaApplication::pWindowDisplayModeChanged, this, [=]() { |
| 45 | d->_windowDisplayMode = eApp->getWindowDisplayMode(); |
| 46 | update(); |
| 47 | }); |
| 48 | eApp->syncWindowDisplayMode(this); |
| 49 | } |
| 50 | |
| 51 | ElaDialog::~ElaDialog() |
| 52 | { |
nothing calls this directly
no test coverage detected