aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-22 21:18:52 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-26 09:17:20 +0000
commit52e933ce2b10b0e1b48afa9ce048552830309da7 (patch)
tree4fa2775aeaac86bbf083b0d477b4919004a55fe4 /src/quicktemplates2
parentfa71ef5a2ccfa4666db9338c4ba8f34d19f2faf1 (diff)
Add QQuickDialog::title
Dialog is incomplete without built-in support for title. All dialogs in the examples, screenshots, webinars, and blog posts have had a custom title. The Material and Universal designs both have specs for dialog titles. This commit adds support for dialog titles with appropriate looks (padding & font) out of the box. Task-number: QTBUG-56711 Change-Id: I248150313f1ce629a7105fdbe1c70c8fcd69e1cc Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickdialog.cpp38
-rw-r--r--src/quicktemplates2/qquickdialog_p.h5
-rw-r--r--src/quicktemplates2/qquickdialog_p_p.h1
3 files changed, 43 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp
index 356e6c27..05e0f26d 100644
--- a/src/quicktemplates2/qquickdialog.cpp
+++ b/src/quicktemplates2/qquickdialog.cpp
@@ -56,7 +56,10 @@ QT_BEGIN_NAMESPACE
\image qtquickcontrols2-page-wireframe.png
- \section1 Dialog Buttons
+ \section1 Dialog Title and Buttons
+
+ Dialog's \l title is displayed by a style-specific title bar that is assigned
+ as a dialog \l header by default.
Dialog's standard buttons are managed by a \l DialogButtonBox that is assigned
as a dialog \l footer by default. The dialog's \l standardButtons property is
@@ -119,6 +122,39 @@ QQuickDialog::QQuickDialog(QObject *parent) :
}
/*!
+ \qmlproperty string QtQuick.Controls::Dialog::title
+
+ This property holds the dialog title.
+
+ The title is displayed in the dialog header.
+
+ \code
+ Dialog {
+ title: qsTr("About")
+
+ Label {
+ text: "Lorem ipsum..."
+ }
+ }
+ \endcode
+*/
+QString QQuickDialog::title() const
+{
+ Q_D(const QQuickDialog);
+ return d->title;
+}
+
+void QQuickDialog::setTitle(const QString &title)
+{
+ Q_D(QQuickDialog);
+ if (d->title == title)
+ return;
+
+ d->title = title;
+ emit titleChanged();
+}
+
+/*!
\qmlproperty Item QtQuick.Controls::Dialog::header
This property holds the dialog header item. The header item is positioned to
diff --git a/src/quicktemplates2/qquickdialog_p.h b/src/quicktemplates2/qquickdialog_p.h
index 1cd50f4a..ff8a1e79 100644
--- a/src/quicktemplates2/qquickdialog_p.h
+++ b/src/quicktemplates2/qquickdialog_p.h
@@ -58,6 +58,7 @@ class QQuickDialogPrivate;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup
{
Q_OBJECT
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL)
@@ -66,6 +67,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup
public:
explicit QQuickDialog(QObject *parent = nullptr);
+ QString title() const;
+ void setTitle(const QString &title);
+
QQuickItem *header() const;
void setHeader(QQuickItem *header);
@@ -83,6 +87,7 @@ Q_SIGNALS:
void accepted();
void rejected();
+ void titleChanged();
void headerChanged();
void footerChanged();
void standardButtonsChanged();
diff --git a/src/quicktemplates2/qquickdialog_p_p.h b/src/quicktemplates2/qquickdialog_p_p.h
index e5ac7066..5ea84cc8 100644
--- a/src/quicktemplates2/qquickdialog_p_p.h
+++ b/src/quicktemplates2/qquickdialog_p_p.h
@@ -67,6 +67,7 @@ public:
return dialog->d_func();
}
+ QString title;
QQuickDialogButtonBox *buttonBox;
QScopedPointer<QQuickPageLayout> layout;
QPlatformDialogHelper::StandardButtons standardButtons;