diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp index db3d662d0..120cbd395 100644 --- a/src/gui/messagebox.cpp +++ b/src/gui/messagebox.cpp @@ -9,7 +9,20 @@ #include #include -MessageBox::MessageBox() { +MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) { +} + +MessageBox::~MessageBox() { +} + +void MessageBox::setIcon(QMessageBox::Icon icon) { + // Determine correct status icon size. + int icon_size = qApp->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, + 0, + this); + // Setup status icon. + setIconPixmap(iconForStatus(icon).pixmap(icon_size, + icon_size)); } void MessageBox::iconify(QDialogButtonBox *button_box) { @@ -63,21 +76,19 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { // Create and find needed components. - QMessageBox msg_box(parent); + MessageBox msg_box(parent); QDialogButtonBox *button_box = msg_box.findChild(); // Initialize message box properties. msg_box.setWindowTitle(title); msg_box.setText(text); + msg_box.setIcon(icon); msg_box.setStandardButtons(buttons); msg_box.setDefaultButton(defaultButton); iconify(button_box); - // Setup status icon. - int icon_size = qApp->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, &msg_box); - msg_box.setIconPixmap(iconForStatus(icon).pixmap(icon_size, - icon_size)); + // Display it. if (msg_box.exec() == -1) { diff --git a/src/gui/messagebox.h b/src/gui/messagebox.h index 28c73f66b..706283e1a 100644 --- a/src/gui/messagebox.h +++ b/src/gui/messagebox.h @@ -5,12 +5,16 @@ #include -class MessageBox { - private: - // Constructors and destructors. - explicit MessageBox(); +class MessageBox : public QMessageBox { + Q_OBJECT public: + // Constructors and destructors. + explicit MessageBox(QWidget *parent = 0); + virtual ~MessageBox(); + + void setIcon(Icon icon); + // TODO: tudle metodu udelat private a udelat public // metody information, warning atd a ty budou tudle volat // se spravnejma parametrama