| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef GUI_DIALOG_DLGINPUTDIALOGIMP_H |
| 25 |
#define GUI_DIALOG_DLGINPUTDIALOGIMP_H |
| 26 |
|
| 27 |
#include <memory> |
| 28 |
#include <QDialog> |
| 29 |
#include <FCGlobal.h> |
| 30 |
|
| 31 |
class QSpinBox; |
| 32 |
class QDoubleSpinBox; |
| 33 |
class QLineEdit; |
| 34 |
class QComboBox; |
| 35 |
|
| 36 |
namespace Gui |
| 37 |
{ |
| 38 |
class UIntSpinBox; |
| 39 |
|
| 40 |
namespace Dialog |
| 41 |
{ |
| 42 |
class Ui_DlgInputDialog; |
| 43 |
|
| 44 |
/** |
| 45 |
* The DlgInputDialogImp dialog class does basically the same as Qt's QInputDialog |
| 46 |
* unless that it provides no static function but the application programmer must |
| 47 |
* create an instance and prepare it. This requires a little more work but increases |
| 48 |
* the flexibility. |
| 49 |
* \author Werner Mayer |
| 50 |
*/ |
| 51 |
class GuiExport DlgInputDialogImp: public QDialog |
| 52 |
{ |
| 53 |
Q_OBJECT |
| 54 |
|
| 55 |
public: |
| 56 |
enum Type |
| 57 |
{ |
| 58 |
LineEdit, |
| 59 |
SpinBox, |
| 60 |
UIntBox, |
| 61 |
FloatSpinBox, |
| 62 |
ComboBox |
| 63 |
}; |
| 64 |
|
| 65 |
DlgInputDialogImp(const QString& label, QWidget* parent = nullptr, bool modal = true, Type = LineEdit); |
| 66 |
~DlgInputDialogImp() override; |
| 67 |
|
| 68 |
void setType(Type t); |
| 69 |
Type type() const; |
| 70 |
|
| 71 |
QSpinBox* getSpinBox() const; |
| 72 |
Gui::UIntSpinBox* getUIntBox() const; |
| 73 |
QDoubleSpinBox* getFloatSpinBox() const; |
| 74 |
QLineEdit* getLineEdit() const; |
| 75 |
QComboBox* getComboBox() const; |
| 76 |
|
| 77 |
protected Q_SLOTS: |
| 78 |
void textChanged(const QString& s); |
| 79 |
void tryAccept(); |
| 80 |
|
| 81 |
protected: |
| 82 |
Type inputtype; |
| 83 |
|
| 84 |
private: |
| 85 |
std::unique_ptr<Ui_DlgInputDialog> ui; |
| 86 |
}; |
| 87 |
|
| 88 |
} // namespace Dialog |
| 89 |
} // namespace Gui |
| 90 |
|
| 91 |
#endif // GUI_DIALOG_DLGINPUTDIALOGIMP_H |