From 3594ea2a2dec8a74c2e8baf307c13671ebbdf18c Mon Sep 17 00:00:00 2001 From: Juho Annunen Date: Tue, 21 Aug 2018 14:44:48 +0300 Subject: Fix scaling, video path & focusing issues on mediaplayer demo Task-number: QTBUG-62791 Change-Id: I8ea9bcc27fcf0b2d4fb9f7b8ada165f7a5a5d7c8 Reviewed-by: Teemu Holappa --- basicsuite/mediaplayer/ControlBar.qml | 5 +- basicsuite/mediaplayer/EffectSelectionPanel.qml | 7 +-- basicsuite/mediaplayer/FileBrowser.qml | 2 +- basicsuite/mediaplayer/ImageButton.qml | 2 + basicsuite/mediaplayer/ParameterPanel.qml | 14 ++--- basicsuite/mediaplayer/VolumeControl.qml | 5 +- basicsuite/mediaplayer/main.qml | 74 ++++++++++++++++--------- basicsuite/shared/main.cpp | 6 ++ 8 files changed, 71 insertions(+), 44 deletions(-) diff --git a/basicsuite/mediaplayer/ControlBar.qml b/basicsuite/mediaplayer/ControlBar.qml index e4f0665..cdf27f2 100644 --- a/basicsuite/mediaplayer/ControlBar.qml +++ b/basicsuite/mediaplayer/ControlBar.qml @@ -164,14 +164,13 @@ Rectangle { anchors.right: volumeControl.left anchors.rightMargin: 15 anchors.bottom: seekControl.top - spacing: 22 - + spacing: itemMargin + height: parent.height * 0.275 ImageButton { id: fxButton imageSource: "images/FXButton.png" checkable: true checked: effectSelectionPanel.visible - onClicked: { openFX(); } diff --git a/basicsuite/mediaplayer/EffectSelectionPanel.qml b/basicsuite/mediaplayer/EffectSelectionPanel.qml index 0af10a5..9aee910 100644 --- a/basicsuite/mediaplayer/EffectSelectionPanel.qml +++ b/basicsuite/mediaplayer/EffectSelectionPanel.qml @@ -52,7 +52,6 @@ import QtQuick 2.0 Rectangle { id: root color: _backgroundColor - height: 78 property int itemHeight: 25 property string effectSource: "" property bool isMouseAbove: mouseAboveMonitor.containsMouse @@ -141,7 +140,7 @@ Rectangle { id: list anchors.fill: parent clip: true - anchors.margins: 14 + anchors.margins: itemMargin model: sources focus: root.visible && root.opacity && urlBar.opacity === 0 @@ -154,14 +153,14 @@ Rectangle { } delegate: Item { - height: 40 + height: itemHeight width: parent.width property bool isSelected: list.currentIndex == index Text { color: parent.isSelected ? _primaryGreen : "white" text: name anchors.centerIn: parent - font.pixelSize: 20 + font.pixelSize: defaultFontSize font.family: appFont font.styleName: parent.isSelected ? "Bold" : "Regular" } diff --git a/basicsuite/mediaplayer/FileBrowser.qml b/basicsuite/mediaplayer/FileBrowser.qml index a2028f4..a111177 100644 --- a/basicsuite/mediaplayer/FileBrowser.qml +++ b/basicsuite/mediaplayer/FileBrowser.qml @@ -55,7 +55,7 @@ import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: fileBrowser - property string folder: "file:///data/videos" + property string folder: VideosLocation signal fileSelected(string file) diff --git a/basicsuite/mediaplayer/ImageButton.qml b/basicsuite/mediaplayer/ImageButton.qml index cb4dcb4..66888ef 100644 --- a/basicsuite/mediaplayer/ImageButton.qml +++ b/basicsuite/mediaplayer/ImageButton.qml @@ -74,6 +74,8 @@ Item { visible: true opacity: pressed ? 0.6 : 1 smooth: true + height: toolbarMenuButtons.height + width: height } ColorOverlay { diff --git a/basicsuite/mediaplayer/ParameterPanel.qml b/basicsuite/mediaplayer/ParameterPanel.qml index 81bba63..b67381a 100644 --- a/basicsuite/mediaplayer/ParameterPanel.qml +++ b/basicsuite/mediaplayer/ParameterPanel.qml @@ -51,11 +51,10 @@ import QtQuick 2.0 Rectangle { id: root - height: view.model.count * sliderHeight color: _backgroundColor property color lineColor: "black" property real spacing: 10 - property real sliderHeight: 50 + property real sliderHeight: height * 0.4 property bool isMouseAbove: mouseAboveMonitor.containsMouse property ListModel model: ListModel { } @@ -82,15 +81,16 @@ Rectangle { anchors { top: parent.top bottom: parent.bottom - leftMargin: 15 + leftMargin: itemMargin left: parent.left } horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter - font.pixelSize: 20 + font.pixelSize: defaultFontSize font.capitalization: Font.Capitalize font.family: appFont - width: 90 + width: root.width * 0.2 + fontSizeMode: Text.Fit } PlayerSlider { @@ -98,9 +98,9 @@ Rectangle { verticalCenter: text.verticalCenter verticalCenterOffset: 3 left: text.right - leftMargin: 20 + leftMargin: itemMargin right: parent.right - rightMargin: 20 + rightMargin: itemMargin } value: model.value onValueChanged: view.model.setProperty(index, "value", value) diff --git a/basicsuite/mediaplayer/VolumeControl.qml b/basicsuite/mediaplayer/VolumeControl.qml index 4369d04..ab8bec8 100644 --- a/basicsuite/mediaplayer/VolumeControl.qml +++ b/basicsuite/mediaplayer/VolumeControl.qml @@ -59,7 +59,6 @@ Item { property alias volume: volumeSlider.value property bool muted: root.volume == 0.0 property bool volumeItemUp: volumeItem.y == (volumeItem.height + volumeItem.height * 0.05) - //Volume Controls QtButton{ id: toggleVolumeButton @@ -85,7 +84,7 @@ Item { volumeItem.opacity = 0; if (volumeItem.y === 0) - volumeItem.y -= (volumeItem.height + volumeItem.height * 0.05); + volumeItem.y -= (volumeItem.height + itemMargin); else if (volumeItem !== 0) volumeItem.y = 0; } @@ -121,7 +120,7 @@ Item { Slider { id: volumeSlider anchors.bottom: muteVolumeButton.top - anchors.bottomMargin: parent.height * 0.05 + anchors.bottomMargin: itemMargin anchors.top: parent.top anchors.horizontalCenter: muteVolumeButton.horizontalCenter orientation: Qt.Vertical diff --git a/basicsuite/mediaplayer/main.qml b/basicsuite/mediaplayer/main.qml index 527e735..741309d 100644 --- a/basicsuite/mediaplayer/main.qml +++ b/basicsuite/mediaplayer/main.qml @@ -57,6 +57,8 @@ FocusScope { focus: true property real buttonHeight: height * 0.05 + property real itemMargin: Math.min(width * 0.025, height * 0.025) + property real defaultFontSize: height * 0.0375 MouseArea { id: mouseActivityMonitor @@ -119,35 +121,55 @@ FocusScope { } } - ParameterPanel { - id: parameterPanel - opacity: controlBar.opacity * 0.9 - visible: effectSelectionPanel.visible && model.count !== 0 - height: 116 - width: 500 + Rectangle { + id: effectsWrapper + color: "transparent" + Behavior on opacity { NumberAnimation { } } anchors { - bottomMargin: 15 + top: parent.top bottom: controlBar.top - right: effectSelectionPanel.left - rightMargin: 15 + bottomMargin: itemMargin + right: parent.right + left: parent.left } - } + visible: opacity > 0 + opacity: 0 - EffectSelectionPanel { - id: effectSelectionPanel - visible: false - opacity: controlBar.opacity * 0.9 - anchors { - bottom: controlBar.top - right: controlBar.right - bottomMargin: 15 + ParameterPanel { + id: parameterPanel + opacity: controlBar.opacity * 0.9 + visible: effectSelectionPanel.visible && model.count !== 0 + height: parent.height * 0.15 + width: parent.width * 0.4 + anchors { + bottom: parent.bottom + right: effectSelectionPanel.left + rightMargin: itemMargin + } + z: 10 } - width: 250 - height: 350 - itemHeight: 80 - onEffectSourceChanged: { - content.effectSource = effectSource - parameterPanel.model = content.effect.parameters + + EffectSelectionPanel { + id: effectSelectionPanel + opacity: controlBar.opacity * 0.9 + width: parent.width * 0.225 + height: parent.height * 0.7 + anchors { + right: parent.right + bottom: parent.bottom + } + z: 10 + onEffectSourceChanged: { + content.effectSource = effectSource + parameterPanel.model = content.effect.parameters + } + itemHeight: height / 8 + } + + MouseArea{ + anchors.fill: parent + onClicked: effectsWrapper.opacity = 0 + enabled: effectsWrapper.opacity !== 0 } } @@ -234,7 +256,7 @@ FocusScope { function init() { content.init() - content.openVideo("file:///data/videos/Qt_video_720p.webm"); + content.openVideo(DefaultVideoUrl); } function openVideo() { @@ -250,7 +272,7 @@ FocusScope { } function openFX() { - effectSelectionPanel.visible = !effectSelectionPanel.visible; + effectsWrapper.opacity = effectsWrapper.opacity === 0 ? 1 : 0 } function close() { diff --git a/basicsuite/shared/main.cpp b/basicsuite/shared/main.cpp index 58ff00f..4afbbe4 100644 --- a/basicsuite/shared/main.cpp +++ b/basicsuite/shared/main.cpp @@ -135,6 +135,10 @@ int main(int argc, char **argv) QGuiApplication::setFont(font); } + QString videosPath = QStringLiteral("file://"); + QString defaultVideoUrl = QStringLiteral("file:///data/videos/Qt_video_720p.webm"); + videosPath.append("/data/videos"); + QSettings styleSettings; QString style = styleSettings.value("style").toString(); if (style.isEmpty() || style == "Default") @@ -149,6 +153,8 @@ int main(int argc, char **argv) applicationengine.rootContext()->setContextProperty("appFont", appFont); applicationengine.rootContext()->setContextProperty("availableStyles", QQuickStyle::availableStyles()); + applicationengine.rootContext()->setContextProperty("VideosLocation", videosPath); + applicationengine.rootContext()->setContextProperty("DefaultVideoUrl", defaultVideoUrl); QSettings themeColorSettings("QtLauncher", "colorSettings"); -- cgit v1.2.3