aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-08-23 17:22:09 +0800
committerMitch Curtis <mitch.curtis@qt.io>2022-09-05 09:13:53 +0800
commit8f27656470103219cff8b404ed21de33757c8651 (patch)
tree3564a8952f8fd81d0833a4b51cb12cc528d70c9a
parent9628b73f6c2f5d7dbab582eced8d2a705a49cc5b (diff)
Doc: fix and improve FileDialog example snippet
Replace it with a self-contained example that can be copy-pasted and run, and that is easier to understand. Change-Id: I54b67b0173d25aee509318ff842bb895c7244a48 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 25bd3b526c6b78694422d0ebcb6052996dd68f2c)
-rw-r--r--src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf2
-rw-r--r--src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml58
-rw-r--r--src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp18
3 files changed, 61 insertions, 17 deletions
diff --git a/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf b/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf
index 6d59f69817..d4f7595f0f 100644
--- a/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf
+++ b/src/quickdialogs2/quickdialogs2/doc/qtquickdialogs.qdocconf
@@ -24,6 +24,8 @@ depends = qtcore qtqmlcore qtgui qtdoc qtqml qtquick qtquickcontrols qtlabsplatf
# This module has no documented C++ types, clear the module header
moduleheader =
+exampledirs += snippets
+
headerdirs += ..
sourcedirs += .. \
src
diff --git a/src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml b/src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml
new file mode 100644
index 0000000000..f59ac444c3
--- /dev/null
+++ b/src/quickdialogs2/quickdialogs2/doc/snippets/qtquickdialogs-filedialog.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [file]
+import QtCore
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Dialogs
+
+ApplicationWindow {
+ width: 640
+ height: 480
+ visible: true
+
+ header: ToolBar {
+ Button {
+ text: qsTr("Choose Image...")
+ onClicked: fileDialog.open()
+ }
+ }
+
+ Image {
+ id: image
+ anchors.fill: parent
+ fillMode: Image.PreserveAspectFit
+ }
+
+ FileDialog {
+ id: fileDialog
+ currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
+ onAccepted: image.source = selectedFile
+ }
+}
+//! [file]
diff --git a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp
index 15708d426d..c393a67ecf 100644
--- a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp
+++ b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp
@@ -70,23 +70,7 @@ Q_LOGGING_CATEGORY(lcFileDialog, "qt.quick.dialogs.filedialog")
properties are updated only after the final selection has been made by
accepting the dialog.
- \code
- MenuItem {
- text: "Open..."
- onTriggered: fileDialog.open()
- }
-
- FileDialog {
- id: fileDialog
- currentFile: document.source
- folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
- }
-
- MyDocument {
- id: document
- source: fileDialog.file
- }
- \endcode
+ \snippet qtquickdialogs-filedialog.qml file
\section2 Availability