diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-04 19:43:28 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-04 19:43:28 +0200 |
commit | 7a6bf3ed5c5338dca085c3979edc8ec8f51c7980 (patch) | |
tree | 3ac51f00add44ab871434e6d71eae7771b818181 /examples | |
parent | 0462193b6fb97fbe7ccde496c33d82d4d5fce8c0 (diff) | |
parent | 7e73dc01f85355e23a4ee07c0b624b253541acdc (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
.qmake.conf
Change-Id: Ib8b5509c48a686f6e916708d83914e13e4f67e9c
Diffstat (limited to 'examples')
17 files changed, 133 insertions, 33 deletions
diff --git a/examples/quick/demos/calqlatr/calqlatr.pro b/examples/quick/demos/calqlatr/calqlatr.pro index 1b002a5f27..91d52a293e 100644 --- a/examples/quick/demos/calqlatr/calqlatr.pro +++ b/examples/quick/demos/calqlatr/calqlatr.pro @@ -6,5 +6,24 @@ SOURCES += main.cpp RESOURCES += calqlatr.qrc \ ../../shared/shared.qrc +OTHER_FILES = calqlatr.qml \ + content/Button.qml \ + content/Display.qml \ + content/NumberPad.qml \ + content/StyleLabel.qml \ + content/audio/touch.wav \ + content/calculator.js \ + content/images/icon-back.png \ + content/images/icon-close.png \ + content/images/icon-settings.png \ + content/images/logo.png \ + content/images/paper-edge-left.png \ + content/images/paper-edge-right.png \ + content/images/paper-grip.png \ + content/images/settings-selected-a.png \ + content/images/settings-selected-b.png \ + content/images/touch-green.png \ + content/images/touch-white.png + target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/calqlatr INSTALLS += target diff --git a/examples/quick/demos/calqlatr/calqlatr.qml b/examples/quick/demos/calqlatr/calqlatr.qml index 16b2e19724..0a092c25da 100644 --- a/examples/quick/demos/calqlatr/calqlatr.qml +++ b/examples/quick/demos/calqlatr/calqlatr.qml @@ -57,7 +57,7 @@ Rectangle { Item { id: pad - width: window.width * 0.58 + width: 180 NumberPad { y: 10; anchors.horizontalCenter: parent.horizontalCenter } } @@ -77,7 +77,7 @@ Rectangle { Display { id: display x: -16 - width: window.width * 0.42 + width: window.width - pad.width height: parent.height MouseArea { @@ -85,7 +85,12 @@ Rectangle { property real oldP: 0 property bool rewind: false - anchors.fill: parent + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + } + height: 50 onPositionChanged: { var reverse = startX > window.width / 2 var mx = mapToItem(window, mouse.x).x diff --git a/examples/quick/demos/calqlatr/content/Display.qml b/examples/quick/demos/calqlatr/content/Display.qml index 4a78a3ebcd..ec8edfea66 100644 --- a/examples/quick/demos/calqlatr/content/Display.qml +++ b/examples/quick/demos/calqlatr/content/Display.qml @@ -42,23 +42,38 @@ import QtQuick 2.0 Item { id: display + property bool enteringDigits: false function displayOperator(operator) { listView.model.append({ "operator": operator, "operand": "" }) + enteringDigits = true } function newLine(operator, operand) { listView.model.append({ "operator": operator, "operand": operand }) + enteringDigits = false + listView.positionViewAtEnd() } function appendDigit(digit) { - if (!listView.model.count) + if (!enteringDigits) listView.model.append({ "operator": "", "operand": "" }) var i = listView.model.count - 1; listView.model.get(i).operand = listView.model.get(i).operand + digit; + enteringDigits = true + } + + function clear() + { + if (enteringDigits) { + var i = listView.model.count - 1 + if (i >= 0) + listView.model.remove(i) + enteringDigits = false + } } Item { @@ -87,6 +102,7 @@ Item { } Image { + id: grip source: "images/paper-grip.png" anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom @@ -97,7 +113,7 @@ Item { id: listView x: 16; y: 30 width: display.width - height: display.height + height: display.height - 50 - y delegate: Item { height: 20 width: parent.width diff --git a/examples/quick/demos/calqlatr/content/NumberPad.qml b/examples/quick/demos/calqlatr/content/NumberPad.qml index 3203e18431..c7f2680651 100644 --- a/examples/quick/demos/calqlatr/content/NumberPad.qml +++ b/examples/quick/demos/calqlatr/content/NumberPad.qml @@ -60,7 +60,7 @@ Grid { Button { text: "±"; color: "#6da43d"; operator: true } Button { text: "−"; color: "#6da43d"; operator: true } Button { text: "+"; color: "#6da43d"; operator: true } - Button { text: " "; color: "#6da43d"; operator: true } + Button { text: "√"; color: "#6da43d"; operator: true } Button { text: "÷"; color: "#6da43d"; operator: true } Button { text: "×"; color: "#6da43d"; operator: true } Button { text: "C"; color: "#6da43d"; operator: true } diff --git a/examples/quick/demos/calqlatr/content/calculator.js b/examples/quick/demos/calqlatr/content/calculator.js index d86fecbf39..da8e940b16 100644 --- a/examples/quick/demos/calqlatr/content/calculator.js +++ b/examples/quick/demos/calqlatr/content/calculator.js @@ -84,7 +84,7 @@ function operatorPressed(op) } else if (previousOperator == "×") { digits = Number(curVal) * Number(digits.valueOf()) } else if (previousOperator == "÷") { - digits = Number(Number(curVal) / Number(digits.valueOf())).toString() + digits = Number(curVal) / Number(digits.valueOf()) } else if (previousOperator == "=") { } @@ -110,9 +110,9 @@ function operatorPressed(op) digits = (Math.abs(digits.valueOf())).toString() } else if (op == "Int") { digits = (Math.floor(digits.valueOf())).toString() - } else if (op == window.plusminus) { + } else if (op == "±") { digits = (digits.valueOf() * -1).toString() - } else if (op == window.squareRoot) { + } else if (op == "√") { digits = (Math.sqrt(digits.valueOf())).toString() } else if (op == "mc") { memory = 0; @@ -130,7 +130,7 @@ function operatorPressed(op) } else if (op == "Off") { Qt.quit(); } else if (op == "C") { - digits = "0" + display.clear() } else if (op == "AC") { curVal = 0 memory = 0 diff --git a/examples/quick/dialogs/ColorDialogs.qml b/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml index f3d253aa8c..6a0af7f730 100644 --- a/examples/quick/dialogs/ColorDialogs.qml +++ b/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml @@ -49,6 +49,7 @@ Rectangle { SystemPalette { id: palette } clip: true + //! [colordialog] ColorDialog { id: colorDialog visible: colorDialogVisible.checked @@ -59,6 +60,7 @@ Rectangle { onAccepted: { console.log("Accepted: " + color) } onRejected: { console.log("Rejected") } } + //! [colordialog] Column { anchors.fill: parent diff --git a/examples/quick/dialogs/FileDialogs.qml b/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml index 8ed64b0b3c..d1278609f9 100644 --- a/examples/quick/dialogs/FileDialogs.qml +++ b/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml @@ -49,6 +49,7 @@ Rectangle { SystemPalette { id: palette } clip: true + //! [filedialog] FileDialog { id: fileDialog visible: fileDialogVisible.checked @@ -63,6 +64,7 @@ Rectangle { onAccepted: { console.log("Accepted: " + fileUrls) } onRejected: { console.log("Rejected") } } + //! [filedialog] Column { anchors.fill: parent diff --git a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro new file mode 100644 index 0000000000..3a7b25c91a --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro @@ -0,0 +1,17 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp +RESOURCES += colorandfiledialogs.qrc ../../shared/shared.qrc + +OTHER_FILES += \ + dialogs.qml \ + FileDialogs.qml \ + ColorDialogs.qml + +EXAMPLE_FILES = \ + FileDialogs.qml \ + ColorDialogs.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs +INSTALLS += target diff --git a/examples/quick/dialogs/dialogs.qrc b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc index efebfe4845..efebfe4845 100644 --- a/examples/quick/dialogs/dialogs.qrc +++ b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc diff --git a/examples/quick/dialogs/dialogs.qml b/examples/quick/dialogs/colorandfiledialogs/dialogs.qml index b5f9841a3f..b5f9841a3f 100644 --- a/examples/quick/dialogs/dialogs.qml +++ b/examples/quick/dialogs/colorandfiledialogs/dialogs.qml diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg b/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg Binary files differnew file mode 100644 index 0000000000..4517a39308 --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc new file mode 100644 index 0000000000..68804649a9 --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \title Qt Quick ColorDialog and FileDialog Examples + \example colorandfiledialogs + \brief This example demonstrates the color and file dialog types in QML + \image qml-colorandfiledialogs-example.jpg + \ingroup qtquickdialog_examples + + This example demonstrates the color and file system dialogs in the \l{Qt Quick Dialogs} + module. The appearance and behavior is platform-dependent. + + A \l FileDialog is used to choose a single file, multiple files or a + single directory, depending on how it is configured. + \snippet colorandfiledialogs/FileDialogs.qml filedialog + + A \l ColorDialog is used to choose a color, with or without alpha (transparency) + depending on how it is configured. + \snippet colorandfiledialogs/ColorDialogs.qml colordialog +*/ diff --git a/examples/quick/dialogs/main.cpp b/examples/quick/dialogs/colorandfiledialogs/main.cpp index bbf0c48104..e8c2ae6aaa 100644 --- a/examples/quick/dialogs/main.cpp +++ b/examples/quick/dialogs/colorandfiledialogs/main.cpp @@ -37,5 +37,5 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "../shared/shared.h" +#include "../../shared/shared.h" DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs) diff --git a/examples/quick/dialogs/dialogs.pro b/examples/quick/dialogs/dialogs.pro index b76f396e9d..275e36470f 100644 --- a/examples/quick/dialogs/dialogs.pro +++ b/examples/quick/dialogs/dialogs.pro @@ -1,17 +1,4 @@ -TEMPLATE = app +TEMPLATE = subdirs -QT += quick qml -SOURCES += main.cpp -RESOURCES += dialogs.qrc ../shared/shared.qrc - -OTHER_FILES += \ - dialogs.qml \ - FileDialogs.qml \ - ColorDialogs.qml - -EXAMPLE_FILES = \ - FileDialogs.qml \ - ColorDialogs.qml - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs -INSTALLS += target +SUBDIRS = \ + colorandfiledialogs diff --git a/examples/quick/window/Splash.qml b/examples/quick/window/Splash.qml index 092e6e6fc2..c981bd2585 100644 --- a/examples/quick/window/Splash.qml +++ b/examples/quick/window/Splash.qml @@ -43,6 +43,7 @@ import QtQuick.Window 2.1 //! [splash-properties] Window { + id: splash visible: true width: splashImage.width height: splashImage.height @@ -50,7 +51,8 @@ Window { title: "Splash Window" modality: Qt.ApplicationModal flags: Qt.SplashScreen - property int timeout: 2000 + property int timeoutInterval: 2000 + signal timeout //! [splash-properties] //! [screen-properties] x: (Screen.width - splashImage.width) / 2 @@ -67,8 +69,11 @@ Window { } //! [timer] Timer { - interval: timeout; running: true; repeat: false - onTriggered: visible = false + interval: timeoutInterval; running: true; repeat: false + onTriggered: { + visible = false + splash.timeout() + } } //! [timer] } diff --git a/examples/quick/window/main.cpp b/examples/quick/window/main.cpp index 2223c607b4..7872c7183c 100644 --- a/examples/quick/window/main.cpp +++ b/examples/quick/window/main.cpp @@ -41,6 +41,7 @@ #include <QtGui/QGuiApplication> #include <QtQml/QQmlEngine> #include <QtQml/QQmlComponent> +#include <QtQuick/QQuickWindow> #include <QtCore/QUrl> #include <QDebug> @@ -49,6 +50,7 @@ int main(int argc, char* argv[]) QGuiApplication app(argc, argv); QQmlEngine engine; QQmlComponent component(&engine); + QQuickWindow::setDefaultAlphaBuffer(true); component.loadUrl(QUrl("qrc:///window/window.qml")); if ( component.isReady() ) component.create(); diff --git a/examples/quick/window/window.qml b/examples/quick/window/window.qml index 1d7282f7a1..67e2ba40ff 100644 --- a/examples/quick/window/window.qml +++ b/examples/quick/window/window.qml @@ -46,14 +46,11 @@ QtObject { property real defaultSpacing: 10 property SystemPalette palette: SystemPalette { } - property var splashWindow: Splash { } - property var controlWindow: Window { width: 400 height: col.implicitHeight + defaultSpacing * 2 color: palette.window title: "Control Window" - visible: true Column { id: col anchors.fill: parent @@ -177,4 +174,8 @@ QtObject { } } } + + property var splashWindow: Splash { + onTimeout: controlWindow.visible = true + } } |