From d0d9bbf9c044153cc25361ecc17975d6a43cb28f Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Fri, 10 Mar 2017 17:48:23 +0100 Subject: [PATCH 1/4] Initial kirigami 2 port --- icon.svg => icons/vplayer.svg | 0 qml/AboutPage.qml | 150 +++++++++++++++++----------------- qml/GlobalDrawer.qml | 61 ++++++++++++++ qml/HistoryPage.qml | 14 ++-- qml/OpenDialog.qml | 16 +--- qml/OpenUrl.qml | 70 ++++++---------- qml/PlayerPage.qml | 49 +++++------ qml/YoutubeSearch.qml | 39 ++------- qml/main.qml | 49 +++-------- 9 files changed, 206 insertions(+), 242 deletions(-) rename icon.svg => icons/vplayer.svg (100%) create mode 100644 qml/GlobalDrawer.qml diff --git a/icon.svg b/icons/vplayer.svg similarity index 100% rename from icon.svg rename to icons/vplayer.svg diff --git a/qml/AboutPage.qml b/qml/AboutPage.qml index e437c18..bf24952 100644 --- a/qml/AboutPage.qml +++ b/qml/AboutPage.qml @@ -21,96 +21,92 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtQuick.Window 2.1 - -import org.kde.kirigami 1.0 as Kirigami +import QtQuick.Controls 2.0 +import org.kde.kirigami 2.0 as Kirigami Kirigami.ScrollablePage { id: aboutPage title: qsTr("About") - - Flickable { - id: flick - width:parent.width - height: parent.height - anchors.top: parent.top - contentHeight: column1.height - - Column{ - id: column1 - width: parent.width - spacing: 15 - - Image{ - source: mainWindow.appIcon - height: 128 - width: 128 - fillMode: Image.PreserveAspectFit - anchors { - horizontalCenter: parent.horizontalCenter - } + + Column { + width: parent.width + spacing: 15 + + Image { + source: mainWindow.appIcon + height: 128 + width: 128 + fillMode: Image.PreserveAspectFit + + anchors { + horizontalCenter: parent.horizontalCenter } - Kirigami.Label { - font.bold: true - text: mainWindow.appName+" v"+mainWindow.version - anchors.horizontalCenter: parent.horizontalCenter + } + + Kirigami.Heading { + text: mainWindow.appName+" v"+mainWindow.version + anchors.horizontalCenter: parent.horizontalCenter + } + + Kirigami.Label { + text: qsTr("License:") + "LGPLv2" + anchors.horizontalCenter: parent.horizontalCenter + } + + Rectangle { + height: 3 + width: parent.width-64 - } - Kirigami.Label { - text: qsTr("License: LGPLv2") - anchors.horizontalCenter: parent.horizontalCenter - } - Rectangle{ - gradient: Gradient { - GradientStop { position: 0.0; color: "#333333" } - GradientStop { position: 1.0; color: "#777777" } - } - anchors { - horizontalCenter: parent.horizontalCenter - } - height: 3 - width: parent.width-64 + gradient: Gradient { + GradientStop { position: 0.0; color: "#333333" } + GradientStop { position: 1.0; color: "#777777" } } - Kirigami.Label { - width: aboutPage.width - font.bold: true - text: qsTr("Copyright (c) 2014-2015 Leszek Lesner <leszek@zevenos.com>
Copyright (c) 2016 JBBGameich <jbb.mail@gmx.de>") // JBBgameich: I'm still not sure how I should write this text, maybe just "developed by Leszek Lesner, contributors: JBBgameich..." - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignHCenter + anchors { + horizontalCenter: parent.horizontalCenter } - Rectangle{ - gradient: Gradient { - GradientStop { position: 0.0; color: "#333333" } - GradientStop { position: 1.0; color: "#777777" } - } - anchors { - horizontalCenter: parent.horizontalCenter - } - height: 3 - width: parent.width-64 + } + + Kirigami.Label { + width: aboutPage.width + font.bold: true + text: qsTr("Copyright (c) 2014-2015 Leszek Lesner <leszek@zevenos.com>
Copyright (c) 2016 JBBGameich <jbb.mail@gmx.de>") // JBBgameich: I'm still not sure how I should write this text, maybe just "developed by Leszek Lesner, contributors: JBBgameich..." + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignHCenter + } + + Rectangle { + height: 3 + width: parent.width-64 + + gradient: Gradient { + GradientStop { position: 0.0; color: "#333333" } + GradientStop { position: 1.0; color: "#777777" } } - Button { - id: homepage - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Sourcecode on Github") - onClicked: { - Qt.openUrlExternally("https://github.com/llelectronics/videoPlayer/tree/plasma"); - } + anchors { + horizontalCenter: parent.horizontalCenter } - - Kirigami.Label { - width: parent.width-70 - text: qsTr("A simple videoplayer based on gstreamer.") - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignHCenter - height: 200 - wrapMode: Text.WordWrap + } + + Button { + id: homepage + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Sourcecode on Github") + onClicked: { + Qt.openUrlExternally("https://github.com/llelectronics/videoPlayer/tree/plasma"); } } + + Kirigami.Label { + width: parent.width-70 + text: qsTr("A simple videoplayer based on gstreamer.") + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignHCenter + height: 200 + wrapMode: Text.WordWrap + } } } diff --git a/qml/GlobalDrawer.qml b/qml/GlobalDrawer.qml new file mode 100644 index 0000000..1f23e5f --- /dev/null +++ b/qml/GlobalDrawer.qml @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2017 JBBgameich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + */ + +import org.kde.kirigami 2.0 as Kirigami + +Kirigami.GlobalDrawer { + title: "Video Player" + titleIcon: "vplayer" + + drawerOpen: false + // show open button on the left side + handleVisible: true + modal: true + + actions: [ + Kirigami.Action { + text: qsTr("History") + iconName: "view-list-icons" + onTriggered: pageStack.replace(historyPageComponent) + }, + Kirigami.Action { + text: qsTr("Youtube Search") + iconName: "smtube" + onTriggered: pageStack.replace(youtubeSearchComponent) + }, + Kirigami.Action { + text: qsTr("Open File") + iconName: "document-open" + onTriggered: pageStack.replace(openDialogComponent) + }, + Kirigami.Action { + text: qsTr("Open Url") + iconName: "applications-internet" + onTriggered: pageStack.replace(openUrlComponent) + }, + Kirigami.Action { + text: qsTr("About Video Player") + iconName: "help-about" + onTriggered: pageStack.replace(aboutPageComponent) + } + ] +} + diff --git a/qml/HistoryPage.qml b/qml/HistoryPage.qml index b8eacf8..c0aba81 100644 --- a/qml/HistoryPage.qml +++ b/qml/HistoryPage.qml @@ -21,26 +21,26 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.0 +import QtQuick.Controls 2.0 import QtQuick.Window 2.1 - -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami Kirigami.ScrollablePage { id: historyPage title: qsTr("History") ListView { - anchors.fill: historyPage + anchors.fill: parent model: mainWindow.historyModel + delegate: Kirigami.BasicListItem { - width: parent.width - (parent.width / 32) height: implicitHeight - anchors.horizontalCenter: parent.horizontalCenter + onClicked: { - console.debug("Clicked " + htitle + " with url: " + hurl) + console.debug("Clicked " + htitle + " with url: " + hurl); mainWindow.loadPlayer(htitle,hurl) } + Kirigami.Label { anchors.left: parent.left anchors.right: parent.right diff --git a/qml/OpenDialog.qml b/qml/OpenDialog.qml index 3f1f742..316f647 100644 --- a/qml/OpenDialog.qml +++ b/qml/OpenDialog.qml @@ -21,14 +21,14 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.2 +import QtQuick.Controls 2.0 import QtQuick.Window 2.1 import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami import Qt.labs.folderlistmodel 2.1 -Kirigami.Page { +Kirigami.ScrollablePage { id: page title: qsTr("Open File") @@ -87,7 +87,7 @@ Kirigami.Page { model: fileModel anchors.fill: parent - delegate: Kirigami.BasicListItem { + delegate: Kirigami.AbstractListItem { id: delegate width: parent.width enabled: true @@ -119,13 +119,5 @@ Kirigami.Page { } } } - - PlasmaComponents.ScrollBar { - id: scrollBar - flickableItem: view - anchors.right: parent.right - width: parent.width / 64 - interactive: true - } } } diff --git a/qml/OpenUrl.qml b/qml/OpenUrl.qml index bfc1f72..f7fca5c 100644 --- a/qml/OpenUrl.qml +++ b/qml/OpenUrl.qml @@ -21,13 +21,10 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.0 +import QtQuick.Controls 2.0 import QtQuick.Window 2.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 -import org.kde.plasma.extras 2.0 -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami import Qt.labs.folderlistmodel 2.1 @@ -39,49 +36,30 @@ Kirigami.Page { mainWindow.loadPlayer("",path); } - PlasmaComponents.TextField { - id: urlField - clearButtonShown: true - placeholderText: qsTr("Enter a streaming url starting with 'http://' or similar") - width: parent.width / 1.15 - height: units.gridUnit * 2 - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: header.bottom - anchors.topMargin: units.largeSpacing - } - - PlasmaComponents.ListItem { - height: units.gridUnit * 2 - width: urlField.width - anchors.margins: units.gridUnit - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: urlField.bottom - enabled: true - - IconItem { - id: openIcon - width: units.gridUnit * 2 - height: width - source: "dialog-ok" - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - margins: units.gridUnit - rightMargin: 0 - } - } + Column { + anchors.fill: parent + spacing: 50 - Heading { - id: openLbl - text: qsTr("Load Url") - elide: Text.ElideRight - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - level: 4 + TextField { + id: urlField + placeholderText: qsTr("Enter a streaming url") + width: parent.width / 1.15 + height: units.gridUnit * 2 + anchors.horizontalCenter: parent.horizontalCenter + anchors.topMargin: units.grifUnit * 2 } - - onClicked: { - openUrl(urlField.text) + + Button { + text: "Load URL" + enabled: urlField.length > 0 + height: units.gridUnit * 3 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: header.bottom + anchors.topMargin: units.gridUnit * 2 + + onClicked: { + openUrl(urlField.text) + } } } } diff --git a/qml/PlayerPage.qml b/qml/PlayerPage.qml index d12634c..7c8fe93 100644 --- a/qml/PlayerPage.qml +++ b/qml/PlayerPage.qml @@ -21,28 +21,27 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.2 +import QtQuick.Controls 2.0 as Controls import QtQuick.Window 2.1 -import QtMultimedia 5.0 +import QtMultimedia 5.7 +import org.kde.plasma.core 2.0 +import org.kde.kirigami 2.0 as Kirigami + import "helper/timeFormat.js" as TimeHelper import "helper/db.js" as DB -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 -import org.kde.kirigami 1.0 as Kirigami - Kirigami.Page { - implicitWidth: 2000 // This number is just the with of this page until it will be tiled. + implicitWidth: 5000 leftPadding: 0 rightPadding: 0 bottomPadding: 0 topPadding: 0 - + Component.onCompleted: { // Automaticly start playing videoWindow.play(); } - + onStreamUrlChanged: { // TODO: maybe youtube or other url checks videoWindow.source = streamUrl; @@ -53,13 +52,8 @@ Kirigami.Page { // Don't forgt to write it to the List aswell mainWindow.add2History(streamUrl,videoPlayerPage.text); } - + id: videoPlayerPage - title: { - if (title != "") return title - else if (streamTitle != "") return streamTitle - else return streamUrl - } property string originalUrl: mainWindow.originalUrl property string streamUrl: mainWindow.streamUrl @@ -79,7 +73,7 @@ Kirigami.Page { property bool autoplay: mainWindow.autoplay actions { - main: Action { + main: Kirigami.Action { iconName: { if (videoWindow.playbackState != MediaPlayer.PlayingState) return "media-playback-start" else return "media-playback-pause" @@ -90,15 +84,15 @@ Kirigami.Page { } shortcut: "Space" } - left: Action { + left: Kirigami.Action { iconName: "view-fullscreen" onTriggered: toggleControls() } - right: Action { + right: Kirigami.Action { iconName: "media-playback-stop" onTriggered: { - applicationWindow().pageStack.pop; videoWindow.stop(); + pageStack.pop(undefined); } } } @@ -120,14 +114,13 @@ Kirigami.Page { function showControls() { timeLine.visible = true; timeLineLbl.visible = true; - // globalDrawer.opened = true; - applicationWindow().controlsVisible = true; + controlsVisible = true; } function hideControls() { timeLine.visible = false; timeLineLbl.visible = false; - globalDrawer.opened = false; + globalDrawer.drawerOpen = false; applicationWindow().controlsVisible = false; } @@ -141,14 +134,16 @@ Kirigami.Page { Video { id: videoWindow anchors.fill: parent - onDurationChanged: timeLine.maximumValue = duration / 1000 + onDurationChanged: timeLine.to = duration / 1000 onPositionChanged: timeLine.value = position / 1000 + MouseArea { anchors.fill: parent onClicked: toggleControls() } + onStopped: showControls() - } + } Kirigami.Label { id: timeLineLbl @@ -157,11 +152,9 @@ Kirigami.Page { anchors.right: videoWindow.right } - Slider { + Controls.Slider { id: timeLine - minimumValue: 0 - value: 0 - stepSize: 1.0 + from: 1 width: parent.width onPressedChanged: { if (!pressed) { diff --git a/qml/YoutubeSearch.qml b/qml/YoutubeSearch.qml index 2bc0cf5..69aea76 100644 --- a/qml/YoutubeSearch.qml +++ b/qml/YoutubeSearch.qml @@ -24,13 +24,11 @@ import QtWebKit 3.0 import QtWebKit.experimental 1.0 import QtMultimedia 5.0 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami import "helper/yt.js" as YT -Kirigami.Page { +Kirigami.ScrollablePage { leftPadding: 0 rightPadding: 0 bottomPadding: 0 @@ -40,19 +38,17 @@ Kirigami.Page { id: searchResultsDialog property string searchTerm property bool ytDetect: true - property string websiteUrl: "http://m.youtube.com/" - property string searchUrl: "http://m.youtube.com/results?q=" + property string websiteUrl: "https://youtube.com/" + property string searchUrl: "https://m.youtube.com/results?q=" property string uA: "Mozilla/5.0 (Linux; U; Android 2.3; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" - WebView { id: ytView - anchors.centerIn: parent + anchors.fill: parent // Width and height for scale=2.0 // width: searchResultsDialog.orientation === Orientation.Portrait ? Screen.width / 2 : (Screen.height - 100) / 2 // height: Screen.height / 2 focus: true - anchors.fill: parent experimental.userAgent: uA experimental.userScripts: [Qt.resolvedUrl("helper/userscript.js")] @@ -78,30 +74,5 @@ Kirigami.Page { } Component.onCompleted: url = websiteUrl - -// Rectangle { -// anchors.left: parent.left -// anchors.bottom: parent.bottom -// visible: ytView.canGoBack -// width: parent.width / 8 -// height: parent.height / 16 -// gradient: Gradient { -// GradientStop { position: 1.0; color: "black" } -// GradientStop { position: 0.0; color: "transparent" } //Theme.highlightColor} // Black seems to look and work better -// } -// IconItem { -// id: backBtn -// source: "arrow-left" -// enabled: ytView.canGoBack -// visible: ytView.canGoBack -// anchors.centerIn: parent -// MouseArea { -// anchors.fill: parent -// onClicked: { -// ytView.goBack(); -// } -// } -// } -// } } } diff --git a/qml/main.qml b/qml/main.qml index c9d1e30..87c972d 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -21,10 +21,9 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.0 +import QtQuick.Controls 2.0 import QtQuick.Window 2.1 - -import org.kde.kirigami 1.0 as Kirigami +import org.kde.kirigami 2.0 as Kirigami import "helper/db.js" as DB @@ -36,7 +35,7 @@ Kirigami.ApplicationWindow { property string appIcon: "/usr/share/icons/hicolor/64x64/apps/vplayer.png" //TODO: use xdg somehow property string appName: "LLs vPlayer" - property string version: "0.2-plasma-mobile" + property string version: "0.2" property alias historyModel: historyModel // Settings ///////////////////////////////////////// @@ -65,43 +64,17 @@ Kirigami.ApplicationWindow { //property string homePath // Use from C++ QStandardsPath //property string videoPath - - globalDrawer: Kirigami.GlobalDrawer { - title: "Video Player" - titleIcon: "vplayer" - actions: [ - Kirigami.Action { - text: qsTr("History") - iconName: "view-list-icons" - onTriggered: applicationWindow().pageStack.replace(historyPageComponent) - }, - Kirigami.Action { - text: qsTr("Youtube Search") - iconName: "smtube" - onTriggered: applicationWindow().pageStack.replace(youtubeSearchComponent) - }, - Kirigami.Action { - text: qsTr("Open File") - iconName: "document-open" - onTriggered: applicationWindow().pageStack.replace(openDialogComponent) - }, - Kirigami.Action { - text: qsTr("Open Url") - iconName: "applications-internet" - onTriggered: applicationWindow().pageStack.replace(openUrlComponent) - }, - Kirigami.Action { - text: qsTr("About Video Player") - iconName: "help-about" - onTriggered: applicationWindow().pageStack.replace(aboutPageComponent) - } - ] + + header: Kirigami.ApplicationHeader { + preferredHeight: Kirigami.Units.gridUnit * 2.25 } - + + globalDrawer: GlobalDrawer {} + contextDrawer: Kirigami.ContextDrawer { id: contextDrawer } - + pageStack.initialPage: openDialogComponent // drawer components @@ -109,7 +82,7 @@ Kirigami.ApplicationWindow { id: historyPageComponent HistoryPage {} } - + Component { id: youtubeSearchComponent YoutubeSearch {} From 2d683408b3ee93b62ae0be53cd59bbe37bd344e2 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Fri, 10 Mar 2017 19:01:40 +0100 Subject: [PATCH 2/4] Style up ListViews --- qml/HistoryPage.qml | 18 +++++++----------- qml/OpenDialog.qml | 27 +++++---------------------- qml/PlayerPage.qml | 8 +++++++- qml/main.qml | 19 +++++++++---------- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/qml/HistoryPage.qml b/qml/HistoryPage.qml index c0aba81..daf0320 100644 --- a/qml/HistoryPage.qml +++ b/qml/HistoryPage.qml @@ -34,20 +34,16 @@ Kirigami.ScrollablePage { model: mainWindow.historyModel delegate: Kirigami.BasicListItem { - height: implicitHeight + width: parent.width + reserveSpaceForIcon: true + + icon: "video-mp4" + label: htitle onClicked: { console.debug("Clicked " + htitle + " with url: " + hurl); - mainWindow.loadPlayer(htitle,hurl) - } - - Kirigami.Label { - anchors.left: parent.left - anchors.right: parent.right - height: implicitHeight - - elide: Text.ElideRight - text: htitle + mainWindow.loadPlayer(htitle,hurl); + pageStack.pop(historyPage); } } } diff --git a/qml/OpenDialog.qml b/qml/OpenDialog.qml index 316f647..db90983 100644 --- a/qml/OpenDialog.qml +++ b/qml/OpenDialog.qml @@ -22,9 +22,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.0 -import QtQuick.Window 2.1 - -import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.core 2.0 import org.kde.kirigami 2.0 as Kirigami import Qt.labs.folderlistmodel 2.1 @@ -87,27 +85,12 @@ Kirigami.ScrollablePage { model: fileModel anchors.fill: parent - delegate: Kirigami.AbstractListItem { - id: delegate + delegate: Kirigami.BasicListItem { width: parent.width - enabled: true + reserveSpaceForIcon: true - Column { - width: parent.width - - Kirigami.Label { - anchors.left: parent.left - anchors.leftMargin: units.largeSpacing - text: fileName + (fileIsDir ? "/" : "") - } - - Kirigami.Label { - visible: !fileIsDir - anchors.left: parent.left - text: fileSize + ", " + fileModified - color: theme.linkColor - } - } + icon: (fileIsDir ? "folder" : "text-x-plain") + label: fileName + (fileIsDir ? "/" : "") onClicked: { if (fileIsDir) { diff --git a/qml/PlayerPage.qml b/qml/PlayerPage.qml index 7c8fe93..a5a77ae 100644 --- a/qml/PlayerPage.qml +++ b/qml/PlayerPage.qml @@ -36,6 +36,12 @@ Kirigami.Page { rightPadding: 0 bottomPadding: 0 topPadding: 0 + + title: { + if (title != "") return title + else if (streamTitle != "") return streamTitle + else return streamUrl + } Component.onCompleted: { // Automaticly start playing @@ -92,7 +98,7 @@ Kirigami.Page { iconName: "media-playback-stop" onTriggered: { videoWindow.stop(); - pageStack.pop(undefined); + pageStack.replace(openDialogComponent); } } } diff --git a/qml/main.qml b/qml/main.qml index 87c972d..be41e66 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -75,8 +75,6 @@ Kirigami.ApplicationWindow { id: contextDrawer } - pageStack.initialPage: openDialogComponent - // drawer components Component { id: historyPageComponent @@ -87,12 +85,12 @@ Kirigami.ApplicationWindow { id: youtubeSearchComponent YoutubeSearch {} } - + Component { id: openDialogComponent OpenDialog {} } - + Component { id: openUrlComponent OpenUrl {} @@ -102,9 +100,9 @@ Kirigami.ApplicationWindow { id: aboutPageComponent AboutPage {} } - + // components not needed for the drawer - + Component { id: playerPageComponent PlayerPage {} @@ -114,13 +112,13 @@ Kirigami.ApplicationWindow { function loadPlayer(title,url) { streamTitle = title streamUrl = url - applicationWindow().pageStack.push(playerPageComponent); + applicationWindow().pageStack.replace(playerPageComponent); } function showPlayer() { applicationWindow().pageStack.push(playerPageComponent); } - + function addHistory(url,title) { //console.debug("Adding " + url + " with title " + title); historyModel.append({"hurl": url, "htitle": title}); @@ -133,7 +131,7 @@ Kirigami.ApplicationWindow { if (title == "" || title == undefined) title = url historyModel.append({"hurl": url, "htitle": title}); } - + ListModel { id: historyModel @@ -162,10 +160,11 @@ Kirigami.ApplicationWindow { return; } } - + Component.onCompleted: { // Intitialize DB DB.initialize(); DB.getHistory(); + pageStack.push(openDialogComponent); } } From 6373d54db955aa89ad3209d986bbe23d8b1dfc2a Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Fri, 10 Mar 2017 21:54:48 +0100 Subject: [PATCH 3/4] Rework OpenUrlPage --- qml/AboutPage.qml | 18 +++++++++++------- qml/OpenDialog.qml | 4 +--- qml/OpenUrl.qml | 29 +++++++++++++++++++++-------- qml/main.qml | 2 +- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/qml/AboutPage.qml b/qml/AboutPage.qml index bf24952..996f256 100644 --- a/qml/AboutPage.qml +++ b/qml/AboutPage.qml @@ -21,7 +21,7 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.0 as Controls import org.kde.kirigami 2.0 as Kirigami Kirigami.ScrollablePage { @@ -44,12 +44,12 @@ Kirigami.ScrollablePage { } Kirigami.Heading { - text: mainWindow.appName+" v"+mainWindow.version + text: mainWindow.appName+" v" + mainWindow.version anchors.horizontalCenter: parent.horizontalCenter } Kirigami.Label { - text: qsTr("License:") + "LGPLv2" + text: qsTr("License: ") + "LGPLv2" anchors.horizontalCenter: parent.horizontalCenter } @@ -70,7 +70,7 @@ Kirigami.ScrollablePage { Kirigami.Label { width: aboutPage.width font.bold: true - text: qsTr("Copyright (c) 2014-2015 Leszek Lesner <leszek@zevenos.com>
Copyright (c) 2016 JBBGameich <jbb.mail@gmx.de>") // JBBgameich: I'm still not sure how I should write this text, maybe just "developed by Leszek Lesner, contributors: JBBgameich..." + text: qsTr("Copyright (c) 2014-2015 Leszek Lesner <leszek@zevenos.com>
Copyright (c) 2016 JBBGameich <jbb.mail@gmx.de>") anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignHCenter @@ -90,7 +90,7 @@ Kirigami.ScrollablePage { } } - Button { + Controls.ToolButton { id: homepage anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Sourcecode on Github") @@ -105,8 +105,12 @@ Kirigami.ScrollablePage { anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignHCenter - height: 200 - wrapMode: Text.WordWrap + } + + Controls.Button { + text: qsTr("Close") + anchors.horizontalCenter: parent.horizontalCenter + onClicked: pageStack.replace(openDialogComponent) } } } diff --git a/qml/OpenDialog.qml b/qml/OpenDialog.qml index db90983..1c272bb 100644 --- a/qml/OpenDialog.qml +++ b/qml/OpenDialog.qml @@ -21,10 +21,8 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 2.0 -import org.kde.plasma.core 2.0 import org.kde.kirigami 2.0 as Kirigami -import Qt.labs.folderlistmodel 2.1 +import Qt.labs.folderlistmodel 2.2 Kirigami.ScrollablePage { id: page diff --git a/qml/OpenUrl.qml b/qml/OpenUrl.qml index f7fca5c..d1e9f96 100644 --- a/qml/OpenUrl.qml +++ b/qml/OpenUrl.qml @@ -21,12 +21,11 @@ import QtQuick 2.1 import QtQuick.Layouts 1.1 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.0 as Controls import QtQuick.Window 2.1 - import org.kde.kirigami 2.0 as Kirigami import Qt.labs.folderlistmodel 2.1 - +import org.kde.plasma.core 2.0 Kirigami.Page { id: page @@ -40,21 +39,35 @@ Kirigami.Page { anchors.fill: parent spacing: 50 - TextField { + Controls.TextField { id: urlField placeholderText: qsTr("Enter a streaming url") width: parent.width / 1.15 - height: units.gridUnit * 2 anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: units.grifUnit * 2 + selectByMouse: true + + Controls.ToolButton { + height: parent.height + width: clearIcon. width + anchors.right: parent.right + + visible: urlField.length > 0 + + IconItem { + id: clearIcon + source: "edit-clear" + height: parent.height + } + + onClicked: urlField.text = ""; + } } - Button { + Controls.Button { text: "Load URL" enabled: urlField.length > 0 height: units.gridUnit * 3 anchors.horizontalCenter: parent.horizontalCenter - anchors.top: header.bottom anchors.topMargin: units.gridUnit * 2 onClicked: { diff --git a/qml/main.qml b/qml/main.qml index be41e66..b99e4d6 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -116,7 +116,7 @@ Kirigami.ApplicationWindow { } function showPlayer() { - applicationWindow().pageStack.push(playerPageComponent); + applicationWindow().pageStack.replace(playerPageComponent); } function addHistory(url,title) { From 23a67d52c3773ff32403910ef929437101db2bb6 Mon Sep 17 00:00:00 2001 From: JBBgameich Date: Sat, 11 Mar 2017 10:06:02 +0100 Subject: [PATCH 4/4] Open Videos on a new page --- qml/PlayerPage.qml | 7 +++++-- qml/main.qml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/qml/PlayerPage.qml b/qml/PlayerPage.qml index a5a77ae..c6e349f 100644 --- a/qml/PlayerPage.qml +++ b/qml/PlayerPage.qml @@ -98,7 +98,7 @@ Kirigami.Page { iconName: "media-playback-stop" onTriggered: { videoWindow.stop(); - pageStack.replace(openDialogComponent); + pageStack.pop() } } } @@ -148,7 +148,10 @@ Kirigami.Page { onClicked: toggleControls() } - onStopped: showControls() + onStopped: { + showControls() + pageStack.pop() + } } Kirigami.Label { diff --git a/qml/main.qml b/qml/main.qml index b99e4d6..113edab 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -112,11 +112,11 @@ Kirigami.ApplicationWindow { function loadPlayer(title,url) { streamTitle = title streamUrl = url - applicationWindow().pageStack.replace(playerPageComponent); + applicationWindow().pageStack.push(playerPageComponent); } function showPlayer() { - applicationWindow().pageStack.replace(playerPageComponent); + applicationWindow().pageStack.push(playerPageComponent); } function addHistory(url,title) {