From 29b2506e8cf0c792821a3ddb28e62080cd66ae28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Fri, 21 Apr 2023 15:13:19 +0200 Subject: Allow disable native messagebox dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The native style may not match the program style and it makes sense to give an option rather than forcing native style. Before it could only be done with setting AA_DontUseNativeDialogs on the app, but it is reasonable to use native file dialogs and Qt styled messageboxes - and it is extremely cumbersome - especially since messageboxes often can start save dialogs. It can look a bit strange that these introduced options has just one option (DontUseNativeDialog) and four functions, but this way it works similar to QColorDialog, QFileDialog and QFontDialog. [ChangeLog][QWidgets][QMessageBox] Added options functionality to QMessagebox. The currently only option available is DontUseNativeDialog. Change-Id: I70282fcfaa66f245f7e679b8897c607bcaff333f Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø Reviewed-by: Volker Hilsheimer --- src/gui/kernel/qplatformdialoghelper.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gui/kernel/qplatformdialoghelper.h') diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h index 25543a70b8..fabc4985a3 100644 --- a/src/gui/kernel/qplatformdialoghelper.h +++ b/src/gui/kernel/qplatformdialoghelper.h @@ -403,6 +403,11 @@ protected: ~QMessageDialogOptions(); public: + // Keep in sync with QMessageBox Option + enum class Option : quint8 { DontUseNativeDialog = 0x00000001 }; + Q_DECLARE_FLAGS(Options, Option); + Q_FLAG(Options); + // Keep in sync with QMessageBox::Icon enum StandardIcon { NoIcon, Information, Warning, Critical, Question }; Q_ENUM(StandardIcon) @@ -428,6 +433,11 @@ public: void setDetailedText(const QString &text); QString detailedText() const; + void setOption(Option option, bool on = true); + bool testOption(Option option) const; + void setOptions(Options options); + Options options() const; + void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons); QPlatformDialogHelper::StandardButtons standardButtons() const; -- cgit v1.2.3