diff options
author | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2012-02-10 10:54:45 +0000 |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2012-02-13 10:05:04 +0000 |
commit | c9aa660d7f02f1010662a85891b3d4969ec58781 (patch) | |
tree | 419a64c6d9665eb6952c4c165a128f42a4dd411a | |
parent | 22f3162a9b750ab11ee7da7e27efcd38a4d753b9 (diff) |
Backported fixes to video demos from QtMultimedia
Backported the following changes from git://gitorious.org/qt/qtmultimedia.git
9092b1ae46d999fb8b971386905d64eba4f9b60d Express qmlvideofx effect parameters declaratively
230782546145e164ec38eb03e37c945aa059d393 Fix some of the effects in qmlvideofx
b6f54c8833347ddb13b12cfd682cd12de72664d8 Tidy up file browsing in video examples
c1ec175b24bde1523fcbd7e33d0f46f3bbc1def9 Tidy up frame rate display in video examples
5c0629b5711b1f349dd7f4add7a61d75bdf5b222 Enable qmlvideofx window to be resized,
when large screen layout is used
50a80cd08330886e380f1ea5801acaca8c31fd00 Fixed 'magnify' shader in qmlvideofx example
8783bcebf7ab2b5e0f5700ee28dd465539b05a04 Disable flicking of qmlvideofx example parameter panel
463ec68b8218b4cacff20bae2750b5dfce25586a Fix shader file loading in qmlvideofx example
cef7321e9a3e5d90476713edac97703c46b4c727 Increase useability of qmlvideofx example on small touchscreens
Reviewed-by: TrustMe
44 files changed, 1147 insertions, 978 deletions
diff --git a/demos/video/qmlvideo/main.cpp b/demos/video/qmlvideo/main.cpp index ec2d4f2aef..78c0dc0bcf 100644 --- a/demos/video/qmlvideo/main.cpp +++ b/demos/video/qmlvideo/main.cpp @@ -41,7 +41,9 @@ #include <QtCore/QString> #include <QtCore/QStringList> +#include <QtDeclarative/QDeclarativeContext> #include <QtGui/QApplication> +#include <QtGui/QDesktopServices> #include <QtGui/QGraphicsObject> #include "qmlapplicationviewer.h" #include "trace.h" @@ -124,6 +126,12 @@ int main(int argc, char *argv[]) rootObject, SLOT(qmlFramePainted())); #endif + QString videoPath; + const QString moviesLocation = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation); + if (!moviesLocation.isEmpty()) + videoPath = moviesLocation; + viewer.rootContext()->setContextProperty("videoPath", videoPath); + QMetaObject::invokeMethod(rootObject, "init"); viewer.showExpanded(); diff --git a/demos/video/qmlvideo/qml/qmlvideo/FileBrowser.qml b/demos/video/qmlvideo/qml/qmlvideo/FileBrowser.qml index be18a9fe3a..8a50a507a8 100644 --- a/demos/video/qmlvideo/qml/qmlvideo/FileBrowser.qml +++ b/demos/video/qmlvideo/qml/qmlvideo/FileBrowser.qml @@ -43,312 +43,342 @@ import QtQuick 1.0 import Qt.labs.folderlistmodel 1.0 Rectangle { - id: root - color: "white" - property bool showFocusHighlight: false - property variant folders: folders1 - property variant view: view1 - property alias folder: folders1.folder - property color textColor: "black" - - signal openFile(string path) - - FolderListModel { - id: folders1 - folder: folder + id: fileBrowser + color: "transparent" + + property string folder + property bool shown: (loader.sourceComponent != undefined) + + signal fileSelected(string file) + + function selectFile(file) { + if (file != "") + folder = loader.item.folders.folder + loader.sourceComponent = undefined + fileBrowser.fileSelected(file) } - FolderListModel { - id: folders2 - folder: folder + Loader { + id: loader } - SystemPalette { - id: palette + function show() { + loader.sourceComponent = fileBrowserComponent + loader.item.parent = fileBrowser + loader.item.anchors.fill = fileBrowser + loader.item.folder = fileBrowser.folder } Component { - id: folderDelegate + id: fileBrowserComponent Rectangle { - id: wrapper - function launch() { - if (folders.isFolder(index)) - down(filePath); - else - root.openFile(filePath); - } - width: root.width - height: 52 - color: "transparent" + id: root + color: "white" + property bool showFocusHighlight: false + property variant folders: folders1 + property variant view: view1 + property alias folder: folders1.folder + property color textColor: "black" - Rectangle { - id: highlight; visible: false - anchors.fill: parent - color: palette.highlight - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } + FolderListModel { + id: folders1 + folder: folder } - Item { - width: 48; height: 48 - Image { - source: "qrc:/images/folder.png" - anchors.centerIn: parent - visible: folders.isFolder(index) - } + FolderListModel { + id: folders2 + folder: folder } - Text { - id: nameText - anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName - anchors.leftMargin: 54 - font.pixelSize: 32 - color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor - elide: Text.ElideRight + SystemPalette { + id: palette } - MouseArea { - id: mouseRegion - anchors.fill: parent - onPressed: { - root.showFocusHighlight = false; - wrapper.ListView.view.currentIndex = index; - } - onClicked: { if (folders == wrapper.ListView.view.model) launch() } - } + Component { + id: folderDelegate - states: [ - State { - name: "pressed" - when: mouseRegion.pressed - PropertyChanges { target: highlight; visible: true } - PropertyChanges { target: nameText; color: palette.highlightedText } - } - ] - } - } + Rectangle { + id: wrapper + function launch() { + if (folders.isFolder(index)) + down(filePath); + else + fileBrowser.selectFile(filePath) + } + width: root.width + height: 52 + color: "transparent" - Rectangle { - id: cancelButton - width: 100 - height: titleBar.height - 7 - color: "black" - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter } + Rectangle { + id: highlight; visible: false + anchors.fill: parent + color: palette.highlight + gradient: Gradient { + GradientStop { id: t1; position: 0.0; color: palette.highlight } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + } + } - Text { - anchors { fill: parent; margins: 4 } - text: "Cancel" - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: 20 - } + Item { + width: 48; height: 48 + Image { + source: "qrc:/images/folder.png" + anchors.centerIn: parent + visible: folders.isFolder(index) + } + } - MouseArea { - anchors.fill: parent - onClicked: root.openFile("") - } - } + Text { + id: nameText + anchors.fill: parent; verticalAlignment: Text.AlignVCenter + text: fileName + anchors.leftMargin: 54 + font.pixelSize: 32 + color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor + elide: Text.ElideRight + } - ListView { - id: view1 - anchors.top: titleBar.bottom - anchors.bottom: cancelButton.top - x: 0 - width: parent.width - model: folders1 - delegate: folderDelegate - highlight: Rectangle { - color: palette.highlight - visible: root.showFocusHighlight && view1.count != 0 - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - width: view1.currentItem == null ? 0 : view1.currentItem.width - } - highlightMoveSpeed: 1000 - pressDelay: 100 - focus: true - state: "current" - states: [ - State { - name: "current" - PropertyChanges { target: view1; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view1; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view1; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } + MouseArea { + id: mouseRegion + anchors.fill: parent + onPressed: { + root.showFocusHighlight = false; + wrapper.ListView.view.currentIndex = index; + } + onClicked: { if (folders == wrapper.ListView.view.model) launch() } + } + + states: [ + State { + name: "pressed" + when: mouseRegion.pressed + PropertyChanges { target: highlight; visible: true } + PropertyChanges { target: nameText; color: palette.highlightedText } + } + ] } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - NumberAnimation { properties: "x"; duration: 250 } } - ] - Keys.onPressed: root.keyPressed(event.key) - } - ListView { - id: view2 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: parent.width - width: parent.width - model: folders2 - delegate: folderDelegate - highlight: Rectangle { - color: palette.highlight - visible: root.showFocusHighlight && view2.count != 0 - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + Rectangle { + id: cancelButton + width: 100 + height: titleBar.height - 7 + color: "black" + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter } + + Text { + anchors { fill: parent; margins: 4 } + text: "Cancel" + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 20 + } + + MouseArea { + anchors.fill: parent + onClicked: fileBrowser.selectFile("") + } } - width: view1.currentItem == null ? 0 : view1.currentItem.width - } - highlightMoveSpeed: 1000 - pressDelay: 100 - states: [ - State { - name: "current" - PropertyChanges { target: view2; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view2; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view2; x: root.width } + + ListView { + id: view1 + anchors.top: titleBar.bottom + anchors.bottom: cancelButton.top + x: 0 + width: parent.width + model: folders1 + delegate: folderDelegate + highlight: Rectangle { + color: palette.highlight + visible: root.showFocusHighlight && view1.count != 0 + gradient: Gradient { + GradientStop { id: t1; position: 0.0; color: palette.highlight } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + } + width: view1.currentItem == null ? 0 : view1.currentItem.width + } + highlightMoveSpeed: 1000 + pressDelay: 100 + focus: true + state: "current" + states: [ + State { + name: "current" + PropertyChanges { target: view1; x: 0 } + }, + State { + name: "exitLeft" + PropertyChanges { target: view1; x: -root.width } + }, + State { + name: "exitRight" + PropertyChanges { target: view1; x: root.width } + } + ] + transitions: [ + Transition { + to: "current" + SequentialAnimation { + NumberAnimation { properties: "x"; duration: 250 } + } + }, + Transition { + NumberAnimation { properties: "x"; duration: 250 } + NumberAnimation { properties: "x"; duration: 250 } + } + ] + Keys.onPressed: root.keyPressed(event.key) } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } + + ListView { + id: view2 + anchors.top: titleBar.bottom + anchors.bottom: parent.bottom + x: parent.width + width: parent.width + model: folders2 + delegate: folderDelegate + highlight: Rectangle { + color: palette.highlight + visible: root.showFocusHighlight && view2.count != 0 + gradient: Gradient { + GradientStop { id: t1; position: 0.0; color: palette.highlight } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + } + width: view1.currentItem == null ? 0 : view1.currentItem.width } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } + highlightMoveSpeed: 1000 + pressDelay: 100 + states: [ + State { + name: "current" + PropertyChanges { target: view2; x: 0 } + }, + State { + name: "exitLeft" + PropertyChanges { target: view2; x: -root.width } + }, + State { + name: "exitRight" + PropertyChanges { target: view2; x: root.width } + } + ] + transitions: [ + Transition { + to: "current" + SequentialAnimation { + NumberAnimation { properties: "x"; duration: 250 } + } + }, + Transition { + NumberAnimation { properties: "x"; duration: 250 } + } + ] + Keys.onPressed: root.keyPressed(event.key) } - ] - Keys.onPressed: root.keyPressed(event.key) - } - Keys.onPressed: { - root.keyPressed(event.key); - if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { - view.currentItem.launch(); - event.accepted = true; - } else if (event.key == Qt.Key_Left) { - up(); - } - } + Keys.onPressed: { + root.keyPressed(event.key); + if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { + view.currentItem.launch(); + event.accepted = true; + } else if (event.key == Qt.Key_Left) { + up(); + } + } - BorderImage { - source: "qrc:/images/titlebar.sci"; - width: parent.width; - height: 52 - y: -7 - id: titleBar + BorderImage { + source: "qrc:/images/titlebar.sci"; + width: parent.width; + height: 52 + y: -7 + id: titleBar - Rectangle { - id: upButton - width: 48 - height: titleBar.height - 7 - color: "transparent" - Image { anchors.centerIn: parent; source: "qrc:/images/up.png" } - MouseArea { id: upRegion; anchors.centerIn: parent - width: 56 - height: 56 - onClicked: if (folders.parentFolder != "") up() - } - states: [ - State { - name: "pressed" - when: upRegion.pressed - PropertyChanges { target: upButton; color: palette.highlight } + Rectangle { + id: upButton + width: 48 + height: titleBar.height - 7 + color: "transparent" + Image { anchors.centerIn: parent; source: "qrc:/images/up.png" } + MouseArea { id: upRegion; anchors.centerIn: parent + width: 56 + height: 56 + onClicked: if (folders.parentFolder != "") up() + } + states: [ + State { + name: "pressed" + when: upRegion.pressed + PropertyChanges { target: upButton; color: palette.highlight } + } + ] } - ] - } - Rectangle { - color: "gray" - x: 48 - width: 1 - height: 44 - } + Rectangle { + color: "gray" + x: 48 + width: 1 + height: 44 + } - Text { - anchors.left: upButton.right; anchors.right: parent.right; height: parent.height - anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder - color: "white" - elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter - font.pixelSize: 32 - } - } + Text { + anchors.left: upButton.right; anchors.right: parent.right; height: parent.height + anchors.leftMargin: 4; anchors.rightMargin: 4 + text: folders.folder + color: "white" + elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter + font.pixelSize: 32 + } + } - function down(path) { - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitLeft"; - } else { - view = view1 - folders = folders1; - view2.state = "exitLeft"; - } - view.x = root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } + function down(path) { + if (folders == folders1) { + view = view2 + folders = folders2; + view1.state = "exitLeft"; + } else { + view = view1 + folders = folders1; + view2.state = "exitLeft"; + } + view.x = root.width; + view.state = "current"; + view.focus = true; + folders.folder = path; + } - function up() { - var path = folders.parentFolder; - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitRight"; - } else { - view = view1 - folders = folders1; - view2.state = "exitRight"; - } - view.x = -root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } + function up() { + var path = folders.parentFolder; + if (folders == folders1) { + view = view2 + folders = folders2; + view1.state = "exitRight"; + } else { + view = view1 + folders = folders1; + view2.state = "exitRight"; + } + view.x = -root.width; + view.state = "current"; + view.focus = true; + folders.folder = path; + } - function keyPressed(key) { - switch (key) { - case Qt.Key_Up: - case Qt.Key_Down: - case Qt.Key_Left: - case Qt.Key_Right: - root.showFocusHighlight = true; - break; - default: - // do nothing - break; + function keyPressed(key) { + switch (key) { + case Qt.Key_Up: + case Qt.Key_Down: + case Qt.Key_Left: + case Qt.Key_Right: + root.showFocusHighlight = true; + break; + default: + // do nothing + break; + } + } } } } diff --git a/demos/video/qmlvideo/qml/qmlvideo/main.qml b/demos/video/qmlvideo/qml/qmlvideo/main.qml index 6c294b64d7..e7a36c0ec0 100644 --- a/demos/video/qmlvideo/qml/qmlvideo/main.qml +++ b/demos/video/qmlvideo/qml/qmlvideo/main.qml @@ -56,7 +56,6 @@ Rectangle { QtObject { id: d - property int fileIndex property int itemHeight: 40 property int buttonHeight: 0.8 * itemHeight property int margins: 10 @@ -70,16 +69,27 @@ Rectangle { Loader { id: performanceLoader + + Connections { + target: inner + onVisibleChanged: + if (performanceLoader.item) + performanceLoader.item.enabled = !inner.visible + ignoreUnknownSignals: true + } + function init() { console.log("[qmlvideo] performanceLoader.init logging " + root.perfMonitorsLogging + " visible " + root.perfMonitorsVisible) var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible source = enabled ? "../performancemonitor/PerformanceItem.qml" : "" } + onLoaded: { item.parent = root item.anchors.fill = root item.logging = root.perfMonitorsLogging item.displayed = root.perfMonitorsVisible + item.enabled = false item.init() } } @@ -99,7 +109,7 @@ Rectangle { } height: d.buttonHeight text: (root.source1 == "") ? "Select file 1" : root.source1 - onClicked: showFileBrowser(1) + onClicked: fileBrowser1.show() } Button { @@ -112,7 +122,7 @@ Rectangle { } height: d.buttonHeight text: (root.source2 == "") ? "Select file 2" : root.source2 - onClicked: showFileBrowser(2) + onClicked: fileBrowser2.show() } Button { @@ -187,8 +197,26 @@ Rectangle { ignoreUnknownSignals: true } - Loader { - id: fileBrowserLoader + FileBrowser { + id: fileBrowser1 + anchors.fill: root + onFolderChanged: fileBrowser2.folder = folder + Component.onCompleted: fileSelected.connect(root.openFile1) + } + + FileBrowser { + id: fileBrowser2 + anchors.fill: root + onFolderChanged: fileBrowser1.folder = folder + Component.onCompleted: fileSelected.connect(root.openFile2) + } + + function openFile1(path) { + root.source1 = path + } + + function openFile2(path) { + root.source2 = path } ErrorDialog { @@ -200,6 +228,8 @@ Rectangle { // Called from main() once root properties have been set function init() { performanceLoader.init() + fileBrowser1.folder = videoPath + fileBrowser2.folder = videoPath } function qmlFramePainted() { @@ -207,26 +237,6 @@ Rectangle { performanceLoader.item.qmlFramePainted() } - function showFileBrowser(index) { - console.log("[qmlvideo] main.showFileBrowser") - d.fileIndex = index - fileBrowserLoader.source = "FileBrowser.qml" - fileBrowserLoader.item.parent = root - fileBrowserLoader.item.anchors.fill = root - fileBrowserLoader.item.openFile.connect(root.openFile) - inner.visible = false - } - - function openFile(path) { - console.log("[qmlvideo] main.openFile " + d.fileIndex + " \"" + path + "\"") - fileBrowserLoader.source = "" - if (1 == d.fileIndex) - root.source1 = path - else if (2 == d.fileIndex) - root.source2 = path - inner.visible = true - } - function closeScene() { console.log("[qmlvideo] main.closeScene") sceneSelectionPanel.sceneSource = "" diff --git a/demos/video/qmlvideofx/filereader.cpp b/demos/video/qmlvideofx/filereader.cpp index f3c08272a7..426e10a343 100644 --- a/demos/video/qmlvideofx/filereader.cpp +++ b/demos/video/qmlvideofx/filereader.cpp @@ -41,18 +41,38 @@ #include "filereader.h" #include "trace.h" +#include <QtCore/QCoreApplication> #include <QtCore/QFile> +#include <QtCore/QFileInfo> #include <QtCore/QTextStream> +QString adjustPath(const QString &path) +{ +#ifdef Q_OS_UNIX +#ifdef Q_OS_MAC + if (!QDir::isAbsolutePath(path)) + return QCoreApplication::applicationDirPath() + + QLatin1String("/../Resources/") + path; +#else + QString pathInInstallDir; + const QString applicationDirPath = QCoreApplication::applicationDirPath(); + pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); + + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; +#endif +#endif + return path; +} + QString FileReader::readFile(const QString &fileName) { - qtTrace() << "FileReader::readFile" << "fileName" << fileName; + qtTrace() << "FileReader::readFile" << "fileName" << fileName << "adjusted" << adjustPath(fileName); QString content; - QFile file(fileName); + QFile file(adjustPath(fileName)); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); content = stream.readAll(); } return content; } - diff --git a/demos/video/qmlvideofx/main.cpp b/demos/video/qmlvideofx/main.cpp index f43af8f5da..7f9295e0a1 100644 --- a/demos/video/qmlvideofx/main.cpp +++ b/demos/video/qmlvideofx/main.cpp @@ -41,6 +41,7 @@ #include <QtDeclarative/QDeclarativeContext> #include <QtGui/QApplication> +#include <QtGui/QDesktopServices> #include <QtGui/QGraphicsObject> #include "filereader.h" #include "qmlapplicationviewer.h" @@ -137,6 +138,18 @@ int main(int argc, char *argv[]) FileReader fileReader; viewer.rootContext()->setContextProperty("fileReader", &fileReader); + QString imagePath = "../../images"; + const QString picturesLocation = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); + if (!picturesLocation.isEmpty()) + imagePath = picturesLocation; + viewer.rootContext()->setContextProperty("imagePath", imagePath); + + QString videoPath; + const QString moviesLocation = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation); + if (!moviesLocation.isEmpty()) + videoPath = moviesLocation; + viewer.rootContext()->setContextProperty("videoPath", videoPath); + #ifdef SMALL_SCREEN_PHYSICAL viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape); viewer.showFullScreen(); diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/Content.qml b/demos/video/qmlvideofx/qml/qmlvideofx/Content.qml index af9a2bdc2c..c63618b896 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/Content.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/Content.qml @@ -83,6 +83,16 @@ Rectangle { ignoreUnknownSignals: true } + onWidthChanged: { + if (effectLoader.item) + effectLoader.item.targetWidth = root.width + } + + onHeightChanged: { + if (effectLoader.item) + effectLoader.item.targetHeight = root.height + } + onEffectSourceChanged: { console.log("[qmlvideofx] Content.onEffectSourceChanged " + effectSource) effectLoader.source = effectSource @@ -91,7 +101,7 @@ Rectangle { effectLoader.item.targetHeight = root.height updateSource() effectLoader.item.source = theSource - divider.visible = effectLoader.item.supportsDivider + divider.visible = effectLoader.item.divider updateDivider() } @@ -102,7 +112,7 @@ Rectangle { } function updateDivider() { - if (effectLoader.item && effectLoader.item.supportsDivider) + if (effectLoader.item && effectLoader.item.divider) effectLoader.item.dividerValue = divider.value } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml b/demos/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml index 7ae806d69c..180dbec25e 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml @@ -42,5 +42,6 @@ import QtQuick 1.0 Image { + fillMode: Image.PreserveAspectFit smooth: true } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/Divider.qml b/demos/video/qmlvideofx/qml/qmlvideofx/Divider.qml index 853398da15..5e6d6e5e51 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/Divider.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/Divider.qml @@ -45,50 +45,29 @@ Rectangle { id: root anchors.fill: parent color: "transparent" - property alias value: grip.value + property alias value: slider.value property alias lineWidth: line.width - property alias gripSize: grip.width - - Rectangle { - id: grip - property real value: 0.5 - x: (value * parent.width) - width/2 - anchors.top: parent.top - width: 20 - height: width - radius: width/2 - color: "red" - - MouseArea { - anchors.fill: parent - - drag { - target: grip - axis: Drag.XAxis - minimumX: -parent.width/2 - maximumX: root.width - parent.width/2 - } - - onPositionChanged: { - if (drag.active) - updatePosition() - } - - onReleased: { - updatePosition() - } - - function updatePosition() { - value = (grip.x + grip.width/2) / grip.parent.width - } - } - } + property alias gripSize: slider.gripSize Rectangle { id: line anchors { top: parent.top; bottom: parent.bottom } - x: value * parent.width - (width / 2) + x: parent.value * parent.width - (width / 2) width: 2 color: "red" } + + Slider { + id: slider + increment: 0.0 + lineColor: "transparent" + fillColor: "transparent" + gripColor: "red" + anchors { + top: parent.top + topMargin: gripSize / 2 + left: parent.left + right: parent.right + } + } } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/Effect.qml b/demos/video/qmlvideofx/qml/qmlvideofx/Effect.qml index a28696544f..eba2d3c5c3 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/Effect.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/Effect.qml @@ -44,8 +44,9 @@ import Qt.labs.shaders 1.0 ShaderEffectItem { property variant source - property int numParameters: 0 - property bool supportsDivider: false + property ListModel parameters: ListModel { } + property bool divider: true + property real dividerValue: 0.5 property real targetWidth: 0 property real targetHeight: 0 property string fragmentShaderFilename diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml index b85ea1d48f..11eec98815 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml @@ -42,13 +42,15 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "grid spacing" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - property real grid: 10.0 * param1Value + // Transform slider values, and bind result to shader uniforms + property real grid: parameters.get(0).value * 10 property real step_x: 0.0015625 property real step_y: targetHeight ? (step_x * targetWidth / targetHeight) : 0.0 diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml index 9e80636214..78916fc3e9 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml @@ -42,12 +42,15 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "threshold" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 + // Transform slider values, and bind result to shader uniforms + property real threshold: parameters.get(0).value fragmentShaderFilename: "shaders/blackandwhite.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml index 758c3e0e46..5d764ab9ed 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml @@ -42,11 +42,5 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 0 - property bool supportsDivider: true - - property real dividerValue: 0.5 - fragmentShaderFilename: "shaders/emboss.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml index 27f761eaeb..4a491b2941 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml @@ -42,34 +42,44 @@ // Based on http://www.geeks3d.com/20100909/shader-library-gaussian-blur-post-processing-filter-in-glsl/ import QtQuick 1.0 +import Qt.labs.shaders 1.0 Item { + id: root + property bool divider: true + property real dividerValue: 0.5 + property ListModel parameters: ListModel { + ListElement { + name: "radius" + value: 0.5 + } + } + property alias targetWidth: verticalShader.targetWidth property alias targetHeight: verticalShader.targetHeight property alias source: verticalShader.source - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true - - property real param1Value: 0.5 - property real dividerValue: 0.5 - Effect { id: verticalShader anchors.fill: parent - property real dividerValue: parent.dividerValue - property real blurSize: 4.0 * parent.param1Value / targetWidth - + dividerValue: parent.dividerValue + property real blurSize: 4.0 * parent.parameters.get(0).value / targetHeight fragmentShaderFilename: "shaders/gaussianblur_v.fsh" + } - Effect { - id: horizontalShader - anchors.fill: parent - property real dividerValue: parent.dividerValue - property real blurSize: parent.blurSize + Effect { + id: horizontalShader + anchors.fill: parent + dividerValue: parent.dividerValue + property real blurSize: 4.0 * parent.parameters.get(0).value / parent.targetWidth + fragmentShaderFilename: "shaders/gaussianblur_h.fsh" + source: horizontalShaderSource - fragmentShaderFilename: "shaders/gaussianblur_h.fsh" + ShaderEffectSource { + id: horizontalShaderSource + sourceItem: verticalShader + smooth: true + hideSource: true } } } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml index 70ed7520ec..f8ed7eea75 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml @@ -42,11 +42,5 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 0 - property bool supportsDivider: true - - property real dividerValue: 0.5 - fragmentShaderFilename: "shaders/glow.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml index c7ce9c7f3f..0252d79345 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml @@ -42,16 +42,20 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 2 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "hue" + value: 0.5 + } + ListElement { + name: "width" + value: 0.5 + } + } - property real param1Value: 0.5 - property real param2Value: 0.5 - property real dividerValue: 0.5 - - property real targetHue: 360.0 * param1Value - property real windowWidth: 60.0 * param2Value + // Transform slider values, and bind result to shader uniforms + property real targetHue: parameters.get(0).value * 360 + property real windowWidth: parameters.get(1).value * 60 fragmentShaderFilename: "shaders/isolate.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml index 81a4e44ad2..a55fa37903 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml @@ -43,22 +43,46 @@ import QtQuick 1.0 Effect { id: root + divider: false + parameters: ListModel { + ListElement { + name: "radius" + value: 0.5 + } + ListElement { + name: "diffraction" + value: 0.5 + } + } - // Constant properties which must be supported by every effect - property int numParameters: 2 - property bool supportsDivider: false + property real posX: -1 + property real posY: -1 - property real param1Value: 0.5 - property real radius: 200 * param1Value + QtObject { + id: d + property real oldTargetWidth: root.targetWidth + property real oldTargetHeight: root.targetHeight + } - property real param2Value: 0.5 - property real diffractionIndex: param2Value + // Transform slider values, and bind result to shader uniforms + property real radius: parameters.get(0).value * 100 + property real diffractionIndex: parameters.get(1).value - property real posX: -1 - property real posY: -1 + onTargetWidthChanged: { + if (posX == -1) + posX = targetWidth / 2 + else if (d.oldTargetWidth != 0) + posX *= (targetWidth / d.oldTargetWidth) + d.oldTargetWidth = targetWidth + } - onTargetWidthChanged: if (posX == -1) posX = targetWidth / 2 - onTargetHeightChanged: if (posY == -1) posY = targetHeight / 2 + onTargetHeightChanged: { + if (posY == -1) + posY = targetHeight / 2 + else if (d.oldTargetHeight != 0) + posY *= (targetHeight / d.oldTargetHeight) + d.oldTargetHeight = targetHeight + } fragmentShaderFilename: "shaders/magnify.fsh" diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml index 2699cd6830..2e24a1699a 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml @@ -42,14 +42,16 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: false + divider: false + parameters: ListModel { + ListElement { + name: "extent" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real curlExtent: 1.0 - param1Value + // Transform slider values, and bind result to shader uniforms + property real curlExtent: 1.0 - parameters.get(0).value fragmentShaderFilename: "shaders/pagecurl.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml index 9125dfb3ce..e07427ced5 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml @@ -42,5 +42,5 @@ import QtQuick 1.0 Effect { - + divider: false } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml index b0d7b274c8..8f2b2eb9d1 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml @@ -42,14 +42,15 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "granularity" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real granularity: param1Value * 20 + // Transform slider values, and bind result to shader uniforms + property real granularity: parameters.get(0).value * 20 fragmentShaderFilename: "shaders/pixelate.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml index 91245c1bc1..ecd5f62cc7 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml @@ -42,14 +42,16 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "gamma" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 + // Transform slider values, and bind result to shader uniforms + property real gamma: parameters.get(0).value - property real gamma: param1Value property real numColors: 8.0 fragmentShaderFilename: "shaders/posterize.fsh" diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml index 59765a6151..c9064a43fe 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml @@ -42,20 +42,23 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 2 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "amplitude" + value: 0.5 + } + ListElement { + name: "frequency" + value: 0.5 + } + } - property real param1Value: 0.5 - property real param2Value: 0.5 - property real dividerValue: 0.5 + // Transform slider values, and bind result to shader uniforms + property real amplitude: parameters.get(0).value * 0.03 + property real n: parameters.get(1).value * 7 property real time: 0 - NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } - property real amplitude: param1Value * 0.03 - property real n: param2Value * 7 - fragmentShaderFilename: "shaders/ripple.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml index d88b2fd454..0a944b91e8 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml @@ -42,11 +42,5 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 0 - property bool supportsDivider: true - - property real dividerValue: 0.5 - fragmentShaderFilename: "shaders/sepia.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml index c8d18ed9e4..5cc4c81ddb 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml @@ -42,14 +42,15 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "sharpness" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real amount: 18.0 * param1Value + // Transform slider values, and bind result to shader uniforms + property real amount: parameters.get(0).value * 18 fragmentShaderFilename: "shaders/sharpen.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml index 46088f27e3..3c26d37533 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml @@ -43,15 +43,16 @@ import QtQuick 1.0 Effect { id: root + parameters: ListModel { + ListElement { + name: "amplitude" + value: 0.5 + } + } - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true - - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real granularity: param1Value * 20 + // Transform slider values, and bind result to shader uniforms + property real granularity: parameters.get(0).value * 20 + property real weight: parameters.get(0).value property real centerX property real centerY @@ -75,7 +76,5 @@ Effect { } } - property real weight: param1Value - fragmentShaderFilename: "shaders/shockwave.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml index fc09242fe4..1e59252d60 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml @@ -42,15 +42,16 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "threshold" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real mixLevel: param1Value - property real targetSize: 250 - (200 * param1Value) // TODO: fix ... + // Transform slider values, and bind result to shader uniforms + property real mixLevel: parameters.get(0).value + property real targetSize: 250 - (200 * mixLevel) // TODO: fix ... property real resS: targetSize property real resT: targetSize diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml index 3171751983..a66cad096c 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection2.qml @@ -42,14 +42,15 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "threshold" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real weight: param1Value + // Transform slider values, and bind result to shader uniforms + property real weight: parameters.get(0).value fragmentShaderFilename: "shaders/sobeledgedetection2.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml index 191311584a..fcf5b3bd64 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml @@ -42,11 +42,5 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 0 - property bool supportsDivider: true - - property real dividerValue: 0.5 - fragmentShaderFilename: "shaders/tiltshift.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml index a1a84c6575..5167c94070 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml @@ -42,15 +42,16 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "threshold" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 - - property real threshold: param1Value - property real targetSize: 250 - (200 * param1Value) // TODO: fix ... + // Transform slider values, and bind result to shader uniforms + property real threshold: parameters.get(0).value + property real targetSize: 250 - (200 * threshold) // TODO: fix ... property real resS: targetSize property real resT: targetSize diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml index a3b0b6c2bc..2e3d3a092b 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml @@ -42,11 +42,5 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 0 - property bool supportsDivider: true - - property real dividerValue: 0.5 - fragmentShaderFilename: "shaders/vignette.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml index cdd61a1b48..ebfb2c534b 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml @@ -42,11 +42,5 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 0 - property bool supportsDivider: true - - property real dividerValue: 0.5 - fragmentShaderFilename: "shaders/warhol.fsh" } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml b/demos/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml index c9a3e08d9a..cb6f16e2de 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml @@ -42,14 +42,16 @@ import QtQuick 1.0 Effect { - // Constant properties which must be supported by every effect - property int numParameters: 1 - property bool supportsDivider: true + parameters: ListModel { + ListElement { + name: "amplitude" + value: 0.5 + } + } - property real param1Value: 0.5 - property real dividerValue: 0.5 + // Transform slider values, and bind result to shader uniforms + property real amplitude: parameters.get(0).value * 0.05 - property real amplitude: param1Value * 0.05 property real frequency: 20 property real time: 0 diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml b/demos/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml index be18a9fe3a..8a50a507a8 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml @@ -43,312 +43,342 @@ import QtQuick 1.0 import Qt.labs.folderlistmodel 1.0 Rectangle { - id: root - color: "white" - property bool showFocusHighlight: false - property variant folders: folders1 - property variant view: view1 - property alias folder: folders1.folder - property color textColor: "black" - - signal openFile(string path) - - FolderListModel { - id: folders1 - folder: folder + id: fileBrowser + color: "transparent" + + property string folder + property bool shown: (loader.sourceComponent != undefined) + + signal fileSelected(string file) + + function selectFile(file) { + if (file != "") + folder = loader.item.folders.folder + loader.sourceComponent = undefined + fileBrowser.fileSelected(file) } - FolderListModel { - id: folders2 - folder: folder + Loader { + id: loader } - SystemPalette { - id: palette + function show() { + loader.sourceComponent = fileBrowserComponent + loader.item.parent = fileBrowser + loader.item.anchors.fill = fileBrowser + loader.item.folder = fileBrowser.folder } Component { - id: folderDelegate + id: fileBrowserComponent Rectangle { - id: wrapper - function launch() { - if (folders.isFolder(index)) - down(filePath); - else - root.openFile(filePath); - } - width: root.width - height: 52 - color: "transparent" + id: root + color: "white" + property bool showFocusHighlight: false + property variant folders: folders1 + property variant view: view1 + property alias folder: folders1.folder + property color textColor: "black" - Rectangle { - id: highlight; visible: false - anchors.fill: parent - color: palette.highlight - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } + FolderListModel { + id: folders1 + folder: folder } - Item { - width: 48; height: 48 - Image { - source: "qrc:/images/folder.png" - anchors.centerIn: parent - visible: folders.isFolder(index) - } + FolderListModel { + id: folders2 + folder: folder } - Text { - id: nameText - anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName - anchors.leftMargin: 54 - font.pixelSize: 32 - color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor - elide: Text.ElideRight + SystemPalette { + id: palette } - MouseArea { - id: mouseRegion - anchors.fill: parent - onPressed: { - root.showFocusHighlight = false; - wrapper.ListView.view.currentIndex = index; - } - onClicked: { if (folders == wrapper.ListView.view.model) launch() } - } + Component { + id: folderDelegate - states: [ - State { - name: "pressed" - when: mouseRegion.pressed - PropertyChanges { target: highlight; visible: true } - PropertyChanges { target: nameText; color: palette.highlightedText } - } - ] - } - } + Rectangle { + id: wrapper + function launch() { + if (folders.isFolder(index)) + down(filePath); + else + fileBrowser.selectFile(filePath) + } + width: root.width + height: 52 + color: "transparent" - Rectangle { - id: cancelButton - width: 100 - height: titleBar.height - 7 - color: "black" - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter } + Rectangle { + id: highlight; visible: false + anchors.fill: parent + color: palette.highlight + gradient: Gradient { + GradientStop { id: t1; position: 0.0; color: palette.highlight } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + } + } - Text { - anchors { fill: parent; margins: 4 } - text: "Cancel" - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: 20 - } + Item { + width: 48; height: 48 + Image { + source: "qrc:/images/folder.png" + anchors.centerIn: parent + visible: folders.isFolder(index) + } + } - MouseArea { - anchors.fill: parent - onClicked: root.openFile("") - } - } + Text { + id: nameText + anchors.fill: parent; verticalAlignment: Text.AlignVCenter + text: fileName + anchors.leftMargin: 54 + font.pixelSize: 32 + color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor + elide: Text.ElideRight + } - ListView { - id: view1 - anchors.top: titleBar.bottom - anchors.bottom: cancelButton.top - x: 0 - width: parent.width - model: folders1 - delegate: folderDelegate - highlight: Rectangle { - color: palette.highlight - visible: root.showFocusHighlight && view1.count != 0 - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - width: view1.currentItem == null ? 0 : view1.currentItem.width - } - highlightMoveSpeed: 1000 - pressDelay: 100 - focus: true - state: "current" - states: [ - State { - name: "current" - PropertyChanges { target: view1; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view1; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view1; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } + MouseArea { + id: mouseRegion + anchors.fill: parent + onPressed: { + root.showFocusHighlight = false; + wrapper.ListView.view.currentIndex = index; + } + onClicked: { if (folders == wrapper.ListView.view.model) launch() } + } + + states: [ + State { + name: "pressed" + when: mouseRegion.pressed + PropertyChanges { target: highlight; visible: true } + PropertyChanges { target: nameText; color: palette.highlightedText } + } + ] } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - NumberAnimation { properties: "x"; duration: 250 } } - ] - Keys.onPressed: root.keyPressed(event.key) - } - ListView { - id: view2 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: parent.width - width: parent.width - model: folders2 - delegate: folderDelegate - highlight: Rectangle { - color: palette.highlight - visible: root.showFocusHighlight && view2.count != 0 - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + Rectangle { + id: cancelButton + width: 100 + height: titleBar.height - 7 + color: "black" + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter } + + Text { + anchors { fill: parent; margins: 4 } + text: "Cancel" + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 20 + } + + MouseArea { + anchors.fill: parent + onClicked: fileBrowser.selectFile("") + } } - width: view1.currentItem == null ? 0 : view1.currentItem.width - } - highlightMoveSpeed: 1000 - pressDelay: 100 - states: [ - State { - name: "current" - PropertyChanges { target: view2; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view2; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view2; x: root.width } + + ListView { + id: view1 + anchors.top: titleBar.bottom + anchors.bottom: cancelButton.top + x: 0 + width: parent.width + model: folders1 + delegate: folderDelegate + highlight: Rectangle { + color: palette.highlight + visible: root.showFocusHighlight && view1.count != 0 + gradient: Gradient { + GradientStop { id: t1; position: 0.0; color: palette.highlight } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + } + width: view1.currentItem == null ? 0 : view1.currentItem.width + } + highlightMoveSpeed: 1000 + pressDelay: 100 + focus: true + state: "current" + states: [ + State { + name: "current" + PropertyChanges { target: view1; x: 0 } + }, + State { + name: "exitLeft" + PropertyChanges { target: view1; x: -root.width } + }, + State { + name: "exitRight" + PropertyChanges { target: view1; x: root.width } + } + ] + transitions: [ + Transition { + to: "current" + SequentialAnimation { + NumberAnimation { properties: "x"; duration: 250 } + } + }, + Transition { + NumberAnimation { properties: "x"; duration: 250 } + NumberAnimation { properties: "x"; duration: 250 } + } + ] + Keys.onPressed: root.keyPressed(event.key) } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } + + ListView { + id: view2 + anchors.top: titleBar.bottom + anchors.bottom: parent.bottom + x: parent.width + width: parent.width + model: folders2 + delegate: folderDelegate + highlight: Rectangle { + color: palette.highlight + visible: root.showFocusHighlight && view2.count != 0 + gradient: Gradient { + GradientStop { id: t1; position: 0.0; color: palette.highlight } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } + } + width: view1.currentItem == null ? 0 : view1.currentItem.width } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } + highlightMoveSpeed: 1000 + pressDelay: 100 + states: [ + State { + name: "current" + PropertyChanges { target: view2; x: 0 } + }, + State { + name: "exitLeft" + PropertyChanges { target: view2; x: -root.width } + }, + State { + name: "exitRight" + PropertyChanges { target: view2; x: root.width } + } + ] + transitions: [ + Transition { + to: "current" + SequentialAnimation { + NumberAnimation { properties: "x"; duration: 250 } + } + }, + Transition { + NumberAnimation { properties: "x"; duration: 250 } + } + ] + Keys.onPressed: root.keyPressed(event.key) } - ] - Keys.onPressed: root.keyPressed(event.key) - } - Keys.onPressed: { - root.keyPressed(event.key); - if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { - view.currentItem.launch(); - event.accepted = true; - } else if (event.key == Qt.Key_Left) { - up(); - } - } + Keys.onPressed: { + root.keyPressed(event.key); + if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { + view.currentItem.launch(); + event.accepted = true; + } else if (event.key == Qt.Key_Left) { + up(); + } + } - BorderImage { - source: "qrc:/images/titlebar.sci"; - width: parent.width; - height: 52 - y: -7 - id: titleBar + BorderImage { + source: "qrc:/images/titlebar.sci"; + width: parent.width; + height: 52 + y: -7 + id: titleBar - Rectangle { - id: upButton - width: 48 - height: titleBar.height - 7 - color: "transparent" - Image { anchors.centerIn: parent; source: "qrc:/images/up.png" } - MouseArea { id: upRegion; anchors.centerIn: parent - width: 56 - height: 56 - onClicked: if (folders.parentFolder != "") up() - } - states: [ - State { - name: "pressed" - when: upRegion.pressed - PropertyChanges { target: upButton; color: palette.highlight } + Rectangle { + id: upButton + width: 48 + height: titleBar.height - 7 + color: "transparent" + Image { anchors.centerIn: parent; source: "qrc:/images/up.png" } + MouseArea { id: upRegion; anchors.centerIn: parent + width: 56 + height: 56 + onClicked: if (folders.parentFolder != "") up() + } + states: [ + State { + name: "pressed" + when: upRegion.pressed + PropertyChanges { target: upButton; color: palette.highlight } + } + ] } - ] - } - Rectangle { - color: "gray" - x: 48 - width: 1 - height: 44 - } + Rectangle { + color: "gray" + x: 48 + width: 1 + height: 44 + } - Text { - anchors.left: upButton.right; anchors.right: parent.right; height: parent.height - anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder - color: "white" - elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter - font.pixelSize: 32 - } - } + Text { + anchors.left: upButton.right; anchors.right: parent.right; height: parent.height + anchors.leftMargin: 4; anchors.rightMargin: 4 + text: folders.folder + color: "white" + elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter + font.pixelSize: 32 + } + } - function down(path) { - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitLeft"; - } else { - view = view1 - folders = folders1; - view2.state = "exitLeft"; - } - view.x = root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } + function down(path) { + if (folders == folders1) { + view = view2 + folders = folders2; + view1.state = "exitLeft"; + } else { + view = view1 + folders = folders1; + view2.state = "exitLeft"; + } + view.x = root.width; + view.state = "current"; + view.focus = true; + folders.folder = path; + } - function up() { - var path = folders.parentFolder; - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitRight"; - } else { - view = view1 - folders = folders1; - view2.state = "exitRight"; - } - view.x = -root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } + function up() { + var path = folders.parentFolder; + if (folders == folders1) { + view = view2 + folders = folders2; + view1.state = "exitRight"; + } else { + view = view1 + folders = folders1; + view2.state = "exitRight"; + } + view.x = -root.width; + view.state = "current"; + view.focus = true; + folders.folder = path; + } - function keyPressed(key) { - switch (key) { - case Qt.Key_Up: - case Qt.Key_Down: - case Qt.Key_Left: - case Qt.Key_Right: - root.showFocusHighlight = true; - break; - default: - // do nothing - break; + function keyPressed(key) { + switch (key) { + case Qt.Key_Up: + case Qt.Key_Down: + case Qt.Key_Left: + case Qt.Key_Right: + root.showFocusHighlight = true; + break; + default: + // do nothing + break; + } + } } } } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml b/demos/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml index 23bb846c42..8881c928f6 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml @@ -45,6 +45,7 @@ Rectangle { id: root color: "white" property int buttonHeight: 35 + property int topMargin: 0 signal openImage signal openVideo @@ -53,9 +54,8 @@ Rectangle { Rectangle { anchors { - topMargin: 10 - bottomMargin: 10 top: parent.top; + topMargin: root.topMargin bottom: parent.bottom; horizontalCenter: parent.horizontalCenter } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml b/demos/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml index 1e1759e137..d4820cc7d4 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml @@ -44,44 +44,66 @@ import QtQuick 1.0 Rectangle { id: root color: "transparent" - height: numParameters * sliderHeight + (numParameters + 1) * spacing - visible: numParameters > 0 + height: view.model.count * sliderHeight property color lineColor: "black" - property int numParameters: 1 - property alias param1Value: slider1.value - property alias param2Value: slider2.value - property bool enabled: true property real gripSize: 25 property real spacing: 10 property real sliderHeight: 40 - Slider { - id: slider1 - color: "white" - enabled: parent.enabled - gripSize: root.gripSize - height: sliderHeight - visible: enabled - anchors { - left: parent.left - right: parent.right - bottom: (root.numParameters == 1) ? root.bottom : slider2.top - margins: root.spacing - } + property ListModel model: ListModel { } + + Rectangle { + anchors.fill: parent + color: "black" + opacity: 0.5 + radius: 10 } - Slider { - id: slider2 - color: "white" - enabled: parent.enabled && root.numParameters >= 2 - gripSize: root.gripSize - height: sliderHeight - visible: enabled - anchors { - left: parent.left - right: parent.right - bottom: root.bottom - margins: root.spacing + Component { + id: editDelegate + + Rectangle { + id: delegate + width: parent.width + height: root.sliderHeight + color: "transparent" + + Text { + id: text + text: name + color: "white" + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + } + font.pixelSize: 0.5 * parent.height + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + width: 150 + } + + Slider { + anchors { + top: parent.top + bottom: parent.bottom + left: text.right + leftMargin: 20 + right: parent.right + rightMargin: 20 + } + gripSize: root.gripSize + value: model.value + onValueChanged: view.model.setProperty(index, "value", value) + } } } + + ListView { + id: view + anchors.fill: parent + model: root.model + delegate: editDelegate + interactive: false + } } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/Slider.qml b/demos/video/qmlvideofx/qml/qmlvideofx/Slider.qml index 69291d5351..ce07e88b0e 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/Slider.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/Slider.qml @@ -43,21 +43,41 @@ import QtQuick 1.0 Rectangle { id: root - color: "white" + color: "transparent" radius: 5 property alias value: grip.value + property color fillColor: "white" property color lineColor: "black" - property alias gripSize: grip.width - property alias enabled: mouseArea.enabled + property color gripColor: "white" + property real gripSize: 20 + property real gripTolerance: 3.0 + property real increment: 0.1 + property bool enabled: true Rectangle { anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter } height: 3 - color: displayedColor() + color: displayedColor(root.lineColor) Rectangle { anchors { fill: parent; margins: 1 } - color: root.color + color: root.fillColor + } + } + + MouseArea { + anchors.fill: parent + enabled: root.enabled + onClicked: { + if (parent.width) { + var newValue = mouse.x / parent.width + if (Math.abs(newValue - parent.value) > parent.increment) { + if (newValue > parent.value) + parent.value = Math.min(1.0, parent.value + parent.increment) + else + parent.value = Math.max(0.0, parent.value - parent.increment) + } + } } } @@ -66,13 +86,14 @@ Rectangle { property real value: 0.5 x: (value * parent.width) - width/2 anchors.verticalCenter: parent.verticalCenter - width: 20 + width: root.gripTolerance * root.gripSize height: width radius: width/2 - color: displayedColor() + color: "transparent" MouseArea { id: mouseArea + enabled: root.enabled anchors.fill: parent drag { target: grip @@ -93,14 +114,16 @@ Rectangle { } Rectangle { - anchors { fill: parent; margins: 1 } + anchors.centerIn: parent + width: root.gripSize + height: width radius: width/2 - color: root.color + color: root.gripColor } } - function displayedColor() { - var tint = Qt.rgba(color.r, color.g, color.b, 0.25) - return enabled ? lineColor : Qt.tint(color, tint) + function displayedColor(c) { + var tint = Qt.rgba(c.r, c.g, c.b, 0.25) + return enabled ? c : Qt.tint(c, tint) } } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/main-largescreen.qml b/demos/video/qmlvideofx/qml/qmlvideofx/main-largescreen.qml index 23320c8c39..5e624eaae6 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/main-largescreen.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/main-largescreen.qml @@ -53,7 +53,7 @@ Rectangle { QtObject { id: d - property string openFileType + property real gripSize: 20 } Rectangle { @@ -65,9 +65,12 @@ Rectangle { id: content anchors { top: parent.top + bottom: parent.bottom left: parent.left + right: effectSelectionPanel.left margins: 5 } + gripSize: d.gripSize width: 600 height: 600 } @@ -84,8 +87,6 @@ Rectangle { item.anchors.top = content.top item.anchors.left = content.left item.anchors.right = content.right - item.height = content.height / 2 - item.anchors.margins = 5 item.logging = root.perfMonitorsLogging item.displayed = root.perfMonitorsVisible item.init() @@ -94,48 +95,55 @@ Rectangle { ParameterPanel { id: parameterPanel - enabled: numParameters >= 1 - numParameters: content.effect ? content.effect.numParameters : 0 anchors { - top: content.bottom left: parent.left bottom: parent.bottom + right: effectSelectionPanel.left + margins: 20 } - width: content.width - onParam1ValueChanged: updateParameters() + gripSize: d.gripSize } EffectSelectionPanel { id: effectSelectionPanel anchors { top: parent.top - left: content.right + bottom: fileOpen.top right: parent.right margins: 5 } - height: 420 + width: 300 itemHeight: 40 onEffectSourceChanged: { content.effectSource = effectSource - updateParameters() - } + parameterPanel.model = content.effect.parameters + } } FileOpen { id: fileOpen anchors { - top: effectSelectionPanel.bottom - left: content.right right: parent.right bottom: parent.bottom margins: 5 } + width: effectSelectionPanel.width + height: 165 buttonHeight: 32 + topMargin: 10 } } - Loader { - id: fileBrowserLoader + FileBrowser { + id: imageFileBrowser + anchors.fill: root + Component.onCompleted: fileSelected.connect(content.openImage) + } + + FileBrowser { + id: videoFileBrowser + anchors.fill: root + Component.onCompleted: fileSelected.connect(content.openVideo) } Component.onCompleted: { @@ -147,12 +155,12 @@ Rectangle { function init() { console.log("[qmlvideofx] main.init") + imageFileBrowser.folder = imagePath + videoFileBrowser.folder = videoPath content.init() performanceLoader.init() - if (fileName != "") { - d.openFileType = "video" - openFile(fileName) - } + if (fileName != "") + content.openVideo(fileName) } function qmlFramePainted() { @@ -160,19 +168,12 @@ Rectangle { performanceLoader.item.qmlFramePainted() } - function updateParameters() { - if (content.effect.numParameters >= 1) - content.effect.param1Value = parameterPanel.param1Value - } - function openImage() { - d.openFileType = "image" - showFileBrowser("../../images") + imageFileBrowser.show() } function openVideo() { - d.openFileType = "video" - showFileBrowser("../../videos") + videoFileBrowser.show() } function openCamera() { @@ -182,24 +183,4 @@ Rectangle { function close() { content.openImage("qrc:/images/qt-logo.png") } - - function showFileBrowser(path) { - fileBrowserLoader.source = "FileBrowser.qml" - fileBrowserLoader.item.parent = root - fileBrowserLoader.item.anchors.fill = root - fileBrowserLoader.item.openFile.connect(root.openFile) - fileBrowserLoader.item.folder = path - inner.visible = false - } - - function openFile(path) { - fileBrowserLoader.source = "" - if (path != "") { - if (d.openFileType == "image") - content.openImage(path) - else if (d.openFileType == "video") - content.openVideo(path) - } - inner.visible = true - } } diff --git a/demos/video/qmlvideofx/qml/qmlvideofx/main-smallscreen.qml b/demos/video/qmlvideofx/qml/qmlvideofx/main-smallscreen.qml index edaec5dfec..dd03f779e4 100644 --- a/demos/video/qmlvideofx/qml/qmlvideofx/main-smallscreen.qml +++ b/demos/video/qmlvideofx/qml/qmlvideofx/main-smallscreen.qml @@ -53,7 +53,11 @@ Rectangle { QtObject { id: d - property string openFileType + property bool dialogShown: (fileOpenContainer.state == "shown" || + effectSelectionPanel.state == "shown" || + videoFileBrowser.shown || + imageFileBrowser.shown) + property real gripSize: 40 } // Create ScreenSaver element via Loader, so this app will still run if the @@ -64,14 +68,28 @@ Rectangle { Loader { id: performanceLoader + + Connections { + target: d + onDialogShownChanged: + if (performanceLoader.item) + performanceLoader.item.enabled = !d.dialogShown + ignoreUnknownSignals: true + } + function init() { console.log("[qmlvideofx] performanceLoader.init logging " + root.perfMonitorsLogging + " visible " + root.perfMonitorsVisible) var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible source = enabled ? "../performancemonitor/PerformanceItem.qml" : "" } + onLoaded: { item.parent = root - item.anchors.fill = root + item.anchors.top = root.top + item.anchors.topMargin = 100 + item.anchors.left = root.left + item.anchors.right = root.right + item.anchors.bottom = root.verticalCenter item.logging = root.perfMonitorsLogging item.displayed = root.perfMonitorsVisible item.init() @@ -86,7 +104,7 @@ Rectangle { Content { id: content anchors.fill: parent - gripSize: 40 + gripSize: d.gripSize onVideoFramePainted: performanceLoader.item.videoFramePainted() } @@ -98,10 +116,8 @@ Rectangle { right: parent.right; margins: 10 } - numParameters: content.effect.numParameters y: parent.height - opacity: 0.75 - gripSize: 40 + gripSize: d.gripSize states: [ State { @@ -125,10 +141,8 @@ Rectangle { } ] - enabled: content.effect.numParameters >= 1 && effectSelectionPanel.state != "shown" - state: enabled ? "shown" : "baseState" - onParam1ValueChanged: updateParameters() - onParam2ValueChanged: updateParameters() + enabled: false + state: (enabled && !d.dialogShown) ? "shown" : "baseState" } EffectSelectionPanel { @@ -168,8 +182,12 @@ Rectangle { onEffectSourceChanged: { content.effectSource = effectSource - parameterPanel.numParameters = content.effect.numParameters - updateParameters() + if (content.effect.parameters.count) { + parameterPanel.model = content.effect.parameters + parameterPanel.enabled = true + } else { + parameterPanel.enabled = false + } } onClicked: state = "baseState" @@ -297,7 +315,7 @@ Rectangle { splashScreen.state = "hidden" fileOpenContainer.state = "shown" } - enabled: (fileOpenContainer.state != "shown" && effectSelectionPanel.state != "shown") + enabled: !d.dialogShown } HintedMouseArea { @@ -315,7 +333,7 @@ Rectangle { splashScreen.state = "hidden" effectSelectionPanel.state = "shown" } - enabled: (fileOpenContainer.state != "shown" && effectSelectionPanel.state != "shown") + enabled: !d.dialogShown } Image { @@ -341,8 +359,16 @@ Rectangle { fileOpen.close.connect(close) } - Loader { - id: fileBrowserLoader + FileBrowser { + id: imageFileBrowser + anchors.fill: root + Component.onCompleted: fileSelected.connect(content.openImage) + } + + FileBrowser { + id: videoFileBrowser + anchors.fill: root + Component.onCompleted: fileSelected.connect(content.openVideo) } // Called from main() once root properties have been set @@ -350,12 +376,13 @@ Rectangle { console.log("[qmlvideofx] main.init") content.init() performanceLoader.init() + imageFileBrowser.folder = imagePath + videoFileBrowser.folder = videoPath if (fileName != "") { fileOpenMouseArea.hintEnabled = false effectSelectionPanelMouseArea.hintEnabled = false splashScreen.state = "hidden" - d.openFileType = "video" - openFile(fileName) + content.openVideo(fileName) } } @@ -364,23 +391,14 @@ Rectangle { performanceLoader.item.qmlFramePainted() } - function updateParameters() { - if (content.effect.numParameters >= 1) - content.effect.param1Value = parameterPanel.param1Value - if (content.effect.numParameters >= 2) - content.effect.param2Value = parameterPanel.param2Value - } - function openImage() { fileOpenContainer.state = "baseState" - d.openFileType = "image" - showFileBrowser("../../images") + imageFileBrowser.show() } function openVideo() { fileOpenContainer.state = "baseState" - d.openFileType = "video" - showFileBrowser("../../videos") + videoFileBrowser.show() } function openCamera() { @@ -392,25 +410,4 @@ Rectangle { fileOpenContainer.state = "baseState" content.openImage("qrc:/images/qt-logo.png") } - - function showFileBrowser(path) { - content.stop() - fileBrowserLoader.source = "FileBrowser.qml" - fileBrowserLoader.item.parent = root - fileBrowserLoader.item.anchors.fill = root - fileBrowserLoader.item.openFile.connect(root.openFile) - fileBrowserLoader.item.folder = path - inner.visible = false - } - - function openFile(path) { - fileBrowserLoader.source = "" - if (path != "") { - if (d.openFileType == "image") - content.openImage(path) - else if (d.openFileType == "video") - content.openVideo(path) - } - inner.visible = true - } } diff --git a/demos/video/qmlvideofx/shaders/blackandwhite.fsh b/demos/video/qmlvideofx/shaders/blackandwhite.fsh index 7e0dc9d996..4ec9c76688 100644 --- a/demos/video/qmlvideofx/shaders/blackandwhite.fsh +++ b/demos/video/qmlvideofx/shaders/blackandwhite.fsh @@ -41,7 +41,7 @@ // Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html -uniform float param1Value; +uniform float threshold; uniform float dividerValue; uniform sampler2D source; @@ -54,7 +54,7 @@ void main() vec4 orig = texture2D(source, uv); vec3 col = orig.rgb; float y = 0.3 *col.r + 0.59 * col.g + 0.11 * col.b; - y = y < param1Value ? 0.0 : 1.0; + y = y < threshold ? 0.0 : 1.0; if (uv.x < dividerValue) gl_FragColor = qt_Opacity * vec4(y, y, y, 1.0); else diff --git a/demos/video/qmlvideofx/shaders/gaussianblur_h.fsh b/demos/video/qmlvideofx/shaders/gaussianblur_h.fsh index 249ee30404..e2d4e7d10e 100644 --- a/demos/video/qmlvideofx/shaders/gaussianblur_h.fsh +++ b/demos/video/qmlvideofx/shaders/gaussianblur_h.fsh @@ -55,7 +55,7 @@ void main() c += texture2D(source, uv - vec2(3.0*blurSize, 0.0)) * 0.09; c += texture2D(source, uv - vec2(2.0*blurSize, 0.0)) * 0.12; c += texture2D(source, uv - vec2(1.0*blurSize, 0.0)) * 0.15; - c += texture2D(source, uv) * 0.16; + c += texture2D(source, uv) * 0.18; c += texture2D(source, uv + vec2(1.0*blurSize, 0.0)) * 0.15; c += texture2D(source, uv + vec2(2.0*blurSize, 0.0)) * 0.12; c += texture2D(source, uv + vec2(3.0*blurSize, 0.0)) * 0.09; diff --git a/demos/video/qmlvideofx/shaders/gaussianblur_v.fsh b/demos/video/qmlvideofx/shaders/gaussianblur_v.fsh index 249052c9fa..9aaddf0926 100644 --- a/demos/video/qmlvideofx/shaders/gaussianblur_v.fsh +++ b/demos/video/qmlvideofx/shaders/gaussianblur_v.fsh @@ -55,7 +55,7 @@ void main() c += texture2D(source, uv - vec2(0.0, 3.0*blurSize)) * 0.09; c += texture2D(source, uv - vec2(0.0, 2.0*blurSize)) * 0.12; c += texture2D(source, uv - vec2(0.0, 1.0*blurSize)) * 0.15; - c += texture2D(source, uv) * 0.16; + c += texture2D(source, uv) * 0.18; c += texture2D(source, uv + vec2(0.0, 1.0*blurSize)) * 0.15; c += texture2D(source, uv + vec2(0.0, 2.0*blurSize)) * 0.12; c += texture2D(source, uv + vec2(0.0, 3.0*blurSize)) * 0.09; @@ -63,5 +63,6 @@ void main() } else { c = texture2D(source, qt_TexCoord0); } - gl_FragColor = qt_Opacity * c; + // First pass we don't apply opacity + gl_FragColor = c; } diff --git a/demos/video/qmlvideofx/shaders/magnify.fsh b/demos/video/qmlvideofx/shaders/magnify.fsh index 8ec72dfab8..68375051d9 100644 --- a/demos/video/qmlvideofx/shaders/magnify.fsh +++ b/demos/video/qmlvideofx/shaders/magnify.fsh @@ -1,8 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ ** ** This file is part of the Qt Mobility Components. ** @@ -35,6 +34,7 @@ ** ** ** +** ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -53,11 +53,15 @@ uniform float posY; void main() { - float h = diffractionIndex * 0.5 * radius; - vec2 targetSize = vec2(targetWidth, targetHeight); + vec2 tc = qt_TexCoord0; vec2 center = vec2(posX, posY); vec2 xy = gl_FragCoord.xy - center.xy; float r = sqrt(xy.x * xy.x + xy.y * xy.y); - vec2 new_xy = r < radius ? xy * (radius - h) / sqrt(radius * radius - r * r) : xy; - gl_FragColor = qt_Opacity * texture2D(source, (new_xy + center) / targetSize); + if (r < radius) { + float h = diffractionIndex * 0.5 * radius; + vec2 new_xy = r < radius ? xy * (radius - h) / sqrt(radius * radius - r * r) : xy; + vec2 targetSize = vec2(targetWidth, targetHeight); + tc = (new_xy + center) / targetSize; + } + gl_FragColor = qt_Opacity * texture2D(source, tc); } diff --git a/demos/video/qmlvideofx/shaders/tiltshift.fsh b/demos/video/qmlvideofx/shaders/tiltshift.fsh index 4323e7f008..5f52d42ec4 100644 --- a/demos/video/qmlvideofx/shaders/tiltshift.fsh +++ b/demos/video/qmlvideofx/shaders/tiltshift.fsh @@ -67,7 +67,7 @@ void main() { vec2 uv = qt_TexCoord0.xy; vec3 col; - if (uv.x < dividerValue && uv.y >= 0.4 && uv.y <= 0.6) + if (uv.x > dividerValue || (uv.y >= 0.4 && uv.y <= 0.6)) col = texture2D(source, uv).rgb; else col = blur(); diff --git a/demos/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml b/demos/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml index 6aae0ddf94..fd6d75de85 100644 --- a/demos/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml +++ b/demos/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml @@ -55,7 +55,7 @@ Rectangle { border.width: 1 border.color: "yellow" - width: 3.5 * root.textSize + width: 5.5 * root.textSize height: 3.0 * root.textSize color: "black" opacity: 0.5 @@ -74,20 +74,22 @@ Rectangle { samplingInterval: root.enabled ? root.samplingInterval : 0 onAverageFrequencyChanged: { if (root.logging) trace() - instantaneousFrequencyText.text = monitor.instantaneousFrequency.toFixed(2) averageFrequencyText.text = monitor.averageFrequency.toFixed(2) } } Text { - id: instantaneousFrequencyText + id: labelText anchors { - right: parent.right + left: parent.left top: parent.top margins: 10 } color: root.textColor - font.pixelSize: root.textSize + font.pixelSize: 0.6 * root.textSize + text: root.label + width: root.width - 2*anchors.margins + elide: Text.ElideRight } Text { diff --git a/demos/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml b/demos/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml index 5ec1c82b81..07038929cf 100644 --- a/demos/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml +++ b/demos/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml @@ -46,79 +46,96 @@ Rectangle { property bool logging: true property bool displayed: true property bool videoActive - property int samplingInterval: 500 - property color textColor: "yellow" - property int textSize: 28 property int margins: 5 + property bool enabled: true color: "transparent" // This should ensure that the monitor is on top of all other content z: 999 - Loader { - id: videoFrameRateItemLoader - function init() { - source = "../frequencymonitor/FrequencyItem.qml" - item.label = "videoFrameRate" - item.parent = root - item.anchors.left = root.left - item.anchors.top = root.top - item.anchors.margins = root.margins - item.logging = root.logging - item.displayed = root.displayed - videoFrameRateActiveConnections.target = item + Column { + id: column + anchors { + fill: root + margins: 10 } + spacing: 10 + } - Connections { - id: videoFrameRateActiveConnections - ignoreUnknownSignals: true - onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active - } + QtObject { + id: d + property Item qmlFrameRateItem: null + property Item videoFrameRateItem: null } - Loader { - id: qmlFrameRateItemLoader - function init() { - source = "../frequencymonitor/FrequencyItem.qml" - item.label = "qmlFrameRate" - item.parent = root - item.anchors.left = root.left - item.anchors.bottom = root.bottom - item.anchors.margins = root.margins - item.logging = root.logging - item.displayed = root.displayed - } + Connections { + id: videoFrameRateActiveConnections + ignoreUnknownSignals: true + onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active } - Loader { - id: graphicsMemoryItemLoader - function init() { - source = "../graphicsmemorymonitor/GraphicsMemoryItem.qml" - item.parent = root - item.anchors.right = root.right - item.anchors.bottom = root.bottom - item.anchors.margins = root.margins - item.logging = root.logging - item.displayed = root.displayed + states: [ + State { + name: "hidden" + PropertyChanges { + target: root + opacity: 0 + } + } + ] + + transitions: [ + Transition { + from: "*" + to: "*" + NumberAnimation { + properties: "opacity" + easing.type: Easing.OutQuart + duration: 500 + } } + ] + + state: enabled ? "baseState" : "hidden" + + function createQmlFrameRateItem() { + var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") + if (component.status == Component.Ready) + d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate", + displayed: root.displayed, + logging: root.logging + }) } + function createVideoFrameRateItem() { + var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml") + if (component.status == Component.Ready) + d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate", + displayed: root.displayed, + logging: root.logging + }) + videoFrameRateActiveConnections.target = d.videoFrameRateItem + } + + function init() { - videoFrameRateItemLoader.init() - qmlFrameRateItemLoader.init() - graphicsMemoryItemLoader.init() + createQmlFrameRateItem() + createVideoFrameRateItem() } function videoFramePainted() { - videoFrameRateItemLoader.item.notify() + if (d.videoFrameRateItem) + d.videoFrameRateItem.notify() } function qmlFramePainted() { - qmlFrameRateItemLoader.item.notify() + if (d.qmlFrameRateItem) + d.qmlFrameRateItem.notify() } onVideoActiveChanged: { - videoFrameRateItemLoader.item.active = root.videoActive + if (d.videoFrameRateItem) + d.videoFrameRateItem.active = root.videoActive } } |