CUSTOM_METAOBJECT(DeclarativeCheckBox, QCheckBox)
// DeclarativeColorDialog
-DeclarativeColorDialogAttached::DeclarativeColorDialogAttached(QObject *parent) : QObject(parent)
+class DeclarativeColorDialogAttached::Private
{
+ public:
+ Private() : options(0) {}
+
+ public:
+ QPointer<QObject> dialogParent;
+ QString title;
+ QColorDialog::ColorDialogOptions options;
+};
+
+DeclarativeColorDialogAttached::DeclarativeColorDialogAttached(QObject *parent)
+ : QObject(parent), d(new Private)
+{
+}
+
+DeclarativeColorDialogAttached::~DeclarativeColorDialogAttached()
+{
+ delete d;
+}
+
+void DeclarativeColorDialogAttached::setDialogParent(QObject *parent)
+{
+ if (parent == d->dialogParent)
+ return;
+
+ d->dialogParent = parent;
+ emit dialogParentChanged(parent);
}
-QColor DeclarativeColorDialogAttached::getColor(const QColor &initialColor, QObject *parent, const QString &title, int options)
+QObject *DeclarativeColorDialogAttached::dialogParent() const
{
- return QColorDialog::getColor(initialColor, bestParentWindow(parent), title, static_cast<QColorDialog::ColorDialogOptions>(options));
+ return d->dialogParent;
}
-QColor DeclarativeColorDialogAttached::getColor(const QColor &initialColor, QObject *parent)
+void DeclarativeColorDialogAttached::setTitle(const QString &title)
{
- return QColorDialog::getColor(initialColor, bestParentWindow(parent));
+ if (title == d->title)
+ return;
+
+ d->title = title;
+ emit titleChanged(title);
+}
+
+QString DeclarativeColorDialogAttached::title() const
+{
+ return d->title;
+}
+
+QColor DeclarativeColorDialogAttached::getColor(const QColor &initialColor)
+{
+ QWidget *parent = bestParentWindow(d->dialogParent);
+ if (!d->title.isEmpty() || d->options != 0)
+ return QColorDialog::getColor(initialColor, parent, d->title, d->options);
+ else
+ return QColorDialog::getColor(initialColor, parent);
}
QWidget *DeclarativeColorDialogAttached::bestParentWindow(QObject *parent) const
class DeclarativeColorDialogAttached : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged)
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
+ // TODO option
public:
DeclarativeColorDialogAttached(QObject *parent = 0);
+ ~DeclarativeColorDialogAttached();
+
+ void setDialogParent(QObject *parent);
+ QObject *dialogParent() const;
+
+ void setTitle(const QString &title);
+ QString title() const;
- Q_INVOKABLE QColor getColor(const QColor &initialColor, QObject *parent, const QString &title, int options = 0);
- Q_INVOKABLE QColor getColor(const QColor &initialColor, QObject *parent = 0);
+ Q_INVOKABLE QColor getColor(const QColor &initialColor);
+
+ Q_SIGNALS:
+ void dialogParentChanged(QObject *parent);
+ void titleChanged(const QString &title);
private:
QWidget *bestParentWindow(QObject *parent) const;
+
+ class Private;
+ Private *const d;
};
class DeclarativeColorDialog : public DeclarativeWidgetProxy<QColorDialog>