1 /* 2 SPDX-License-Identifier: GPL-2.0-or-later 3 SPDX-FileCopyrightText: 2012-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org> 4 */ 5 6 #ifndef SINGLEPAGEDIALOGBASE_H 7 #define SINGLEPAGEDIALOGBASE_H 8 9 #include <QtGlobal> 10 11 #if QT_VERSION >= 0x050000 12 #include <QDialog> 13 class QAbstractButton; 14 class QDialogButtonBox; 15 #else 16 #include <KDialog> 17 #endif 18 19 /** 20 * Base class for single page property dialogs 21 * 22 * @author Ralf Habacker 23 * 24 * Bugs and comments to umbrello-devel@kde.org or https://bugs.kde.org 25 */ 26 #if QT_VERSION >= 0x050000 27 class SinglePageDialogBase : public QDialog 28 #else 29 class SinglePageDialogBase : public KDialog 30 #endif 31 { 32 Q_OBJECT 33 public: 34 explicit SinglePageDialogBase(QWidget *parent, bool withApplyButton = false, bool withSearchButton = false); 35 virtual ~SinglePageDialogBase(); 36 virtual bool apply(); 37 38 #if QT_VERSION >= 0x050000 39 typedef enum { Cancel = 0, Ok = 1, Apply = 2, No = 2 } ButtonCode; 40 // keep in sync with MultiPageDialogBase 41 void setCaption(const QString &caption); 42 43 QWidget *mainWidget(); 44 void setMainWidget(QWidget *widget); 45 void setButtonText(ButtonCode code, const QString &text); 46 #endif 47 48 protected slots: 49 void slotApply(); 50 void slotOk(); 51 #if QT_VERSION >= 0x050000 52 void slotCancel(); 53 void slotClicked(QAbstractButton*); 54 #endif 55 56 protected: 57 #if QT_VERSION >= 0x050000 58 QDialogButtonBox *m_buttonBox; 59 QWidget *m_mainWidget; 60 void enableButtonOk(bool enable); 61 #endif 62 virtual bool validate(); 63 }; 64 65 #endif 66