Add a couple of dialogs
authorTobias Koenig <tobias.koenig@kdab.com>
Fri, 19 Oct 2012 17:43:43 +0000 (19:43 +0200)
committerTobias Koenig <tobias.koenig@kdab.com>
Fri, 19 Oct 2012 17:43:43 +0000 (19:43 +0200)
declarativeobjects.cpp
declarativeobjects_p.h
declarativewidgetdocument.cpp
declarativewidgets.pro
dialogs.qml [new file with mode: 0644]
objectadaptors.cpp
objectadaptors_p.h

index b368896..ca53f6e 100644 (file)
@@ -638,6 +638,14 @@ DeclarativeCheckBox::DeclarativeCheckBox(QObject *parent) : DeclarativeWidgetPro
 
 CUSTOM_METAOBJECT(DeclarativeCheckBox, QCheckBox)
 
+// DeclarativeColorDialog
+DeclarativeColorDialog::DeclarativeColorDialog(QObject *parent) : DeclarativeWidgetProxy<QColorDialog>(parent)
+{
+  connectAllSignals(m_proxiedObject, this);
+}
+
+CUSTOM_METAOBJECT(DeclarativeColorDialog, QColorDialog)
+
 // DeclarativeDialog
 DeclarativeDialog::DeclarativeDialog(QObject *parent) : DeclarativeWidgetProxy<QDialog>(parent)
 {
@@ -654,6 +662,30 @@ DeclarativeDialogButtonBox::DeclarativeDialogButtonBox(QObject *parent) : Declar
 
 CUSTOM_METAOBJECT(DeclarativeDialogButtonBox, QDialogButtonBox)
 
+// DeclarativeFileDialog
+DeclarativeFileDialog::DeclarativeFileDialog(QObject *parent) : DeclarativeWidgetProxy<FileDialog>(parent)
+{
+  connectAllSignals(m_proxiedObject, this);
+}
+
+CUSTOM_METAOBJECT(DeclarativeFileDialog, FileDialog)
+
+// DeclarativeFontDialog
+DeclarativeFontDialog::DeclarativeFontDialog(QObject *parent) : DeclarativeWidgetProxy<QFontDialog>(parent)
+{
+  connectAllSignals(m_proxiedObject, this);
+}
+
+CUSTOM_METAOBJECT(DeclarativeFontDialog, QFontDialog)
+
+// DeclarativeInputDialog
+DeclarativeInputDialog::DeclarativeInputDialog(QObject *parent) : DeclarativeWidgetProxy<InputDialog>(parent)
+{
+  connectAllSignals(m_proxiedObject, this);
+}
+
+CUSTOM_METAOBJECT(DeclarativeInputDialog, InputDialog)
+
 // DeclarativeLabel
 DeclarativeLabel::DeclarativeLabel(QObject *parent) : DeclarativeWidgetProxy<QLabel>(parent)
 {
index 8d0b86e..4243f0c 100644 (file)
@@ -8,8 +8,10 @@
 #include <QtGui/QAction>
 #include <QtGui/QCalendarWidget>
 #include <QtGui/QCheckBox>
+#include <QtGui/QColorDialog>
 #include <QtGui/QDialog>
 #include <QtGui/QDialogButtonBox>
+#include <QtGui/QFontDialog>
 #include <QtGui/QFormLayout>
 #include <QtGui/QHBoxLayout>
 #include <QtGui/QLabel>
@@ -395,6 +397,14 @@ class DeclarativeCheckBox : public DeclarativeWidgetProxy<QCheckBox>
     DeclarativeCheckBox(QObject *parent = 0);
 };
 
+class DeclarativeColorDialog : public DeclarativeWidgetProxy<QColorDialog>
+{
+  DECLARATIVE_OBJECT
+
+  public:
+    DeclarativeColorDialog(QObject *parent = 0);
+};
+
 class DeclarativeDialog : public DeclarativeWidgetProxy<QDialog>
 {
   DECLARATIVE_OBJECT
@@ -411,6 +421,30 @@ class DeclarativeDialogButtonBox : public DeclarativeWidgetProxy<QDialogButtonBo
     DeclarativeDialogButtonBox(QObject *parent = 0);
 };
 
+class DeclarativeFileDialog : public DeclarativeWidgetProxy<FileDialog>
+{
+  DECLARATIVE_OBJECT
+
+  public:
+    DeclarativeFileDialog(QObject *parent = 0);
+};
+
+class DeclarativeFontDialog : public DeclarativeWidgetProxy<QFontDialog>
+{
+  DECLARATIVE_OBJECT
+
+  public:
+    DeclarativeFontDialog(QObject *parent = 0);
+};
+
+class DeclarativeInputDialog : public DeclarativeWidgetProxy<InputDialog>
+{
+  DECLARATIVE_OBJECT
+
+  public:
+    DeclarativeInputDialog(QObject *parent = 0);
+};
+
 class DeclarativeLabel : public DeclarativeWidgetProxy<QLabel>
 {
   DECLARATIVE_OBJECT
index 6607a4a..93f0b03 100644 (file)
@@ -46,8 +46,12 @@ DeclarativeWidgetDocument::DeclarativeWidgetDocument(const QUrl &url, QObject *p
   // widgets
   qmlRegisterType<DeclarativeCalendarWidget>("QtGui", 1, 0, "CalendarWidget");
   qmlRegisterType<DeclarativeCheckBox>("QtGui", 1, 0, "CheckBox");
+  qmlRegisterType<DeclarativeColorDialog>("QtGui", 1, 0, "ColorDialog");
   qmlRegisterType<DeclarativeDialog>("QtGui", 1, 0, "Dialog");
   qmlRegisterType<DeclarativeDialogButtonBox>("QtGui", 1, 0, "DialogButtonBox");
+  qmlRegisterType<DeclarativeFileDialog>("QtGui", 1, 0, "FileDialog");
+  qmlRegisterType<DeclarativeFontDialog>("QtGui", 1, 0, "FontDialog");
+  qmlRegisterType<DeclarativeInputDialog>("QtGui", 1, 0, "InputDialog");
   qmlRegisterType<DeclarativeLabel>("QtGui", 1, 0, "Label");
   qmlRegisterType<DeclarativeMainWindow>("QtGui", 1, 0, "MainWindow");
   qmlRegisterType<DeclarativeMenu>("QtGui", 1, 0, "Menu");
index 4d13136..95c13ac 100644 (file)
@@ -24,8 +24,9 @@ SOURCES += \
 QT += declarative
 
 OTHER_FILES += \
-    layouts.qml \
     animation.qml \
+    dialogs.qml \
     editor.qml \
     gallery.qml \
+    layouts.qml \
     test.qml
diff --git a/dialogs.qml b/dialogs.qml
new file mode 100644 (file)
index 0000000..a87cf4c
--- /dev/null
@@ -0,0 +1,58 @@
+import QtGui 1.0
+
+Widget {
+  ColorDialog {
+    id: colorDialog
+  }
+
+  FileDialog {
+    id: fileDialog
+
+    fileMode: FileDialog.ExistingFile
+    viewMode: FileDialog.List
+  }
+
+  FontDialog {
+    id: fontDialog
+  }
+
+  InputDialog {
+    id: intInputDialog
+
+    labelText: qsTr("Percentage")
+  }
+
+  VBoxLayout {
+    PushButton {
+      text: qsTr("Color Dialog...")
+      onClicked: {
+        if (colorDialog.exec())
+          console.log("Selected color: " + colorDialog.currentColor)
+      }
+    }
+
+    PushButton {
+      text: qsTr("File Dialog...")
+      onClicked: {
+        if (fileDialog.exec())
+          console.log("Selected files: " + fileDialog.selectedFiles)
+      }
+    }
+
+    PushButton {
+      text: qsTr("Font Dialog...")
+      onClicked: {
+        if (fontDialog.exec())
+          console.log("Selected font: " + fontDialog.currentFont)
+      }
+    }
+
+    PushButton {
+      text: qsTr("Input Dialog (Int)...")
+      onClicked: {
+        if (intInputDialog.exec())
+          console.log(intInputDialog.intValue + "%")
+      }
+    }
+  }
+}
index ca7bc0c..d3f44b6 100644 (file)
@@ -1,5 +1,18 @@
 #include "objectadaptors_p.h"
 
+FileDialog::FileDialog(QWidget *parent)
+  : QFileDialog(parent)
+{
+}
+
+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()));
+}
+
 TextEdit::TextEdit(QWidget *parent)
   : QTextEdit(parent)
 {
index c485ce8..11e22f7 100644 (file)
@@ -1,8 +1,54 @@
 #ifndef OBJECTADAPTORS_P_H
 #define OBJECTADAPTORS_P_H
 
+#include <QtGui/QFileDialog>
+#include <QtGui/QInputDialog>
 #include <QtGui/QTextEdit>
 
+class FileDialog : public QFileDialog
+{
+  Q_OBJECT
+
+  Q_PROPERTY(QStringList selectedFiles READ selectedFiles)
+
+  public:
+    FileDialog(QWidget *parent = 0);
+};
+
+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:
+    InputDialog(QWidget *parent = 0);
+
+  Q_SIGNALS:
+    void customTextValueChanged();
+    void customIntValueChanged();
+    void customDoubleValueChanged();
+};
+
 class TextEdit : public QTextEdit
 {
   Q_OBJECT