Refactor Media Control Keys QML into smaller bits

The old QML was a giant mess of implementation details and logic.
Reducing the buttons to only 2 essential properties allows the
MediaControllerKeys object to be more easily understood.

Moving the MediaControllerKeys into its own QML file allows the
resulting page to be more easily understood and individual pieces
swapped in and out.

The current QML directory structure is non-existent, breaking parts down
into cohesive folders will allow for easier understanding of the bigger
picture.
This commit is contained in:
Vasily
2019-01-13 16:47:38 +01:00
parent e75a4c2353
commit f5000a0ee0
5 changed files with 137 additions and 148 deletions
@@ -0,0 +1,80 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import matzman666.advsettings 1.0
// Necessary for the project specific Components.
import ".."
GroupBox {
id: mediaKeysGroupBox
Layout.fillWidth: true
label: MyText {
leftPadding: 10
text: "Media Control Keys"
bottomPadding: -10
}
background: Rectangle {
color: "transparent"
border.color: "#ffffff"
radius: 8
}
ColumnLayout {
anchors.fill: parent
LineSeparator {
}
RowLayout {
property bool playButtonIsPlay: false
property string playButtonPath: "outline_play_arrow_white_24dp.svg"
property string pauseButtonPath: "outline_pause_white_24dp.svg"
property string stopButtonPath: "outline_stop_white_24dp.svg"
property string previousButtonPath: "outline_skip_previous_white_24dp.svg"
property string nextButtonPath: "outline_skip_next_white_24dp.svg"
MediaButton {
id: previousSongButton
imagePath: parent.previousButtonPath
onClicked: {
UtilitiesTabController.sendMediaPreviousSong()
}
}
MediaButton {
id: stopSongButton
imagePath: parent.stopButtonPath
onClicked: {
UtilitiesTabController.sendMediaStopSong()
playPauseSongButton.contentItem.source = parent.playButtonPath
parent.playButtonIsPlay = true
}
}
MediaButton {
id: playPauseSongButton
imagePath: parent.pauseButtonPath
onClicked: {
UtilitiesTabController.sendMediaPausePlay()
if (parent.playButtonIsPlay) {
playPauseSongButton.contentItem.source = parent.pauseButtonPath
parent.playButtonIsPlay = false
} else {
playPauseSongButton.contentItem.source = parent.playButtonPath
parent.playButtonIsPlay = true
}
}
}
MediaButton {
id: nextSongButton
imagePath: parent.nextButtonPath
onClicked: {
UtilitiesTabController.sendMediaNextSong()
}
}
}
}
}