| 17 | #include <QVBoxLayout> |
| 18 | Q_TAKEOVER_NATIVEEVENT_CPP(ElaContentDialog, d_func()->_appBar); |
| 19 | ElaContentDialog::ElaContentDialog(QWidget* parent) |
| 20 | : QDialog{parent}, d_ptr(new ElaContentDialogPrivate()) |
| 21 | { |
| 22 | Q_D(ElaContentDialog); |
| 23 | d->q_ptr = this; |
| 24 | |
| 25 | d->_maskWidget = new ElaMaskWidget(parent); |
| 26 | d->_maskWidget->move(0, 0); |
| 27 | d->_maskWidget->setFixedSize(parent->size()); |
| 28 | d->_maskWidget->setVisible(false); |
| 29 | |
| 30 | resize(400, height()); |
| 31 | setWindowModality(Qt::ApplicationModal); |
| 32 | |
| 33 | d->_appBar = new ElaAppBar(this); |
| 34 | d->_appBar->setWindowButtonFlags(ElaAppBarType::NoneButtonHint); |
| 35 | d->_appBar->setIsFixedSize(true); |
| 36 | d->_appBar->setAppBarHeight(0); |
| 37 | #ifdef Q_OS_WIN |
| 38 | // 防止意外拉伸 |
| 39 | createWinId(); |
| 40 | #endif |
| 41 | d->_leftButton = new ElaPushButton("cancel", this); |
| 42 | connect(d->_leftButton, &ElaPushButton::clicked, this, [=]() { |
| 43 | onLeftButtonClicked(); |
| 44 | d->_doCloseAnimation(false); |
| 45 | QTimer::singleShot(0, nullptr, [=]() { |
| 46 | Q_EMIT leftButtonClicked(); |
| 47 | }); |
| 48 | }); |
| 49 | d->_leftButton->setMinimumSize(0, 0); |
| 50 | d->_leftButton->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); |
| 51 | d->_leftButton->setFixedHeight(38); |
| 52 | d->_leftButton->setBorderRadius(6); |
| 53 | d->_middleButton = new ElaPushButton("minimum", this); |
| 54 | connect(d->_middleButton, &ElaPushButton::clicked, this, [=]() { |
| 55 | onMiddleButtonClicked(); |
| 56 | QTimer::singleShot(0, nullptr, [=]() { |
| 57 | Q_EMIT middleButtonClicked(); |
| 58 | }); |
| 59 | }); |
| 60 | d->_middleButton->setMinimumSize(0, 0); |
| 61 | d->_middleButton->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); |
| 62 | d->_middleButton->setFixedHeight(38); |
| 63 | d->_middleButton->setBorderRadius(6); |
| 64 | d->_rightButton = new ElaPushButton("exit", this); |
| 65 | connect(d->_rightButton, &ElaPushButton::clicked, this, [=]() { |
| 66 | onRightButtonClicked(); |
| 67 | d->_doCloseAnimation(true); |
| 68 | QTimer::singleShot(0, nullptr, [=]() { |
| 69 | Q_EMIT rightButtonClicked(); |
| 70 | }); |
| 71 | }); |
| 72 | d->_rightButton->setLightDefaultColor(ElaThemeColor(ElaThemeType::Light, PrimaryNormal)); |
| 73 | d->_rightButton->setLightHoverColor(ElaThemeColor(ElaThemeType::Light, PrimaryHover)); |
| 74 | d->_rightButton->setLightPressColor(ElaThemeColor(ElaThemeType::Light, PrimaryPress)); |
| 75 | d->_rightButton->setLightTextColor(Qt::white); |
| 76 | d->_rightButton->setDarkDefaultColor(ElaThemeColor(ElaThemeType::Dark, PrimaryNormal)); |
nothing calls this directly
no test coverage detected