Commit e680ff58 authored by Carson Black's avatar Carson Black 🍿

[applets/mediacontroller] Visually refresh media controller plasmoid

Summary:
The media controller has been adjusted visually. Note that this is marked as WIP due to the fact that the system tray displays margins around the applet, which doesn't look too good.
Co-authored-by: Ismael Asensio's avatarIsmael Asensio <isma.af@gmail.com>

Depends on D28089

Test Plan:
Before:
{F8085938}
After:
{F8089034}

Reviewers: #vdg, #plasma, manueljlin, ngraham, broulik!

Reviewed By: #vdg, #plasma, ngraham

Subscribers: kmaterka, iasensio, ndavis, broulik, gvgeo, davidedmundson, ngraham, manueljlin, plasma-devel

Tags: #plasma

Maniphest Tasks: T10470

Differential Revision: https://phabricator.kde.org/D27160
parent f6e34fe0
/***************************************************************************
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
* Copyright 2014 Kai Uwe Broulik <kde@privat.broulik.de> *
* Copyright 2020 Ismael Asensio <isma.af@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
......@@ -70,6 +71,8 @@ Item {
property bool noPlayer: mpris2Source.sources.length <= 1
property var mprisSourcesModel: []
readonly property bool canControl: (!root.noPlayer && mpris2Source.currentData.CanControl) || false
readonly property bool canGoPrevious: (canControl && mpris2Source.currentData.CanGoPrevious) || false
readonly property bool canGoNext: (canControl && mpris2Source.currentData.CanGoNext) || false
......@@ -205,18 +208,24 @@ Item {
readonly property var currentData: data[current]
engine: "mpris2"
connectedSources: current
connectedSources: sources
onSourceAdded: {
updateMprisSourcesModel()
}
onSourceRemoved: {
// if player is closed, reset to multiplex source
if (source === current) {
current = multiplexSource
}
updateMprisSourcesModel()
}
}
Component.onCompleted: {
mpris2Source.serviceForSource("@multiplex").enableGlobalShortcuts();
mpris2Source.serviceForSource("@multiplex").enableGlobalShortcuts()
updateMprisSourcesModel()
}
function togglePlaying() {
......@@ -268,6 +277,31 @@ Item {
return service.startOperationCall(operation);
}
function updateMprisSourcesModel () {
var model = [{
'text': i18n("Choose player automatically"),
'icon': 'emblem-favorite',
'source': mpris2Source.multiplexSource
}]
var sources = mpris2Source.sources
for (var i = 0, length = sources.length; i < length; ++i) {
var source = sources[i]
if (source === mpris2Source.multiplexSource) {
continue
}
model.push({
'text': mpris2Source.data[source]["Identity"],
'icon': mpris2Source.data[source]["Desktop Icon Name"] || mpris2Source.data[source]["Desktop Entry"] || source,
'source': source
});
}
root.mprisSourcesModel = model;
}
states: [
State {
name: "playing"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment