1
0
Fork 0

Tidy up some things, ACTUALLY fix #14 finally.

This commit is contained in:
namedkitten 2020-04-23 15:10:48 +01:00
parent 0ef0537a31
commit 9b537bc9f5
7 changed files with 163 additions and 155 deletions

View file

@ -17,6 +17,18 @@ Item {
property var progress: progressBar property var progress: progressBar
property var controls: controlsBar property var controls: controlsBar
property var duration: progressBar.to property var duration: progressBar.to
property bool controlsShowing: true
Connections {
target: globalConnections
onHideUI: function(force) {
controlsBarItem.controlsShowing=false
}
onShowUI: {
controlsBarItem.controlsShowing=true
}
}
Component.onCompleted: { Component.onCompleted: {
setControlsTheme(appearance.themeName) setControlsTheme(appearance.themeName)
@ -103,6 +115,17 @@ Item {
} }
} }
VideoProgress {
id: progressBar
visible: controlsBarItem.controlsShowing && (appearance.themeName == "RoosterTeeth" ? false : true)
anchors.bottom: controlsBackground.top
anchors.left: controlsBackground.left
anchors.right: controlsBackground.right
anchors.bottomMargin: 0
bottomPadding: 0
z: 20
}
Rectangle { Rectangle {
id: controlsBackground id: controlsBackground
height: controlsBar.visible ? controlsBar.height height: controlsBar.visible ? controlsBar.height
@ -115,7 +138,8 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
color: getAppearanceValueForTheme(appearance.themeName, color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground") "mainBackground")
visible: controlsOverlay.controlsShowing visible: controlsBarItem.controlsShowing
z: 10
} }
Item { Item {
@ -127,15 +151,7 @@ Item {
anchors.leftMargin: parent.width / 128 anchors.leftMargin: parent.width / 128
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 0 anchors.bottomMargin: 0
visible: controlsOverlay.controlsShowing visible: controlsBarItem.controlsShowing
VideoProgress { z: 30
id: progressBar
visible: appearance.themeName == "RoosterTeeth" ? false : true
anchors.bottom: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottomMargin: 0
bottomPadding: 0
}
} }
} }

View file

