| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/gui/messagebox.cpp`/ |
| 2 | |
| 3 | #include "gui/messagebox.h"cxx . . $ `<file>/src/librssguard/gui/messagebox.h`/ |
| 4 | |
| 5 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 6 | #include "miscellaneous/iconfactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/iconfactory.h`/ |
| 7 | |
| 8 | #include <QCheckBox> |
| 9 | #include <QDialogButtonBox> |
| 10 | #include <QPushButton> |
| 11 | #include <QStyle> |
| 12 | #include <QtGlobal> |
| 13 | |
| 14 | MsgBoxcxx . . $ MsgBox#::MsgBoxcxx . . $ MsgBox#MsgBox(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) : QMessageBoxcxx . . $ QMessageBox#(parent) { |
| 15 | // setAttribute(Qt::WA_WindowPropagation, true); |
| 16 | } |
| 17 | |
| 18 | void MsgBoxcxx . . $ MsgBox#::setIconcxx . . $ MsgBox#setIcon(1f09eb2268fa2fc4).(QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon# icon) { |
| 19 | // Determine correct status icon size. |
| 20 | const int icon_size = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->stylecxx . . $ QApplication#style(8bb4f2215cbcf478).()->pixelMetriccxx . . $ QStyle#pixelMetric(83914974d8fbce56).(QStylecxx . . $ QStyle#::PixelMetriccxx . . $ QStyle#PixelMetric#::PM_MessageBoxIconSizecxx . . $ QStyle#PM_MessageBoxIconSize., nullptr, this); |
| 21 | |
| 22 | // Setup status icon. |
| 23 | setIconPixmapcxx . . $ QMessageBox#setIconPixmap(8887f7d25b86c3f4).(iconForStatuscxx . . $ MsgBox#iconForStatus(c9ff3e83110e7763).(icon).pixmapcxx . . $ QIcon#pixmap(6ca65e964a77a341).(icon_size, icon_size)); |
| 24 | } |
| 25 | |
| 26 | void MsgBoxcxx . . $ MsgBox#::setCheckBoxcxx . . $ MsgBox#setCheckBox(f38a1e3c7e93bae).(QMessageBoxcxx . . $ QMessageBox#* msg_box, const QStringcxx . . $ QString#& text, bool* data) { |
| 27 | // Add "don't show this again checkbox. |
| 28 | auto* check_box = new QCheckBoxcxx . . $ QCheckBox#QCheckBox(108f35f7aa7f3cf9).(msg_box); |
| 29 | |
| 30 | check_box->setCheckedcxx . . $ QAbstractButton#setChecked(b45ddcbc8423892c).(*data); |
| 31 | check_box->setTextcxx . . $ QAbstractButton#setText(3520e46b33348bf6).(text); |
| 32 | connectcxx . . $ QObject#connect(93770ac28d6bf547).(check_box, &QCheckBoxcxx . . $ QCheckBox#::toggledcxx . . $ QAbstractButton#toggled(b45ddcbc8423892c)., [=](bool checked) { |
| 33 | *data = checked; |
| 34 | }); |
| 35 | msg_box->setCheckBoxcxx . . $ QMessageBox#setCheckBox(9611d405b7895605).(check_box); |
| 36 | } |
| 37 | |
| 38 | QIconcxx . . $ QIcon# MsgBoxcxx . . $ MsgBox#::iconForStatuscxx . . $ MsgBox#iconForStatus(c9ff3e83110e7763).(QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon# status) { |
| 39 | switch (status) { |
| 40 | case QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon#::Informationcxx . . $ QMessageBox#Information.: |
| 41 | return qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dialog-information")); |
| 42 | |
| 43 | case QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon#::Warningcxx . . $ QMessageBox#Warning.: |
| 44 | return qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dialog-warning")); |
| 45 | |
| 46 | case QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon#::Criticalcxx . . $ QMessageBox#Critical.: |
| 47 | return qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dialog-error")); |
| 48 | |
| 49 | case QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon#::Questioncxx . . $ QMessageBox#Question.: |
| 50 | return qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dialog-question")); |
| 51 | |
| 52 | default: |
| 53 | return QIconcxx . . $ QIcon#QIcon(ced63f7c635d850d).(); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton# MsgBoxcxx . . $ MsgBox#::showcxx . . $ MsgBox#show(699e792c6fa2d501).(QWidgetcxx . . $ QWidget#* parent, |
| 58 | QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon# icon, |
| 59 | const QStringcxx . . $ QString#& title, |
| 60 | const QStringcxx . . $ QString#& text, |
| 61 | const QStringcxx . . $ QString#& informative_text, |
| 62 | const QStringcxx . . $ QString#& detailed_text, |
| 63 | QMessageBoxcxx . . $ QMessageBox#::StandardButtonscxx . . $ QMessageBox#StandardButtons# buttons, |
| 64 | QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton# default_button, |
| 65 | bool* dont_show_again, |
| 66 | const QStringcxx . . $ QString#& functor_heading, |
| 67 | const stdcxx . . $ std/::functioncxx . . $ std/function#<void()>& functor) { |
| 68 | if (parent == nullptr) { |
| 69 | parent = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->mainFormWidgetcxx . . $ Application#mainFormWidget(9b769eeb00a33a04).(); |
| 70 | } |
| 71 | |
| 72 | // Create and find needed components. |
| 73 | MsgBoxcxx . . $ MsgBox# msg_boxcxx . . $ MsgBox#MsgBox(108f35f7aa7f3cf9).(parent); |
| 74 | |
| 75 | // Initialize message box properties. |
| 76 | msg_box.setWindowTitlecxx . . $ QMessageBox#setWindowTitle(3520e46b33348bf6).(title); |
| 77 | msg_box.setTextcxx . . $ QMessageBox#setText(3520e46b33348bf6).(text); |
| 78 | msg_box.setInformativeTextcxx . . $ QMessageBox#setInformativeText(3520e46b33348bf6).(informative_text); |
| 79 | msg_box.setDetailedTextcxx . . $ QMessageBox#setDetailedText(3520e46b33348bf6).(detailed_text); |
| 80 | msg_box.setIconcxx . . $ MsgBox#setIcon(1f09eb2268fa2fc4).(icon); |
| 81 | msg_box.setStandardButtonscxx . . $ QMessageBox#setStandardButtons(4a518dc19368b384).(buttons); |
| 82 | msg_box.setDefaultButtoncxx . . $ QMessageBox#setDefaultButton(7bbe32d9411e0477).(default_button); |
| 83 | |
| 84 | if (dont_show_again != nullptr) { |
| 85 | MsgBoxcxx . . $ MsgBox#::setCheckBoxcxx . . $ MsgBox#setCheckBox(f38a1e3c7e93bae).(&msg_box, trcxx . . $ MsgBox#tr(75d9f1c324b4579d).("Do not show this dialog again."), dont_show_again); |
| 86 | } |
| 87 | |
| 88 | if (functor) { |
| 89 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(msg_box.addButtoncxx . . $ QMessageBox#addButton(24dcebdc5d97acf9).(functor_heading, QMessageBoxcxx . . $ QMessageBox#::ButtonRolecxx . . $ QMessageBox#ButtonRole#::HelpRolecxx . . $ QMessageBox#HelpRole.), |
| 90 | &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., |
| 91 | &msg_box, |
| 92 | functor); |
| 93 | } |
| 94 | |
| 95 | // Display it. |
| 96 | if (msg_box.execcxx . . $ QDialog#exec(b126dc7c1de90089).() == -1) { |
| 97 | return QMessageBoxcxx . . $ QMessageBox#::StandardButtoncxx . . $ QMessageBox#StandardButton#::Cancelcxx . . $ QMessageBox#Cancel.; |
| 98 | } |
| 99 | else { |
| 100 | return msg_box.standardButtoncxx . . $ QMessageBox#standardButton(7774bc375256c50e).(msg_box.clickedButtoncxx . . $ QMessageBox#clickedButton(b255616d4b016afb).()); |
| 101 | } |
| 102 | } |