summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qerrormessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs/qerrormessage.cpp')
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 2c36e535c7..2b5681f79b 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -28,17 +28,15 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-namespace {
-struct Message {
- QString content;
- QString type;
-};
-}
-
class QErrorMessagePrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QErrorMessage)
public:
+ struct Message {
+ QString content;
+ QString type;
+ };
+
QPushButton * ok;
QCheckBox * again;
QTextEdit * errors;
@@ -53,6 +51,8 @@ public:
bool nextPending();
void retranslateStrings();
+ void setVisible(bool) override;
+
private:
void initHelper(QPlatformDialogHelper *) override;
void helperPrepareShow(QPlatformDialogHelper *) override;
@@ -63,9 +63,9 @@ void QErrorMessagePrivate::initHelper(QPlatformDialogHelper *helper)
{
Q_Q(QErrorMessage);
auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(helper);
- QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::supressionCheckBoxChanged, q,
- [this](bool supressionChecked) {
- again->setChecked(!supressionChecked);
+ QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::checkBoxStateChanged, q,
+ [this](Qt::CheckState state) {
+ again->setCheckState(state);
}
);
QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::clicked, q,
@@ -85,8 +85,8 @@ void QErrorMessagePrivate::helperPrepareShow(QPlatformDialogHelper *helper)
options->setWindowTitle(q->windowTitle());
options->setText(QErrorMessage::tr("An error occurred"));
options->setInformativeText(currentMessage);
- options->setIcon(QMessageDialogOptions::Critical);
- options->setSupressionCheckBoxEnabled(true);
+ options->setStandardIcon(QMessageDialogOptions::Critical);
+ options->setCheckBox(again->text(), again->checkState());
messageDialogHelper->setOptions(options);
}
@@ -257,7 +257,9 @@ QErrorMessage::QErrorMessage(QWidget * parent)
grid->setRowStretch(0, 42);
#if QT_CONFIG(messagebox)
- d->icon->setPixmap(style()->standardPixmap(QStyle::SP_MessageBoxInformation));
+ const auto iconSize = style()->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, this);
+ const auto icon = style()->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, this);
+ d->icon->setPixmap(icon.pixmap(QSize(iconSize, iconSize), devicePixelRatio()));
d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
#endif
d->again->setChecked(true);
@@ -358,6 +360,7 @@ bool QErrorMessagePrivate::nextPending()
#endif
currentMessage = std::move(message);
currentType = std::move(type);
+ again->setChecked(true);
return true;
}
}
@@ -403,21 +406,19 @@ void QErrorMessage::showMessage(const QString &message, const QString &type)
show();
}
-void QErrorMessage::setVisible(bool visible)
+void QErrorMessagePrivate::setVisible(bool visible)
{
- if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible)
- return;
+ Q_Q(QErrorMessage);
- Q_D(QErrorMessage);
- if (d->canBeNativeDialog())
- d->setNativeDialogVisible(visible);
+ if (canBeNativeDialog())
+ setNativeDialogVisible(visible);
// Update WA_DontShowOnScreen based on whether the native dialog was shown,
// so that QDialog::setVisible(visible) below updates the QWidget state correctly,
// but skips showing the non-native version.
- setAttribute(Qt::WA_DontShowOnScreen, d->nativeDialogInUse);
+ q->setAttribute(Qt::WA_DontShowOnScreen, nativeDialogInUse);
- QDialog::setVisible(visible);
+ QDialogPrivate::setVisible(visible);
}
/*!