From: Kevin Krammer Date: Wed, 16 Jan 2013 14:40:04 +0000 (+0100) Subject: Ported input dialog X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=819666c7de8adc5cf2e5881cb91f99d922693c4f;p=web%2Fkonrad%2FDeclarativeWidgets.git Ported input dialog --- diff --git a/lib/declarativeinputdialog.cpp b/lib/declarativeinputdialog.cpp index 244bd2f..90a785e 100644 --- a/lib/declarativeinputdialog.cpp +++ b/lib/declarativeinputdialog.cpp @@ -275,14 +275,14 @@ void DeclarativeInputDialogAttached::setDialogAccepted(bool accepted) emit dialogAcceptedChanged(accepted); } -DeclarativeInputDialog::DeclarativeInputDialog(QObject *parent) : DeclarativeWidgetProxy(parent) +DeclarativeInputDialog::DeclarativeInputDialog(QWidget *parent) : QInputDialog(parent) { - connectAllSignals(m_proxiedObject, this); + connect(this, SIGNAL(textValueChanged(QString)), this, SIGNAL(customTextValueChanged())); + connect(this, SIGNAL(intValueChanged(int)), this, SIGNAL(customIntValueChanged())); + connect(this, SIGNAL(doubleValueChanged(double)), this, SIGNAL(customDoubleValueChanged())); } DeclarativeInputDialogAttached *DeclarativeInputDialog::qmlAttachedProperties(QObject *parent) { return new DeclarativeInputDialogAttached(parent); } - -CUSTOM_METAOBJECT(DeclarativeInputDialog, InputDialog) diff --git a/lib/declarativeinputdialog_p.h b/lib/declarativeinputdialog_p.h index c03decd..b5851d8 100644 --- a/lib/declarativeinputdialog_p.h +++ b/lib/declarativeinputdialog_p.h @@ -21,11 +21,11 @@ #ifndef DECLARATIVEINPUTDIALOG_P_H #define DECLARATIVEINPUTDIALOG_P_H -#include "declarativewidgetproxy_p.h" - -#include "objectadaptors_p.h" #include "staticdialogmethodattached_p.h" +#include +#include + class DeclarativeInputDialogAttached : public StaticDialogMethodAttached { Q_OBJECT @@ -116,14 +116,40 @@ class DeclarativeInputDialogAttached : public StaticDialogMethodAttached Private *const d; }; -class DeclarativeInputDialog : public DeclarativeWidgetProxy +class DeclarativeInputDialog : public QInputDialog { - DECLARATIVE_OBJECT + Q_OBJECT + + Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode) + Q_PROPERTY(QString labelText READ labelText WRITE setLabelText) + Q_PROPERTY(InputDialogOptions options READ options WRITE setOptions) + Q_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY customTextValueChanged) + Q_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY customIntValueChanged) + Q_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY customDoubleValueChanged) + Q_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode) + Q_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable) + Q_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems) + Q_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum) + Q_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum) + Q_PROPERTY(int intStep READ intStep WRITE setIntStep) + Q_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum) + Q_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum) + Q_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals) + Q_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText) + Q_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText) + + Q_ENUMS(InputMode) + Q_ENUMS(InputDialogOption) public: - explicit DeclarativeInputDialog(QObject *parent = 0); + explicit DeclarativeInputDialog(QWidget *parent = 0); static DeclarativeInputDialogAttached *qmlAttachedProperties(QObject *parent); + + Q_SIGNALS: + void customTextValueChanged(); + void customIntValueChanged(); + void customDoubleValueChanged(); }; QML_DECLARE_TYPEINFO(DeclarativeInputDialog, QML_HAS_ATTACHED_PROPERTIES) diff --git a/lib/declarativewidgetsdocument.cpp b/lib/declarativewidgetsdocument.cpp index 71b6f21..32cd02c 100644 --- a/lib/declarativewidgetsdocument.cpp +++ b/lib/declarativewidgetsdocument.cpp @@ -120,8 +120,6 @@ DeclarativeWidgetsDocument::DeclarativeWidgetsDocument(const QUrl &url, QObject qmlRegisterType("QtGui", 1, 0, "DoubleSpinBox"); qmlRegisterType("QtGui", 1, 0, "Frame"); qmlRegisterType("QtGui", 1, 0, "GroupBox"); - qmlRegisterType(); - qmlRegisterType("QtGui", 1, 0, "InputDialog"); qmlRegisterType("QtGui", 1, 0, "Label"); qmlRegisterType("QtGui", 1, 0, "LCDNumber"); qmlRegisterType("QtGui", 1, 0, "ListView"); @@ -166,6 +164,7 @@ DeclarativeWidgetsDocument::DeclarativeWidgetsDocument(const QUrl &url, QObject qmlRegisterExtendedType("QtGui", 1, 0, "DialogButtonBox"); qmlRegisterExtendedType("QtGui", 1, 0, "FileDialog"); qmlRegisterExtendedType("QtGui", 1, 0, "FontDialog"); + qmlRegisterExtendedType("QtGui", 1, 0, "InputDialog"); qmlRegisterExtendedType("QtGui", 1, 0, "Label"); qmlRegisterExtendedType("QtGui", 1, 0, "LineEdit"); qmlRegisterExtendedType("QtGui", 1, 0, "MainWindow"); diff --git a/lib/objectadaptors.cpp b/lib/objectadaptors.cpp index 132230c..18b2bb2 100644 --- a/lib/objectadaptors.cpp +++ b/lib/objectadaptors.cpp @@ -217,15 +217,6 @@ QObject *DeclarativeView::declarativeRootContext() const return m_rootContext; } -// InputDialog -InputDialog::InputDialog(QWidget *parent) - : QInputDialog(parent) -{ - connect(this, SIGNAL(textValueChanged(QString)), this, SIGNAL(customTextValueChanged())); - connect(this, SIGNAL(intValueChanged(int)), this, SIGNAL(customIntValueChanged())); - connect(this, SIGNAL(doubleValueChanged(double)), this, SIGNAL(customDoubleValueChanged())); -} - // ListView ListView::ListView(QWidget *parent) : QListView(parent) diff --git a/lib/objectadaptors_p.h b/lib/objectadaptors_p.h index 5f94cf3..e1f252c 100644 --- a/lib/objectadaptors_p.h +++ b/lib/objectadaptors_p.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -144,40 +144,6 @@ public: Q_DECLARE_METATYPE(Qt::WindowFlags) -class InputDialog : public QInputDialog -{ - Q_OBJECT - - Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode) - Q_PROPERTY(QString labelText READ labelText WRITE setLabelText) - Q_PROPERTY(InputDialogOptions options READ options WRITE setOptions) - Q_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY customTextValueChanged) - Q_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY customIntValueChanged) - Q_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY customDoubleValueChanged) - Q_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode) - Q_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable) - Q_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems) - Q_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum) - Q_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum) - Q_PROPERTY(int intStep READ intStep WRITE setIntStep) - Q_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum) - Q_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum) - Q_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals) - Q_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText) - Q_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText) - - Q_ENUMS(InputMode) - Q_ENUMS(InputDialogOption) - - public: - explicit InputDialog(QWidget *parent = 0); - - Q_SIGNALS: - void customTextValueChanged(); - void customIntValueChanged(); - void customDoubleValueChanged(); -}; - class Menu : public QMenu { Q_OBJECT