Ported input dialog
authorKevin Krammer <kevin.krammer@kdab.com>
Wed, 16 Jan 2013 14:40:04 +0000 (15:40 +0100)
committerKevin Krammer <kevin.krammer@kdab.com>
Wed, 16 Jan 2013 14:40:04 +0000 (15:40 +0100)
lib/declarativeinputdialog.cpp
lib/declarativeinputdialog_p.h
lib/declarativewidgetsdocument.cpp
lib/objectadaptors.cpp
lib/objectadaptors_p.h

index 244bd2f..90a785e 100644 (file)
@@ -275,14 +275,14 @@ void DeclarativeInputDialogAttached::setDialogAccepted(bool accepted)
   emit dialogAcceptedChanged(accepted);
 }
 
-DeclarativeInputDialog::DeclarativeInputDialog(QObject *parent) : DeclarativeWidgetProxy<InputDialog>(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)
index c03decd..b5851d8 100644 (file)
 #ifndef DECLARATIVEINPUTDIALOG_P_H
 #define DECLARATIVEINPUTDIALOG_P_H
 
-#include "declarativewidgetproxy_p.h"
-
-#include "objectadaptors_p.h"
 #include "staticdialogmethodattached_p.h"
 
+#include <qdeclarative.h>
+#include <QInputDialog>
+
 class DeclarativeInputDialogAttached : public StaticDialogMethodAttached
 {
   Q_OBJECT
@@ -116,14 +116,40 @@ class DeclarativeInputDialogAttached : public StaticDialogMethodAttached
     Private *const d;
 };
 
-class DeclarativeInputDialog : public DeclarativeWidgetProxy<InputDialog>
+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)
index 71b6f21..32cd02c 100644 (file)
@@ -120,8 +120,6 @@ DeclarativeWidgetsDocument::DeclarativeWidgetsDocument(const QUrl &url, QObject
   qmlRegisterType<DeclarativeDoubleSpinBox>("QtGui", 1, 0, "DoubleSpinBox");
   qmlRegisterType<DeclarativeFrame>("QtGui", 1, 0, "Frame");
   qmlRegisterType<DeclarativeGroupBox>("QtGui", 1, 0, "GroupBox");
-  qmlRegisterType<DeclarativeInputDialogAttached>();
-  qmlRegisterType<DeclarativeInputDialog>("QtGui", 1, 0, "InputDialog");
   qmlRegisterType<DeclarativeLabel>("QtGui", 1, 0, "Label");
   qmlRegisterType<DeclarativeLCDNumber>("QtGui", 1, 0, "LCDNumber");
   qmlRegisterType<DeclarativeListView>("QtGui", 1, 0, "ListView");
@@ -166,6 +164,7 @@ DeclarativeWidgetsDocument::DeclarativeWidgetsDocument(const QUrl &url, QObject
   qmlRegisterExtendedType<QDialogButtonBox, DeclarativeWidgetExtension>("QtGui", 1, 0, "DialogButtonBox");
   qmlRegisterExtendedType<DeclarativeFileDialog, DeclarativeWidgetExtension>("QtGui", 1, 0, "FileDialog");
   qmlRegisterExtendedType<DeclarativeFontDialog, DeclarativeWidgetExtension>("QtGui", 1, 0, "FontDialog");
+  qmlRegisterExtendedType<DeclarativeInputDialog, DeclarativeWidgetExtension>("QtGui", 1, 0, "InputDialog");
   qmlRegisterExtendedType<QLabel, DeclarativeWidgetExtension>("QtGui", 1, 0, "Label");
   qmlRegisterExtendedType<QLineEdit, DeclarativeWidgetExtension>("QtGui", 1, 0, "LineEdit");
   qmlRegisterExtendedType<QMainWindow, DeclarativeMainWindowExtension>("QtGui", 1, 0, "MainWindow");
index 132230c..18b2bb2 100644 (file)
@@ -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)
index 5f94cf3..e1f252c 100644 (file)
@@ -24,7 +24,7 @@
 #include <QColumnView>
 #include <QDeclarativeContext>
 #include <QDeclarativeView>
-#include <QInputDialog>
+#include <QDialog>
 #include <QMenu>
 #include <QListView>
 #include <QPointer>
@@ -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