diff options
| author | Christoph Berg <myon@debian.org> | 2025-01-09 22:12:12 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2025-01-09 22:12:12 +0100 |
| commit | 98c02f78b26811ba5d9962ba27ec24cacf82bb22 (patch) | |
| tree | daaf609cde31d8fb3b6c3457c43663d14f0dda80 /widgets/MessageBox.cpp | |
| parent | 332d2ce88c2f0bc2908cacdc6707e2f9fa49f26d (diff) | |
| parent | 992d4b4b8d3f3a630a2cf00d593ee4ce4dfa7ce8 (diff) | |
Update upstream source from tag 'upstream/2.7.0_rc8+repack'
Update to upstream version '2.7.0~rc8+repack'
with Debian dir 6fce941c8282d35c8df23d3de779a42e27688bc1
Diffstat (limited to 'widgets/MessageBox.cpp')
| -rwxr-xr-x | widgets/MessageBox.cpp | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/widgets/MessageBox.cpp b/widgets/MessageBox.cpp index c6576708..7c6f0513 100755 --- a/widgets/MessageBox.cpp +++ b/widgets/MessageBox.cpp @@ -1,102 +1,102 @@ -#include "MessageBox.hpp"
-
-#include <QDialogButtonBox>
-#include <QPushButton>
-#include <QCoreApplication>
-
-#include "revision_utils.hpp"
-
-MessageBox::MessageBox (QWidget * parent)
- : QMessageBox {parent}
-{
- setWindowTitle (program_title ());
-}
-
-MessageBox::MessageBox (Icon icon, QString const& text, StandardButtons buttons
- , QWidget * parent, Qt::WindowFlags flags)
- : QMessageBox {icon, QCoreApplication::applicationName (), text, buttons, parent, flags}
-{
-}
-
-void MessageBox::about_message (QWidget * parent, QString const& text)
-{
- QMessageBox::about (parent, program_title (), text);
-}
-
-void MessageBox::about_Qt_message (QWidget * parent)
-{
- QMessageBox::aboutQt (parent, program_title ());
-}
-
-namespace
-{
- QMessageBox::StandardButton show_it (QWidget * parent, MessageBox::Icon icon
- , QString const& text
- , QString const& informative
- , QString const& detail
- , MessageBox::StandardButtons buttons
- , MessageBox::StandardButton default_button)
- {
- MessageBox mb {icon, text, MessageBox::NoButton, parent};
- QDialogButtonBox * button_box = mb.findChild<QDialogButtonBox *> ();
- Q_ASSERT (button_box);
-
- uint mask = MessageBox::FirstButton;
- while (mask <= MessageBox::LastButton) {
- uint sb = buttons & mask;
- mask <<= 1;
- if (!sb)
- continue;
- QPushButton * button = mb.addButton (static_cast<MessageBox::StandardButton> (sb));
- // Choose the first accept role as the default
- if (mb.defaultButton ())
- continue;
- if ((default_button == MessageBox::NoButton
- && button_box->buttonRole (button) == QDialogButtonBox::AcceptRole)
- || (default_button != MessageBox::NoButton
- && sb == static_cast<uint> (default_button)))
- mb.setDefaultButton (button);
- }
- mb.setInformativeText (informative);
- mb.setDetailedText (detail);
- if (mb.exec() == -1)
- return MessageBox::Cancel;
- return mb.standardButton (mb.clickedButton ());
- }
-}
-
-auto MessageBox::information_message (QWidget * parent, QString const& text
- , QString const& informative
- , QString const& detail
- , StandardButtons buttons
- , StandardButton default_button) -> StandardButton
-{
- return show_it (parent, Information, text, informative, detail, buttons, default_button);
-}
-
-auto MessageBox::query_message (QWidget * parent, QString const& text
- , QString const& informative
- , QString const& detail
- , StandardButtons buttons
- , StandardButton default_button) -> StandardButton
-{
- return show_it (parent, Question, text, informative, detail, buttons, default_button);
-}
-
-auto MessageBox::warning_message (QWidget * parent, QString const& text
- , QString const& informative
- , QString const& detail
- , StandardButtons buttons
- , StandardButton default_button) -> StandardButton
-{
- return show_it (parent, Warning, text, informative, detail, buttons, default_button);
-}
-
-auto MessageBox::critical_message (QWidget * parent, QString const& text
- , QString const& informative
- , QString const& detail
- , StandardButtons buttons
- , StandardButton default_button) -> StandardButton
-{
- return show_it (parent, Critical, text, informative, detail, buttons, default_button);
-}
+#include "MessageBox.hpp" + +#include <QDialogButtonBox> +#include <QPushButton> +#include <QCoreApplication> + +#include "revision_utils.hpp" + +MessageBox::MessageBox (QWidget * parent) + : QMessageBox {parent} +{ + setWindowTitle (program_title ()); +} + +MessageBox::MessageBox (Icon icon, QString const& text, StandardButtons buttons + , QWidget * parent, Qt::WindowFlags flags) + : QMessageBox {icon, QCoreApplication::applicationName (), text, buttons, parent, flags} +{ +} + +void MessageBox::about_message (QWidget * parent, QString const& text) +{ + QMessageBox::about (parent, program_title (), text); +} + +void MessageBox::about_Qt_message (QWidget * parent) +{ + QMessageBox::aboutQt (parent, program_title ()); +} + +namespace +{ + QMessageBox::StandardButton show_it (QWidget * parent, MessageBox::Icon icon + , QString const& text + , QString const& informative + , QString const& detail + , MessageBox::StandardButtons buttons + , MessageBox::StandardButton default_button) + { + MessageBox mb {icon, text, MessageBox::NoButton, parent}; + QDialogButtonBox * button_box = mb.findChild<QDialogButtonBox *> (); + Q_ASSERT (button_box); + + uint mask = MessageBox::FirstButton; + while (mask <= MessageBox::LastButton) { + uint sb = buttons & mask; + mask <<= 1; + if (!sb) + continue; + QPushButton * button = mb.addButton (static_cast<MessageBox::StandardButton> (sb)); + // Choose the first accept role as the default + if (mb.defaultButton ()) + continue; + if ((default_button == MessageBox::NoButton + && button_box->buttonRole (button) == QDialogButtonBox::AcceptRole) + || (default_button != MessageBox::NoButton + && sb == static_cast<uint> (default_button))) + mb.setDefaultButton (button); + } + mb.setInformativeText (informative); + mb.setDetailedText (detail); + if (mb.exec() == -1) + return MessageBox::Cancel; + return mb.standardButton (mb.clickedButton ()); + } +} + +auto MessageBox::information_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Information, text, informative, detail, buttons, default_button); +} + +auto MessageBox::query_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Question, text, informative, detail, buttons, default_button); +} + +auto MessageBox::warning_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Warning, text, informative, detail, buttons, default_button); +} + +auto MessageBox::critical_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Critical, text, informative, detail, buttons, default_button); +} |
