Skip to content

Commit

Permalink
Merge pull request #66 from neochapay/master
Browse files Browse the repository at this point in the history
[Statusbar] Add media controller panel
  • Loading branch information
locusf authored Nov 16, 2017
2 parents a15c1f8 + 5671182 commit 3eb6ebd
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 3 deletions.
1 change: 1 addition & 0 deletions rpm/lipstick-glacier-home-qt5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Requires: connman-qt5
Requires: libqofono-qt5-declarative
Requires: nemo-theme-glacier
Requires: google-opensans-fonts
Requires: mpris-qt5-qml-plugin

BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Quick)
Expand Down
14 changes: 13 additions & 1 deletion src/qml/Statusbar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
import org.freedesktop.contextkit 1.0
import MeeGo.Connman 0.2

import org.nemomobile.lipstick 0.1
import org.nemomobile.mpris 1.0

import "statusbar"

Expand Down Expand Up @@ -289,9 +291,19 @@ Item {
iconSize: Theme.itemHeightExtraSmall
source: "image://theme/icon_gps_normal"
}

StatusbarItem {
MprisManager {
id: mprisManager
}
property bool isPlaying: mprisManager.currentService && mprisManager.playbackStatus == Mpris.Playing

iconSize: Theme.itemHeightExtraSmall
source: "image://theme/icon_play_pause"
source: isPlaying ?
"image://theme/pause"
: "image://theme/play"

panel: MediaController{}
}
StatusbarItem {
iconSize: root.height
Expand Down
4 changes: 3 additions & 1 deletion src/qml/statusbar/CommonPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Rectangle {
id: commonPanel

property alias switcherEnabled: columnCheckBox.enabled
property bool settingsIconEnabled: true

property alias switcherChecked: columnCheckBox.checked
property string name: ""
signal click
Expand Down Expand Up @@ -120,7 +122,7 @@ Rectangle {
id:settingsIcon
fillMode: Image.PreserveAspectFit
height: Theme.itemHeightMedium
visible: parent.height > Theme.itemSpacingMedium
visible: settingsIconEnabled && parent.height > Theme.itemSpacingMedium
source: "image://theme/icon-app-settings" //maybe better icon? settings.png from statusbar spec
anchors{
right: parent.right
Expand Down
136 changes: 136 additions & 0 deletions src/qml/statusbar/MediaController.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/****************************************************************************************
**
** Copyright (C) 2017 Sergey Chupligin <[email protected]>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/


import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Layouts 1.0

import org.nemomobile.mpris 1.0

Component {
id: mediaPanelItem
CommonPanel {
id: mediaPanelcommon
switcherEnabled: false
settingsIconEnabled: false

property bool isPlaying: mprisManager.currentService && mprisManager.playbackStatus == Mpris.Playing

Item{
width: parent.width
height: parent.height

Label{
id: trackName
width: parent.width
text: if (mprisManager.currentService) {
var artistTag = Mpris.metadataToString(Mpris.Artist)
var titleTag = Mpris.metadataToString(Mpris.Title)

var artistLabel = (artistTag in mprisManager.metadata) ? mprisManager.metadata[artistTag].toString() : "";
var titleLabel = (titleTag in mprisManager.metadata) ? mprisManager.metadata[titleTag].toString() : ""

return artistLabel+"\n"+titleLabel

}else{
return qsTr("No music playing")
}
horizontalAlignment: Text.AlignHCenter
}


Image{
id: backBtn
width: playPause.width*0.6
height: width
visible: mprisManager.currentService

anchors{
right: playPause.left
rightMargin: width/2
verticalCenter: playPause.verticalCenter
}

MouseArea{
anchors.fill: parent
onClicked: if (mprisManager.canGoPrevious) mprisManager.previous()
}

source: "image://theme/backward"
}

Image{
id: playPause
width: Theme.itemHeightHuge
height: width
visible: mprisManager.currentService

anchors{
horizontalCenter: parent.horizontalCenter
top: trackName.bottom
topMargin: Theme.itemSpacingLarge
}

source: isPlaying ?
"image://theme/pause" :
"image://theme/play"

MouseArea{
anchors.fill: parent
onClicked: (isPlaying)? mprisManager.pause() : mprisManager.play()
}
}

Image{
id: forwBtn
width: playPause.width*0.6
height: width
visible: mprisManager.currentService

anchors{
left: playPause.right
leftMargin: width/2
verticalCenter: playPause.verticalCenter
}

source: "image://theme/forward"

MouseArea{
anchors.fill: parent
onClicked: if (mprisManager.canGoNext) mprisManager.next()
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ statusbar.files = qml/statusbar/BatteryPanel.qml\
qml/statusbar/SimPanel.qml\
qml/statusbar/WifiPanel.qml\
qml/statusbar/StatusbarItem.qml\
qml/statusbar/NumButton.qml
qml/statusbar/NumButton.qml \
qml/statusbar/MediaController.qml

INSTALLS += styles \
images \
Expand Down

0 comments on commit 3eb6ebd

Please sign in to comment.