From 0b84a6e6b648658ead59c86e4ece882247fd612c Mon Sep 17 00:00:00 2001 From: Anika Raemer Date: Thu, 6 Dec 2018 12:46:46 +0100 Subject: [PATCH] styled progress bar; moved to correct position still todo: show time and lenght as formatted number refactor MusicPlayer.qml into components --- LenaPi/MusicPlayer.qml | 163 ++++++++++++++++++----------------- LenaPi/models/MusicModel.cpp | 9 +- 2 files changed, 88 insertions(+), 84 deletions(-) diff --git a/LenaPi/MusicPlayer.qml b/LenaPi/MusicPlayer.qml index 47d0545..46409d6 100644 --- a/LenaPi/MusicPlayer.qml +++ b/LenaPi/MusicPlayer.qml @@ -40,37 +40,6 @@ Item{ } } - ProgressBar{ - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: container.margins - /*anchors.bottom: buttons.top - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: 40 - anchors.rightMargin: 40 - anchors.topMargin: 10 - anchors.bottomMargin: 10 - */ - z:99 - - value: musicModel.pProgress - style:ProgressBarStyle { - background: Rectangle { - radius: 2 - color: "magenta" - border.color: "gray" - border.width: 1 - implicitWidth: 200 - implicitHeight: 24 - } - progress: Rectangle { - color: "lightsteelblue" - border.color: "steelblue" - } - } - } - Rectangle { id: controlPannel @@ -78,63 +47,95 @@ Item{ anchors.right: parent.right anchors.bottom: parent.bottom color: "#99ffffff" - height: 120 + height: 140 - Row{ - id: buttons - spacing: 20 - anchors.centerIn: parent + ProgressBar{ + id: progress + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: container.margins - RoundButton{ - id: previous - anchors.verticalCenter: parent.verticalCenter + value: musicModel.pProgress - width: 60 - imageSource: "qrc:/icon_previous" - - enabled: musicModel.pHasPrevious - - onClicked:{ - musicModel.playPrevious(); + style:ProgressBarStyle { + background: Rectangle { + radius: 5 + color: "lightgrey" + border.color: "grey" + border.width: 1 + implicitWidth: controlPannel.width - 2*container.margins + implicitHeight: 10 } - } - RoundButton{ - id: playPause - anchors.verticalCenter: parent.verticalCenter - width: 80 - imageSource: musicModel.pIsPlaying ? "qrc:/icon_pause" : "qrc:/icon_play" - - onClicked:{ - musicModel.playPause(); - } - } - RoundButton{ - id: stop - anchors.verticalCenter: parent.verticalCenter - - width: 60 - imageSource: "qrc:/icon_stop" - - enabled: musicModel.pIsPlaying - - onClicked:{ - musicModel.stopMusic(); - } - } - RoundButton{ - id: next - anchors.verticalCenter: parent.verticalCenter - - width: 60 - imageSource: "qrc:/icon_next" - - enabled: musicModel.pHasNext - - onClicked:{ - musicModel.playNext(); + progress: Rectangle { + color: "blue" + border.color: "blue" + radius: 5 + implicitHeight: 8 } } } + + Item{ + anchors.left: parent.left + anchors.right: parent.right + anchors.top: progress.bottom + anchors.bottom: parent.bottom + Row{ + id: buttons + spacing: 20 + anchors.centerIn: parent + + RoundButton{ + id: previous + anchors.verticalCenter: parent.verticalCenter + + width: 60 + imageSource: "qrc:/icon_previous" + + enabled: musicModel.pHasPrevious + + onClicked:{ + musicModel.playPrevious(); + } + } + RoundButton{ + id: playPause + anchors.verticalCenter: parent.verticalCenter + width: 80 + imageSource: musicModel.pIsPlaying ? "qrc:/icon_pause" : "qrc:/icon_play" + + onClicked:{ + musicModel.playPause(); + } + } + RoundButton{ + id: stop + anchors.verticalCenter: parent.verticalCenter + + width: 60 + imageSource: "qrc:/icon_stop" + + enabled: musicModel.pIsPlaying + + onClicked:{ + musicModel.stopMusic(); + } + } + RoundButton{ + id: next + anchors.verticalCenter: parent.verticalCenter + + width: 60 + imageSource: "qrc:/icon_next" + + enabled: musicModel.pHasNext + + onClicked:{ + musicModel.playNext(); + } + } + } //Row + }// Item } } diff --git a/LenaPi/models/MusicModel.cpp b/LenaPi/models/MusicModel.cpp index 59973c6..f3d328d 100644 --- a/LenaPi/models/MusicModel.cpp +++ b/LenaPi/models/MusicModel.cpp @@ -62,13 +62,16 @@ void MusicModel::stopMusic() { if(mIsPlaying){ mIsPlaying = false; + emit isPlayingChanged(); + mHasNext = false; mHasPrevious = false; - mCurrentMediaItemProgress = 0.0; - emit progressChanged(); emit hasNextChanged(); emit hasPreviousChanged(); - emit isPlayingChanged(); + + mCurrentMediaItemProgress = 0.0; + emit progressChanged(); + emit stop(); } }