diff --git a/src/qml/HeaderBar.qml b/src/qml/HeaderBar.qml index 8d446772..98edfaa0 100644 --- a/src/qml/HeaderBar.qml +++ b/src/qml/HeaderBar.qml @@ -75,12 +75,7 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } - onClicked: { - if(AudioManager.playbackRate === 2.5) - AudioManager.playbackRate = 1 - else - AudioManager.playbackRate = AudioManager.playbackRate + 0.25 - } + onClicked: playbackDialog.open() flat: true Layout.alignment: Qt.AlignHCenter padding: 0 diff --git a/src/qml/Playback.qml b/src/qml/Playback.qml new file mode 100644 index 00000000..a3891ca5 --- /dev/null +++ b/src/qml/Playback.qml @@ -0,0 +1,135 @@ +/** + * SPDX-FileCopyrightText: 2021 Swapnil Tripathi + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +import QtQuick 2.14 +import QtQuick.Controls 2.14 as Controls +import QtQuick.Layouts 1.14 + +import org.kde.kirigami 2.14 as Kirigami +import org.kde.kasts 1.0 + +Loader { + sourceComponent: !Kirigami.Settings.isMobile ? widescreenComponent : narrowComponent + + function open() { + item.open(); + } + ListModel { + id: playbackRateModel + ListElement { + name: "0.50x" + value: 0.50 + } + ListElement { + name: "0.75x" + value: 0.75 + } + ListElement { + name: "1x" + value: 1 + } + ListElement { + name: "1.25x" + value: 1.25 + } + ListElement { + name: "1.50x" + value: 1.50 + } + ListElement { + name: "1.75x" + value: 1.75 + } + ListElement { + name: "2x" + value: 2 + } + ListElement { + name: "2.25x" + value: 2.25 + } + ListElement { + name: "2.5x" + value: 2.5 + } + } + + Component { + id: widescreenComponent + Kirigami.OverlaySheet { + id: listViewSheet + header: Kirigami.Heading { + text: qsTr("Set Playback Rate") + } + ListView { + id: playbackRateList + model: playbackRateModel + implicitWidth: Kirigami.Units.gridUnit * 12 + delegate: Kirigami.SwipeListItem { + id: swipeDelegate + Controls.Label { + text: name + } + onClicked: { + AudioManager.playbackRate = value; + close(); + } + } + } + } + } + + Component { + id: narrowComponent + Kirigami.OverlayDrawer { + id: drawer + height: parent.height / 2 + edge: Qt.BottomEdge + z: -1 + + Behavior on height { + NumberAnimation { duration: Kirigami.Units.shortDuration } + } + + contentItem: ColumnLayout { + id: contents + spacing: 0 + + Kirigami.Icon { + Layout.margins: Kirigami.Units.smallSpacing + source: "arrow-down" + implicitWidth: Kirigami.Units.gridUnit + implicitHeight: Kirigami.Units.gridUnit + Layout.alignment: Qt.AlignHCenter + } + + Kirigami.Heading { + level: 3 + text: i18n("Set Playback Rate") + Layout.alignment: Qt.AlignHCenter + Layout.bottomMargin: Kirigami.Units.largeSpacing * 2 + } + Controls.ScrollView { + Layout.fillWidth: true + Layout.fillHeight: true + ListView { + id: playbackRateList + model: playbackRateModel + delegate: Kirigami.SwipeListItem { + contentItem: Controls.Label { + text: model.name + } + onClicked: { + AudioManager.playbackRate = value; + close(); + } + } + } + } + } + } + } +} diff --git a/src/qml/PlayerControls.qml b/src/qml/PlayerControls.qml index bbb72159..c598fb29 100644 --- a/src/qml/PlayerControls.qml +++ b/src/qml/PlayerControls.qml @@ -195,10 +195,7 @@ Kirigami.Page { verticalAlignment: Text.AlignVCenter } onClicked: { - if(AudioManager.playbackRate === 2.5) - AudioManager.playbackRate = 1 - else - AudioManager.playbackRate = AudioManager.playbackRate + 0.25 + playbackDialog.open() } flat: true Layout.alignment: Qt.AlignHCenter diff --git a/src/qml/main.qml b/src/qml/main.qml index d5938d2e..3c64380d 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -277,4 +277,7 @@ Kirigami.ApplicationWindow { action(); } } + Playback { + id: playbackDialog + } } diff --git a/src/resources.qrc b/src/resources.qrc index f4128146..07445486 100755 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -24,6 +24,7 @@ qml/ImageWithFallback.qml qml/UpdateNotification.qml qml/HeaderBar.qml + qml/Playback.qml qml/ErrorNotification.qml qml/ConnectionCheckAction.qml qtquickcontrols2.conf