Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Workspace
Commits
0eac817d
Commit
0eac817d
authored
Nov 15, 2020
by
Mikel Johnson
Committed by
Noah Davis
Nov 15, 2020
Browse files
[Media Controller] Add shuffle and loop controls
Co-authored-by:
Kai Uwe Broulik
<
kde@privat.broulik.de
>
parent
6193e2b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
applets/mediacontroller/contents/ui/ExpandedRepresentation.qml
View file @
0eac817d
...
...
@@ -32,12 +32,12 @@ import QtGraphicalEffects 1.0
PlasmaComponents3.Page
{
id
:
expandedRepresentation
Layout.minimumWidth
:
u
nits
.
gridUnit
*
14
Layout.minimumHeight
:
u
nits
.
gridUnit
*
14
Layout.minimumWidth
:
PlasmaCore
.
U
nits
.
gridUnit
*
14
Layout.minimumHeight
:
PlasmaCore
.
U
nits
.
gridUnit
*
14
Layout.preferredWidth
:
Layout
.
minimumWidth
*
1.5
Layout.preferredHeight
:
Layout
.
minimumHeight
*
1.5
readonly
property
int
controlSize
:
u
nits
.
iconSizes
.
medium
readonly
property
int
controlSize
:
PlasmaCore
.
U
nits
.
iconSizes
.
medium
property
double
position
:
mpris2Source
.
currentData
.
Position
||
0
readonly
property
real
rate
:
mpris2Source
.
currentData
.
Rate
||
1
...
...
@@ -172,11 +172,11 @@ PlasmaComponents3.Page {
anchors
{
fill
:
parent
leftMargin
:
u
nits
.
largeSpacing
rightMargin
:
u
nits
.
largeSpacing
leftMargin
:
PlasmaCore
.
U
nits
.
largeSpacing
rightMargin
:
PlasmaCore
.
U
nits
.
largeSpacing
}
spacing
:
u
nits
.
largeSpacing
spacing
:
PlasmaCore
.
U
nits
.
largeSpacing
Item
{
Layout.fillWidth
:
true
...
...
@@ -209,7 +209,7 @@ PlasmaComponents3.Page {
anchors
{
fill
:
parent
margins
:
u
nits
.
largeSpacing
*
2
margins
:
PlasmaCore
.
U
nits
.
largeSpacing
*
2
}
}
}
...
...
@@ -239,7 +239,7 @@ PlasmaComponents3.Page {
text
:
root
.
track
||
i18n
(
"
No media playing
"
)
Layout.fillWidth
:
true
Layout.maximumHeight
:
u
nits
.
gridUnit
*
5
Layout.maximumHeight
:
PlasmaCore
.
U
nits
.
gridUnit
*
5
}
Kirigami.Heading
{
// Song Artist
id
:
songArtist
...
...
@@ -255,7 +255,7 @@ PlasmaComponents3.Page {
text
:
root
.
artist
Layout.fillWidth
:
true
Layout.maximumHeight
:
u
nits
.
gridUnit
*
2
Layout.maximumHeight
:
PlasmaCore
.
U
nits
.
gridUnit
*
2
}
Kirigami.Heading
{
// Song Album
color
:
(
softwareRendering
||
!
albumArt
.
visible
)
?
PlasmaCore
.
ColorScope
.
textColor
:
"
white
"
...
...
@@ -302,7 +302,7 @@ PlasmaComponents3.Page {
return
""
}
Layout.fillWidth
:
true
Layout.maximumHeight
:
u
nits
.
gridUnit
*
2
Layout.maximumHeight
:
PlasmaCore
.
U
nits
.
gridUnit
*
2
}
}
}
...
...
@@ -314,18 +314,18 @@ PlasmaComponents3.Page {
ColumnLayout
{
// Main Column Layout
anchors.fill
:
parent
RowLayout
{
// Seek Bar
spacing
:
u
nits
.
smallSpacing
spacing
:
PlasmaCore
.
U
nits
.
smallSpacing
// if there's no "mpris:length" in the metadata, we cannot seek, so hide it in that case
enabled
:
!
root
.
noPlayer
&&
root
.
track
&&
expandedRepresentation
.
length
>
0
?
true
:
false
opacity
:
enabled
?
1
:
0
Behavior
on
opacity
{
NumberAnimation
{
duration
:
u
nits
.
longDuration
}
NumberAnimation
{
duration
:
PlasmaCore
.
U
nits
.
longDuration
}
}
Layout.alignment
:
Qt
.
AlignHCenter
Layout.fillWidth
:
true
Layout.maximumWidth
:
Math
.
min
(
u
nits
.
gridUnit
*
45
,
Math
.
round
(
expandedRepresentation
.
width
*
(
7
/
10
)))
Layout.maximumWidth
:
Math
.
min
(
PlasmaCore
.
U
nits
.
gridUnit
*
45
,
Math
.
round
(
expandedRepresentation
.
width
*
(
7
/
10
)))
// ensure the layout doesn't shift as the numbers change and measure roughly the longest text that could occur with the current song
TextMetrics
{
...
...
@@ -417,7 +417,28 @@ PlasmaComponents3.Page {
Layout.alignment
:
Qt
.
AlignHCenter
Layout.bottomMargin
:
PlasmaCore
.
Units
.
smallSpacing
spacing
:
units
.
smallSpacing
spacing
:
PlasmaCore
.
Units
.
smallSpacing
PlasmaComponents3.ToolButton
{
Layout.rightMargin
:
LayoutMirroring
.
enabled
?
0
:
PlasmaCore
.
Units
.
largeSpacing
-
playerControls
.
spacing
Layout.leftMargin
:
LayoutMirroring
.
enabled
?
PlasmaCore
.
Units
.
largeSpacing
-
playerControls
.
spacing
:
0
icon.name
:
"
media-playlist-shuffle
"
icon.width
:
expandedRepresentation
.
controlSize
icon.height
:
icon
.
width
checked
:
root
.
shuffle
===
true
enabled
:
root
.
canControl
&&
root
.
shuffle
!==
undefined
Accessible.name
:
i18n
(
"
Shuffle
"
)
onClicked
:
{
const
service
=
mpris2Source
.
serviceForSource
(
mpris2Source
.
current
);
let
operation
=
service
.
operationDescription
(
"
SetShuffle
"
);
operation
.
on
=
!
root
.
shuffle
;
service
.
startOperationCall
(
operation
);
}
PlasmaComponents3.ToolTip
{
text
:
parent
.
Accessible
.
name
}
}
PlasmaComponents3.ToolButton
{
// Previous
icon.width
:
expandedRepresentation
.
controlSize
...
...
@@ -451,6 +472,36 @@ PlasmaComponents3.Page {
root
.
action_next
()
}
}
PlasmaComponents3.ToolButton
{
Layout.leftMargin
:
LayoutMirroring
.
enabled
?
0
:
PlasmaCore
.
Units
.
largeSpacing
-
playerControls
.
spacing
Layout.rightMargin
:
LayoutMirroring
.
enabled
?
PlasmaCore
.
Units
.
largeSpacing
-
playerControls
.
spacing
:
0
icon.name
:
root
.
loopStatus
===
"
Track
"
?
"
media-playlist-repeat-song
"
:
"
media-playlist-repeat
"
icon.width
:
expandedRepresentation
.
controlSize
icon.height
:
icon
.
width
checked
:
root
.
loopStatus
!==
undefined
&&
root
.
loopStatus
!==
"
None
"
enabled
:
root
.
canControl
&&
root
.
loopStatus
!==
undefined
Accessible.name
:
root
.
loopStatus
===
"
Track
"
?
i18n
(
"
Repeat Track
"
)
:
i18n
(
"
Repeat
"
)
onClicked
:
{
const
service
=
mpris2Source
.
serviceForSource
(
mpris2Source
.
current
);
let
operation
=
service
.
operationDescription
(
"
SetLoopStatus
"
);
switch
(
root
.
loopStatus
)
{
case
"
Playlist
"
:
operation
.
status
=
"
Track
"
;
break
;
case
"
Track
"
:
operation
.
status
=
"
None
"
;
break
;
default
:
operation
.
status
=
"
Playlist
"
;
}
service
.
startOperationCall
(
operation
);
}
PlasmaComponents3.ToolTip
{
text
:
parent
.
Accessible
.
name
}
}
}
}
}
...
...
@@ -458,13 +509,27 @@ PlasmaComponents3.Page {
header
:
PlasmaExtras.PlasmoidHeading
{
id
:
headerItem
location
:
PlasmaExtras
.
PlasmoidHeading
.
Location
.
Header
visible
:
playerList
.
model
.
length
>
2
// more than one player, @multiplex is always there
visible
:
playerList
.
model
.
length
>
1
//this removes top padding to allow tabbar to touch the edge
topPadding
:
topInset
bottomPadding
:
-
bottomInset
implicitHeight
:
PlasmaCore
.
Units
.
gridUnit
*
2
PlasmaExtras.Heading
{
// Song Title
anchors.fill
:
parent
anchors.leftMargin
:
PlasmaCore
.
Units
.
smallSpacing
level
:
2
textFormat
:
Text
.
PlainText
fontSizeMode
:
Text
.
VerticalFit
elide
:
Text
.
ElideRight
text
:
root
.
identity
visible
:
playerList
.
count
<=
2
}
PlasmaComponents3.TabBar
{
id
:
playerSelector
visible
:
playerList
.
model
.
length
>
2
// more than one player, @multiplex is always there
position
:
PlasmaComponents3
.
TabBar
.
Header
anchors.fill
:
parent
...
...
applets/mediacontroller/contents/ui/main.qml
View file @
0eac817d
...
...
@@ -78,8 +78,14 @@ Item {
readonly
property
bool
canPlay
:
(
canControl
&&
mpris2Source
.
currentData
.
CanPlay
)
||
false
readonly
property
bool
canPause
:
(
canControl
&&
mpris2Source
.
currentData
.
CanPause
)
||
false
Plasmoid.switchWidth
:
units
.
gridUnit
*
14
Plasmoid.switchHeight
:
units
.
gridUnit
*
10
// var instead of bool so we can use "undefined" for "shuffle not supported"
readonly
property
var
shuffle
:
!
root
.
noPlayer
&&
typeof
mpris2Source
.
currentData
.
Shuffle
===
"
boolean
"
?
mpris2Source
.
currentData
.
Shuffle
:
undefined
readonly
property
var
loopStatus
:
!
root
.
noPlayer
&&
typeof
mpris2Source
.
currentData
.
LoopStatus
===
"
string
"
?
mpris2Source
.
currentData
.
LoopStatus
:
undefined
Plasmoid.switchWidth
:
PlasmaCore
.
Units
.
gridUnit
*
14
Plasmoid.switchHeight
:
PlasmaCore
.
Units
.
gridUnit
*
10
Plasmoid.icon
:
"
media-playback-playing
"
Plasmoid.toolTipMainText
:
i18n
(
"
No media playing
"
)
Plasmoid.toolTipSubText
:
identity
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment