1
0
Fork 0

Add keybinds and reformat code.

This commit is contained in:
NamedKitten 2018-10-16 16:55:25 +01:00
parent a4957d6219
commit 04acb4baaf

View file

@ -16,7 +16,7 @@ Window {
property int lastScreenVisibility property int lastScreenVisibility
function toggleFullscreen(){ function toggleFullscreen() {
if (mainWindow.visibility != Window.FullScreen) { if (mainWindow.visibility != Window.FullScreen) {
lastScreenVisibility = mainWindow.visibility lastScreenVisibility = mainWindow.visibility
mainWindow.visibility = Window.FullScreen mainWindow.visibility = Window.FullScreen
@ -198,7 +198,8 @@ Window {
function showControls() { function showControls() {
updateControls() updateControls()
renderer.setOption("sub-margin-y", String(controlsBar.height + progressBar.height)) renderer.setOption("sub-margin-y",
String(controlsBar.height + progressBar.height))
controlsBar.visible = true controlsBar.visible = true
controlsBackground.visible = true controlsBackground.visible = true
titleBar.visible = true titleBar.visible = true
@ -479,7 +480,6 @@ Window {
color: "red" color: "red"
border.color: "red" border.color: "red"
} }
} }
Button { Button {
@ -488,7 +488,8 @@ Window {
icon.source: "icons/prev.svg" icon.source: "icons/prev.svg"
icon.color: "white" icon.color: "white"
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
visible: false visible: false
width: 0 width: 0
onClicked: { onClicked: {
@ -506,7 +507,8 @@ Window {
icon.source: "icons/pause.svg" icon.source: "icons/pause.svg"
icon.color: "white" icon.color: "white"
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: playlistPrevButton.right anchors.left: playlistPrevButton.right
onClicked: { onClicked: {
updatePlayPause() updatePlayPause()
@ -522,7 +524,8 @@ Window {
icon.source: "icons/next.svg" icon.source: "icons/next.svg"
icon.color: "white" icon.color: "white"
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: playPauseButton.right anchors.left: playPauseButton.right
onClicked: { onClicked: {
renderer.command(["playlist-next", "force"]) renderer.command(["playlist-next", "force"])
@ -538,7 +541,8 @@ Window {
icon.source: "icons/volume-up.svg" icon.source: "icons/volume-up.svg"
icon.color: "white" icon.color: "white"
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: playlistNextButton.right anchors.left: playlistNextButton.right
onClicked: { onClicked: {
renderer.command(["cycle", "mute"]) renderer.command(["cycle", "mute"])
@ -604,7 +608,8 @@ Window {
text: "0:00 / 0:00" text: "0:00 / 0:00"
color: "white" color: "white"
anchors.left: volumeBar.right anchors.left: volumeBar.right
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
padding: 5 padding: 5
font.family: notoFont.name font.family: notoFont.name
font.pixelSize: 12 font.pixelSize: 12
@ -618,7 +623,8 @@ Window {
icon.source: "icons/subtitles.svg" icon.source: "icons/subtitles.svg"
icon.color: "white" icon.color: "white"
anchors.right: settingsButton.left anchors.right: settingsButton.left
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
tracksMenuUpdate() tracksMenuUpdate()
@ -637,7 +643,8 @@ Window {
icon.color: "white" icon.color: "white"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
anchors.right: fullscreenButton.left anchors.right: fullscreenButton.left
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
loadDialog.open() loadDialog.open()
@ -654,7 +661,8 @@ Window {
icon.color: "white" icon.color: "white"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top; anchors.bottom: parent.bottom; anchors.top: parent.top
anchors.bottom: parent.bottom
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
toggleFullscreen() toggleFullscreen()
@ -667,5 +675,20 @@ Window {
//} //}
} }
Item {
anchors.fill: parent
focus: true
Keys.onPressed: {
if (event.key == Qt.Key_K || event.key == Qt.Key_Space) {
renderer.command(["cycle", "pause"])
} else if (event.key == Qt.Key_J) {
renderer.command(["seek", "-10"])
} else if (event.key == Qt.Key_L) {
renderer.command(["seek", "10"])
}
updateControls()
}
}
} }
} }