@ -83,22 +83,6 @@ MenuBar {
} }
} }
LabsPlatform.FileDialog {
id: screenshotSaveDialog
title: translate.getTranslation("SAVE_SCREENSHOT", i18n.language)
fileMode: LabsPlatform.FileDialog.SaveFile
defaultSuffix: "png"
nameFilters: ["Images (*.png)", "All files (*)"]
onAccepted: {
player.grabToImage(function (result) {
var filepath = String(screenshotSaveDialog.file).replace(
"file://", '')
result.saveToFile(filepath)
subtitlesBar.visible = appearance.useMpvSubs ? false : true
})
}
}
LabsPlatform.FileDialog { LabsPlatform.FileDialog {
id: fileDialog id: fileDialog
title: translate.getTranslation("OPEN_FILE", i18n.language) title: translate.getTranslation("OPEN_FILE", i18n.language)
@ -185,31 +169,6 @@ MenuBar {
onTriggered: loadDialog.open() onTriggered: loadDialog.open()
shortcut: keybinds.openURI shortcut: keybinds.openURI
} }
Action {
text: translate.getTranslation("SCREENSHOT", i18n.language)
onTriggered: {
player.hideControls(true)
screenshotSaveDialog.open()
}
shortcut: keybinds.screenshot
}
Action {
text: translate.getTranslation("SCREENSHOT_WITHOUT_SUBTITLES",
i18n.language)
onTriggered: {
player.hideControls(true)
subtitlesBar.visible = false
screenshotSaveDialog.open()
}
shortcut: keybinds.screenshotWithoutSubtitles
}
Action {
text: translate.getTranslation("FULL_SCREENSHOT", i18n.language)
onTriggered: {
screenshotSaveDialog.open()
}
shortcut: keybinds.fullScreenshot
}
Action { Action {
text: translate.getTranslation("EXIT", i18n.language) text: translate.getTranslation("EXIT", i18n.language)
onTriggered: Qt.quit() onTriggered: Qt.quit()

View file

@ -75,11 +75,14 @@ Item {
id: videoProgressRoosterTeeth id: videoProgressRoosterTeeth
anchors.left: timeLabel.right anchors.left: timeLabel.right
anchors.right: speedText.left anchors.right: speedText.left
anchors.leftMargin: parent.width / 128
anchors.rightMargin: parent.width / 128
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
height: parent.height height: parent.height
to: progressBar.to to: progressBar.to
value: progressBar.value value: progressBar.value
center: true
} }
SpeedText { SpeedText {

View file

@ -0,0 +1,71 @@
import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
Item {
id: menuTitleBar
height: menuBar.height
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
visible: true
Connections {
target: globalConnections
onHideUI: function () {
if (!menuBar.anythingOpen()) {
menuTitleBar.visible = false
}
}
onShowUI: {
menuTitleBar.visible = true
}
}
MainMenu {
id: menuBar
}
Rectangle {
id: titleBar
height: menuBar.height
anchors.right: parent.right
anchors.left: menuBar.right
anchors.top: parent.top
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
Text {
id: titleLabel
objectName: "titleLabel"
text: translate.getTranslation("TITLE", i18n.language)
color: "white"
width: parent.width
height: parent.height
anchors.left: parent.left
anchors.leftMargin: 4
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
anchors.top: parent.top
font.family: appearance.fontName
fontSizeMode: Text.VerticalFit
font.pixelSize: appearance.scaleFactor * (height - anchors.topMargin
- anchors.bottomMargin - 2)
font.bold: true
opacity: 1
visible: menuTitleBar.visible
&& ((!appearance.titleOnlyOnFullscreen)
|| (mainWindow.visibility == Window.FullScreen
|| mainWindow.visibility == Window.Maximized))
Connections {
target: player
onTitleChanged: function (title) {
titleLabel.text = title
mainWindow.title = title
}
}
}
}
}

View file

@ -12,8 +12,29 @@ Slider {
objectName: "progressBar" objectName: "progressBar"
property string currentMediaURL: "" property string currentMediaURL: ""
property bool playing: false property bool playing: false
property bool center: false
to: 1 to: 1
value: 0.0 value: 0.0
Rectangle {
id: timestampBox
visible: false
width: hoverProgressLabel.width
height: hoverProgressLabel.height
z: 100
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
Text {
id: hoverProgressLabel
text: "0:00"
color: "white"
font.family: appearance.fontName
font.pixelSize: mainWindow.virtualHeight / 50
horizontalAlignment: Text.AlignHCenter
renderType: Text.NativeRendering
}
}
Connections { Connections {
target: player target: player
onPlayStatusChanged: function (status) { onPlayStatusChanged: function (status) {
@ -50,6 +71,10 @@ Slider {
} }
} }
function getHandleVisibility(themeName, isMouse) { function getHandleVisibility(themeName, isMouse) {
if (fun.nyanCat) {
return true
}
if (appearance.themeName == "Niconico" && isMouse) { if (appearance.themeName == "Niconico" && isMouse) {
return true return true
} else if (appearance.themeName == "Niconico") { } else if (appearance.themeName == "Niconico") {
@ -65,30 +90,30 @@ Slider {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
propagateComposedEvents: false propagateComposedEvents: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
z: 100 z: 100
property string currentTime: "" property string currentTime: ""
onEntered: previewRect.visible = true onEntered: timestampBox.visible = true
onExited: previewRect.visible = false onExited: timestampBox.visible = false
onPositionChanged: { onPositionChanged: {
var a = (progressBar.to / progressBar.availableWidth) var a = (progressBar.to / progressBar.availableWidth)
* (mouseAreaProgressBar.mapToItem( * (mouseAreaProgressBar.mapToItem(
progressBar, mouseAreaProgressBar.mouseX, 0).x - 2) progressBar, mouseAreaProgressBar.mouseX, 0).x - 2)
hoverProgressLabel.text = utils.createTimestamp(a) hoverProgressLabel.text = utils.createTimestamp(a)
previewRect.x = mouseAreaProgressBar.mapToItem( timestampBox.x = mouseAreaProgressBar.mouseX - (timestampBox.width / 2)
controlsOverlay, mouseAreaProgressBar.mouseX, timestampBox.y = progressBackground.y - timestampBox.height * 2
0).x - previewRect.width / 2
previewRect.y = progressBackground.y - previewRect.height - controlsBar.height * 2
} }
} }
background: Rectangle { background: Rectangle {
anchors.bottom: parent.bottom
anchors.bottomMargin: progressBar.center ? (progressBar.height / 2) - (height / 2) : 0
id: progressBackground id: progressBackground
x: progressBar.leftPadding z: 30
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
width: progressBar.availableWidth width: progressBar.availableWidth
height: progressBar.getProgressBarHeight( height: progressBar.getProgressBarHeight(
fun.nyanCat, mouseAreaProgressBar.containsMouse) fun.nyanCat, mouseAreaProgressBar.containsMouse)
@ -152,9 +177,9 @@ Slider {
handle: Rectangle { handle: Rectangle {
z: 70 z: 70
id: handleRect id: handleRect
x: progressBar.leftPadding + progressBar.visualPosition x: progressBar.visualPosition * (progressBar.availableWidth - width)
* (progressBar.availableWidth - width) anchors.bottom: parent.bottom
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2 anchors.bottomMargin: progressBar.center ? (progressBar.height / 2) - (height / 2) : -height / 4
implicitHeight: radius implicitHeight: radius
implicitWidth: radius implicitWidth: radius
radius: mainWindow.virtualHeight / 59 radius: mainWindow.virtualHeight / 59

View file

@ -11,7 +11,7 @@ import "codes.js" as LanguageCodes
Window { Window {
id: mainWindow id: mainWindow
title: titleLabel.text title: "KittehPlayer"
visible: true visible: true
width: 720 width: 720
height: 480 height: 480
@ -24,6 +24,12 @@ Window {
id: qmlDebugger id: qmlDebugger
} }
Item {
id: globalConnections
signal showUI()
signal hideUI()
}
function getAppearanceValueForTheme(themeName, name) { function getAppearanceValueForTheme(themeName, name) {
if (themeName == "YouTube") { if (themeName == "YouTube") {
return youTubeAppearance[name] return youTubeAppearance[name]
@ -306,23 +312,19 @@ Window {
property bool controlsShowing: true property bool controlsShowing: true
z: 2 z: 2
function hideControls(force) { Connections {
if (!menuBar.anythingOpen() || force) { target: globalConnections
controlsShowing = false onHideUI: function() {
mouseAreaPlayer.cursorShape = Qt.BlankCursor mouseAreaPlayer.cursorShape = Qt.BlankCursor
}
} }
onShowUI: {
mouseAreaPlayer.cursorShape = Qt.ArrowCursor
}
}
function showControls() {
if (!controlsShowing) {
controlsShowing = true
mouseAreaPlayer.cursorShape = Qt.ArrowCursor
}
}
MouseArea { MouseArea {
id: mouseAreaBar id: mouseAreaBar
width: parent.width width: parent.width
height: (controlsBar.controls.height * 2) + controlsBar.progress.height height: (controlsBar.controls.height * 2) + controlsBar.progress.height
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@ -344,9 +346,11 @@ Window {
anchors.rightMargin: 0 anchors.rightMargin: 0
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 0 anchors.leftMargin: 0
anchors.top: titleBar.bottom anchors.top: topBar.bottom
anchors.topMargin: 0 anchors.topMargin: 0
hoverEnabled: true hoverEnabled: true
propagateComposedEvents: true
Timer{ Timer{
id: mouseTapTimer id: mouseTapTimer
@ -392,11 +396,11 @@ Window {
running: true running: true
repeat: false repeat: false
onTriggered: { onTriggered: {
controlsOverlay.hideControls() globalConnections.hideUI()
} }
} }
onPositionChanged: { onPositionChanged: {
controlsOverlay.showControls() globalConnections.showUI()
mouseAreaPlayerTimer.restart() mouseAreaPlayerTimer.restart()
} }
} }
@ -404,12 +408,10 @@ Window {
Timer { Timer {
id: statsUpdater id: statsUpdater
interval: 1000 interval: 1000
running: true running: statsForNerdsText.visible
repeat: true repeat: true
onTriggered: { onTriggered: {
if (statsForNerdsText.visible) { statsForNerdsText.text = player.getStats()
statsForNerdsText.text = player.getStats()
}
} }
} }
@ -435,81 +437,12 @@ Window {
} }
} }
MainMenu { MenuTitleBar {
id: menuBar id: topBar
visible: controlsOverlay.controlsShowing
}
Rectangle {
id: titleBar
height: menuBar.height
anchors.right: parent.right
anchors.left: menuBar.right
anchors.top: parent.top
visible: controlsOverlay.controlsShowing
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
Text {
id: titleLabel
objectName: "titleLabel"
text: translate.getTranslation("TITLE", i18n.language)
color: "white"
width: parent.width
height: parent.height
anchors.left: parent.left
anchors.leftMargin: 4
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
anchors.top: parent.top
font.family: appearance.fontName
fontSizeMode: Text.VerticalFit
font.pixelSize: appearance.scaleFactor
* (height - anchors.topMargin - anchors.bottomMargin - 2)
font.bold: true
opacity: 1
visible: controlsOverlay.controlsShowing
&& ((!appearance.titleOnlyOnFullscreen)
|| (mainWindow.visibility == Window.FullScreen
|| mainWindow.visibility == Window.Maximized))
Connections {
target: player
onTitleChanged: function (title) {
titleLabel.text = title
}
}
}
} }
ControlsBar { ControlsBar {
id: controlsBar id: controlsBar
Item {
id: previewRect
z: 80
visible: false
width: hoverProgressLabel.width
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
width: hoverProgressLabel.width
height: hoverProgressLabel.height
z: 100
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
Text {
id: hoverProgressLabel
text: "0:00"
color: "white"
font.family: appearance.fontName
font.pixelSize: mainWindow.virtualHeight / 50
horizontalAlignment: Text.AlignHCenter
renderType: Text.NativeRendering
}
}
}
} }
} }
} }

View file

@ -8,6 +8,7 @@
<file>YouTubeButtonLayout.qml</file> <file>YouTubeButtonLayout.qml</file>
<file>NiconicoButtonLayout.qml</file> <file>NiconicoButtonLayout.qml</file>
<file>RoosterTeethButtonLayout.qml</file> <file>RoosterTeethButtonLayout.qml</file>
<file alias="MenuTitleBar.qml">UIComponents/MenuTitleBar.qml</file>
<file alias="SmoothButton.qml">UIComponents/SmoothButton.qml</file> <file alias="SmoothButton.qml">UIComponents/SmoothButton.qml</file>
<file alias="ButtonImage.qml">UIComponents/ButtonImage.qml</file> <file alias="ButtonImage.qml">UIComponents/ButtonImage.qml</file>
<file alias="VerticalVolume.qml">UIComponents/VerticalVolume.qml</file> <file alias="VerticalVolume.qml">UIComponents/VerticalVolume.qml</file>