1 /******************************************************************************************************* 2 DkMessageBox.h 3 Created on: 28.03.2014 4 5 nomacs is a fast and small image viewer with the capability of synchronizing multiple instances 6 7 Copyright (C) 2011-2014 Markus Diem <markus@nomacs.org> 8 Copyright (C) 2011-2014 Stefan Fiel <stefan@nomacs.org> 9 Copyright (C) 2011-2014 Florian Kleber <florian@nomacs.org> 10 11 This file is part of nomacs. 12 13 nomacs is free software: you can redistribute it and/or modify 14 it under the terms of the GNU General Public License as published by 15 the Free Software Foundation, either version 3 of the License, or 16 (at your option) any later version. 17 18 nomacs is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program. If not, see <http://www.gnu.org/licenses/>. 25 26 *******************************************************************************************************/ 27 28 #pragma once 29 30 #pragma warning(push, 0) // no warnings from includes - begin 31 #include <QDialog> 32 #include <QMessageBox> 33 #pragma warning(pop) // no warnings from includes - end 34 35 #ifndef DllCoreExport 36 #ifdef DK_CORE_DLL_EXPORT 37 #define DllCoreExport Q_DECL_EXPORT 38 #elif DK_DLL_IMPORT 39 #define DllCoreExport Q_DECL_IMPORT 40 #else 41 #define DllCoreExport Q_DECL_IMPORT 42 #endif 43 #endif 44 45 // Qt defines 46 class QDialogButtonBox; 47 class QCheckBox; 48 49 namespace nmc { 50 51 class DllCoreExport DkMessageBox : public QDialog { 52 Q_OBJECT 53 54 public: 55 DkMessageBox(QMessageBox::Icon icon, 56 const QString& title, 57 const QString& text, 58 QMessageBox::StandardButtons buttons = QMessageBox::NoButton, 59 QWidget* parent = 0, 60 Qt::WindowFlags f = Qt::Dialog); 61 DkMessageBox(QWidget* parent = 0); 62 63 ~DkMessageBox(); 64 65 virtual void setVisible(bool visible) override; 66 void setDefaultButton(QMessageBox::StandardButton button); 67 void setButtonText(QMessageBox::StandardButton button, const QString &text); 68 69 public slots: 70 void buttonClicked(QAbstractButton* button); 71 int exec() override; 72 73 protected: 74 75 QLabel* iconLabel; 76 QLabel* textLabel; 77 QMessageBox::Icon icon; 78 QDialogButtonBox* buttonBox; 79 QCheckBox* showAgain; 80 81 void createLayout(const QMessageBox::Icon& userIcon, const QString& userText, QMessageBox::StandardButtons buttons); 82 void updateSize(); 83 }; 84 85 }