1
0
Fork 0

Rework some code to be prettyerish.

This commit is contained in:
namedkitten 2020-04-24 17:06:14 +01:00
parent 59fecddc0a
commit f702ab5330
24 changed files with 374 additions and 390 deletions

View file

@ -13,12 +13,17 @@ find_package(Qt5Concurrent REQUIRED)
find_package(Qt5 CONFIG REQUIRED COMPONENTS Qml Quick Gui Widgets Core X11Extras) find_package(Qt5 CONFIG REQUIRED COMPONENTS Qml Quick Gui Widgets Core X11Extras)
option(QML_DEBUG "enable qml debug" OFF)
if(QML_DEBUG)
add_definitions(-DQT_QML_DEBUG)
endif()
find_package(Qt5QuickCompiler) find_package(Qt5QuickCompiler)
#if(Qt5QuickCompiler_FOUND) if(Qt5QuickCompiler_FOUND)
#qtquick_compiler_add_resources(qml_QRC src/qml/qml.qrc) qtquick_compiler_add_resources(qml_QRC src/qml/qml.qrc)
#else() else()
qt5_add_resources(qml_QRC src/qml/qml.qrc) qt5_add_resources(qml_QRC src/qml/qml.qrc)
#endif() endif()
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(MPV REQUIRED mpv) pkg_check_modules(MPV REQUIRED mpv)

View file

@ -6,6 +6,9 @@
#include <qprocess.h> #include <qprocess.h>
#include <qqml.h> #include <qqml.h>
#include <qqmlapplicationengine.h> #include <qqmlapplicationengine.h>
#ifdef QT_QML_DEBUG
#include <qqmldebug.h>
#endif
#include <qsettings.h> #include <qsettings.h>
#include <qstring.h> #include <qstring.h>
#include <qstringliteral.h> #include <qstringliteral.h>
@ -98,9 +101,14 @@ main(int argc, char* argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
app.setOrganizationName("KittehPlayer"); app.setOrganizationName("KittehPlayer");
app.setOrganizationDomain("namedkitten.pw"); app.setOrganizationDomain("kitteh.pw");
app.setApplicationName("KittehPlayer"); app.setApplicationName("KittehPlayer");
#ifdef QT_QML_DEBUG
// Allows debug.
QQmlDebuggingEnabler enabler;
#endif
QSettings settings; QSettings settings;
Utils::SetDPMS(false); Utils::SetDPMS(false);

View file

@ -9,12 +9,13 @@ import player 1.0
Item { Item {
id: controlsBarItem id: controlsBarItem
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
property var combinedHeight: progressBar.height + controlsBackground.height property var combinedHeight: progressBar.height + controlsBackground.height
property bool controlsShowing: true property bool controlsShowing: true
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
Connections { Connections {
target: globalConnections target: globalConnections
@ -26,10 +27,6 @@ Item {
} }
} }
Component.onCompleted: {
setControlsTheme(appearance.themeName)
}
Connections { Connections {
target: appearance target: appearance
onThemeNameChanged: setControlsTheme(appearance.themeName) onThemeNameChanged: setControlsTheme(appearance.themeName)
@ -49,78 +46,21 @@ Item {
component.createObject(controlsBar, {}) component.createObject(controlsBar, {})
} }
Item { SubtitlesBar {
id: subtitlesBar
visible: !appearance.useMpvSubs
height: player.height / 8
anchors.bottom: controlsBackground.top anchors.bottom: controlsBackground.top
anchors.bottomMargin: 5
anchors.right: parent.right
anchors.left: parent.left
RowLayout {
id: nativeSubtitles
visible: true
anchors.left: subtitlesBar.left
anchors.right: subtitlesBar.right
height: childrenRect.height
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
Item {
id: subsContainer
Layout.fillWidth: true
Layout.fillHeight: true
Layout.rightMargin: 0
Layout.leftMargin: 0
Layout.maximumWidth: nativeSubtitles.width
height: childrenRect.height
Label {
id: nativeSubs
objectName: "nativeSubs"
onWidthChanged: {
if (width > parent.width - 10)
width = parent.width - 10
}
onTextChanged: if (width <= parent.width - 10)
width = undefined
color: "white"
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pixelSize: appearance.subtitlesFontSize
font.family: appearance.fontName
horizontalAlignment: Text.AlignHCenter
opacity: 1
background: Rectangle {
id: subsBackground
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
width: subsContainer.childrenRect.width
height: subsContainer.childrenRect.height
}
Connections {
target: player
onSubtitlesChanged: function (subtitles) {
nativeSubs.text = subtitles
}
}
}
}
}
} }
VideoProgress { VideoProgress {
id: progressBar id: progressBar
visible: controlsBarItem.controlsShowing visible: controlsBarItem.controlsShowing && appearance.themeName != "RoosterTeeth"
&& (appearance.themeName == "RoosterTeeth" ? false : true)
anchors.bottom: controlsBackground.top
anchors.left: controlsBackground.left
anchors.right: controlsBackground.right
anchors.bottomMargin: 0
bottomPadding: 0 bottomPadding: 0
z: 20 z: 20
anchors {
bottom: controlsBackground.top
left: controlsBackground.left
right: controlsBackground.right
bottomMargin: 0
}
} }
Rectangle { Rectangle {
@ -128,27 +68,35 @@ Item {
height: controlsBar.visible ? controlsBar.height height: controlsBar.visible ? controlsBar.height
+ (appearance.themeName + (appearance.themeName
== "RoosterTeeth" ? 0 : progressBar.topPadding) : 0 == "RoosterTeeth" ? 0 : progressBar.topPadding) : 0
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
color: getAppearanceValueForTheme(appearance.themeName, color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground") "mainBackground")
visible: controlsBarItem.controlsShowing visible: controlsBarItem.controlsShowing
z: 10 z: 10
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
} }
Item { Item {
id: controlsBar id: controlsBar
height: controlsBar.visible ? mainWindow.virtualHeight / 20 : 0 height: controlsBar.visible ? mainWindow.virtualHeight / 20 : 0
anchors.right: parent.right
anchors.rightMargin: parent.width / 128
anchors.left: parent.left
anchors.leftMargin: parent.width / 128
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
visible: controlsBarItem.controlsShowing visible: controlsBarItem.controlsShowing
z: 30 z: 30
anchors {
right: parent.right
rightMargin: parent.width / 128
left: parent.left
leftMargin: parent.width / 128
bottom: parent.bottom
bottomMargin: 0
}
}
Component.onCompleted: {
setControlsTheme(appearance.themeName)
} }
} }

View file

@ -8,6 +8,15 @@ Rectangle {
property int time: 0 property int time: 0
color: getAppearanceValueForTheme(appearance.themeName, color: getAppearanceValueForTheme(appearance.themeName,
"chapterMarkerColor") "chapterMarkerColor")
width: 4
height: parent.height
x: progressBar.background.width / progressBar.to * time
z: 9000
anchors {
top: parent.top
bottom: parent.bottom
}
Connections { Connections {
target: player target: player
enabled: true enabled: true
@ -15,11 +24,4 @@ Rectangle {
chapterMarker.destroy() chapterMarker.destroy()
} }
} }
width: 4
height: parent.height
anchors.top: parent.top
anchors.bottom: parent.bottom
x: progressBar.background.width / progressBar.to * time
z: 9000
} }

View file

@ -8,19 +8,19 @@ MenuItem {
contentItem: Text { contentItem: Text {
text: menuItem.text text: menuItem.text
font.family: appearance.fontName
font.bold: menuItem.highlighted
opacity: 1 opacity: 1
color: menuItem.highlighted ? "#5a50da" : "white" color: menuItem.highlighted ? "#5a50da" : "white"
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight elide: Text.ElideRight
font {
family: appearance.fontName
bold: menuItem.highlighted
}
} }
background: Rectangle { background: Rectangle {
width: parent.width anchors.fill: parent
height: parent.height
opacity: 1 opacity: 1
color: menuItem.highlighted ? "#c0c0f0" : "transparent" color: menuItem.highlighted ? "#c0c0f0" : "transparent"
} }

View file

@ -34,11 +34,13 @@ MenuBar {
var menu = trackMenus[a] var menu = trackMenus[a]
for (var i = 0, len = menu.count; i < len; i++) { for (var i = 0, len = menu.count; i < len; i++) {
var action = menu.actionAt(i) var action = menu.actionAt(i)
if (action) {
if (action.trackID != "no") { if (action.trackID != "no") {
menu.removeAction(action) menu.removeAction(action)
} }
} }
} }
}
for (var i = 0, len = newTracks.length; i < len; i++) { for (var i = 0, len = newTracks.length; i < len; i++) {
var track = newTracks[i] var track = newTracks[i]
@ -128,9 +130,11 @@ MenuBar {
contentItem: Text { contentItem: Text {
id: menuBarItemText id: menuBarItemText
text: menuBarItem.text text: menuBarItem.text
font.family: appearance.fontName font {
font.pixelSize: menuBar.height / 2 family: appearance.fontName
font.bold: menuBarItem.highlighted pixelSize: menuBar.height / 2
bold: menuBarItem.highlighted
}
opacity: 1 opacity: 1
color: menuBarItem.highlighted ? "#5a50da" : "white" color: menuBarItem.highlighted ? "#5a50da" : "white"
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft

View file

@ -1,10 +1,4 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
Item { Item {
@ -14,79 +8,83 @@ Item {
PlayPauseButton { PlayPauseButton {
id: playPauseButton id: playPauseButton
anchors.left: parent.left anchors {
anchors.top: parent.top left: parent.left
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
VolumeButton { VolumeButton {
id: volumeButton id: volumeButton
anchors.left: playPauseButton.right anchors {
anchors.top: parent.top left: playPauseButton.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
VolumeSlider { VolumeSlider {
anchors.left: volumeButton.right anchors {
anchors.top: parent.top left: volumeButton.right
anchors.bottom: parent.bottom top: parent.top
bottom: parent.bottom
}
} }
PlaylistPrevButton { PlaylistPrevButton {
id: playlistPrevButton id: playlistPrevButton
anchors.right: backwardButton.left anchors {
anchors.top: parent.top right: backwardButton.left
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
BackwardButton { BackwardButton {
id: backwardButton id: backwardButton
anchors.right: timeLabel.left anchors {
anchors.top: parent.top right: timeLabel.left
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
TimeLabel { TimeLabel {
id: timeLabel id: timeLabel
anchors.centerIn: parent anchors {
anchors.top: parent.top centerIn: parent
anchors.bottom: parent.bottom top: parent.top
bottom: parent.bottom
}
} }
ForwardButton { ForwardButton {
id: forwardButton id: forwardButton
anchors.left: timeLabel.right anchors {
anchors.top: parent.top left: timeLabel.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
PlaylistNextButton { PlaylistNextButton {
id: playlistNextButton id: playlistNextButton
anchors.left: forwardButton.right anchors {
anchors.top: parent.top left: forwardButton.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
FullscreenButton { FullscreenButton {
id: fullscreenButton id: fullscreenButton
anchors.right: settingsButton.left anchors {
anchors.top: parent.top right: settingsButton.left
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
SettingsButton { SettingsButton {
id: settingsButton id: settingsButton
anchors.right: parent.right anchors {
anchors.top: parent.top right: parent.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 2 bottom: parent.bottom
iconWidth: parent.height / 2 }
} }
} }

View file

@ -1,10 +1,4 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
Item { Item {
@ -14,17 +8,20 @@ Item {
PlayPauseButton { PlayPauseButton {
id: playPauseButton id: playPauseButton
anchors.top: parent.top anchors {
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 left: parent.left
}
} }
MouseArea { MouseArea {
id: mouseAreaVolumeArea id: mouseAreaVolumeArea
anchors.right: volumeSliderArea.right anchors {
anchors.bottom: volumeButton.bottom right: volumeSliderArea.right
anchors.left: volumeButton.left bottom: volumeButton.bottom
left: volumeButton.left
}
height: parent.height + (volumeSliderArea.visible ? volumeSliderArea.height : 0) height: parent.height + (volumeSliderArea.visible ? volumeSliderArea.height : 0)
hoverEnabled: true hoverEnabled: true
z: 500 z: 500
@ -33,7 +30,6 @@ Item {
onEntered: { onEntered: {
mouseAreaPlayerTimer.stop() mouseAreaPlayerTimer.stop()
} }
onExited: { onExited: {
mouseAreaPlayerTimer.restart() mouseAreaPlayerTimer.restart()
} }
@ -41,44 +37,44 @@ Item {
VolumeButton { VolumeButton {
id: volumeButton id: volumeButton
anchors.left: playPauseButton.right anchors {
anchors.top: parent.top left: playPauseButton.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
hoverEnabled: true hoverEnabled: true
iconColor: hovered
|| mouseAreaVolumeArea.containsMouse ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName,
"buttonColor")
} }
VerticalVolume { VerticalVolume {
id: volumeSliderArea id: volumeSliderArea
anchors.bottom: volumeButton.top anchors {
anchors.left: volumeButton.left bottom: volumeButton.top
anchors.right: volumeButton.right left: volumeButton.left
right: volumeButton.right
}
width: volumeButton.width width: volumeButton.width
visible: mouseAreaVolumeArea.containsMouse || volumeButton.hovered visible: mouseAreaVolumeArea.containsMouse || volumeButton.hovered
} }
TimeLabel { TimeLabel {
id: timeLabel id: timeLabel
anchors.left: volumeButton.right anchors {
anchors.top: parent.top left: volumeButton.right
anchors.bottom: parent.bottom top: parent.top
bottom: parent.bottom
}
} }
VideoProgress { VideoProgress {
id: videoProgressRoosterTeeth id: videoProgressRoosterTeeth
anchors.left: timeLabel.right anchors {
anchors.right: speedText.left top: parent.top
anchors.leftMargin: parent.width / 128 bottom: parent.bottom
anchors.rightMargin: parent.width / 128 left: timeLabel.right
anchors.top: parent.top leftMargin: parent.width / 128
anchors.bottom: parent.bottom right: speedText.left
rightMargin: parent.width / 128
}
height: parent.height height: parent.height
to: progressBar.to to: progressBar.to
value: progressBar.value value: progressBar.value
@ -87,25 +83,27 @@ Item {
SpeedText { SpeedText {
id: speedText id: speedText
anchors.top: parent.top anchors {
anchors.bottom: parent.bottom top: parent.top
anchors.right: fullscreenButton.left bottom: parent.bottom
right: fullscreenButton.left
}
} }
FullscreenButton { FullscreenButton {
id: fullscreenButton id: fullscreenButton
anchors.right: settingsButton.left anchors {
anchors.top: parent.top right: settingsButton.left
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
} }
SettingsButton { SettingsButton {
id: settingsButton id: settingsButton
anchors.right: parent.right anchors {
anchors.top: parent.top right: parent.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
} }
} }

71
src/qml/SubtitlesBar.qml Normal file
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
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0
Item {
id: subtitlesBar
visible: !appearance.useMpvSubs
height: player.height / 8
anchors {
bottomMargin: 5
right: parent.right
left: parent.left
}
RowLayout {
id: nativeSubtitles
height: childrenRect.height
visible: true
anchors {
left: subtitlesBar.left
right: subtitlesBar.right
bottom: parent.bottom
bottomMargin: 10
}
Item {
id: subsContainer
height: childrenRect.height
Layout.fillWidth: true
Layout.fillHeight: true
Layout.rightMargin: 0
Layout.leftMargin: 0
Layout.maximumWidth: nativeSubtitles.width
Label {
id: nativeSubs
objectName: "nativeSubs"
anchors.horizontalCenter: parent.horizontalCenter
color: "white"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Text.AlignHCenter
opacity: 1
font {
pixelSize: appearance.subtitlesFontSize
family: appearance.fontName
}
background: Rectangle {
id: subsBackground
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
width: subsContainer.childrenRect.width
height: subsContainer.childrenRect.height
}
onWidthChanged: {
if (width > parent.width - 10)
width = parent.width - 10
}
onTextChanged: if (width <= parent.width - 10)
width = undefined
Connections {
target: player
onSubtitlesChanged: function (subtitles) {
nativeSubs.text = subtitles
}
}
}
}
}
}

View file

@ -8,14 +8,7 @@ import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
SmoothButton { SmoothButton {
id: backwardButton
iconSource: "icons/" + appearance.themeName + "/backward.svg" iconSource: "icons/" + appearance.themeName + "/backward.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.Seek, "-10") player.playerCommand(Enums.Commands.Seek, "-10")
} }

View file

@ -1,22 +0,0 @@
import QtQuick 2.0
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
Image {
id: root
smooth: true
property alias color: colorOverlay.color
property int iconHeight: 24
property int iconWidth: 24
fillMode: Image.PreserveAspectFit
sourceSize.height: iconHeight
sourceSize.width: iconWidth
ColorOverlay {
id: colorOverlay
anchors.fill: root
source: root
color: "#000000"
}
}

View file

@ -8,13 +8,7 @@ import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
SmoothButton { SmoothButton {
id: forwardButton
iconSource: "icons/" + appearance.themeName + "/forward.svg" iconSource: "icons/" + appearance.themeName + "/forward.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.Seek, "10") player.playerCommand(Enums.Commands.Seek, "10")
} }

View file

@ -8,15 +8,8 @@ import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
SmoothButton { SmoothButton {
id: fullscreenButton
iconSource: "icons/" + appearance.themeName + "/fullscreen.svg" iconSource: "icons/" + appearance.themeName + "/fullscreen.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
onClicked: { onClicked: {
toggleFullscreen() toggleFullscreen()
} }

View file

@ -7,10 +7,12 @@ import QtQuick.Window 2.2
Item { Item {
id: menuTitleBar id: menuTitleBar
height: menuBar.height height: menuBar.height
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
visible: true visible: true
anchors {
left: parent.left
right: parent.right
top: parent.top
}
Connections { Connections {
target: globalConnections target: globalConnections
@ -29,13 +31,14 @@ Item {
} }
Rectangle { Rectangle {
id: titleBar
height: menuBar.height height: menuBar.height
anchors.right: parent.right
anchors.left: menuBar.right
anchors.top: parent.top
color: getAppearanceValueForTheme(appearance.themeName, color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground") "mainBackground")
anchors {
right: parent.right
left: menuBar.right
top: parent.top
}
Text { Text {
id: titleLabel id: titleLabel
@ -44,26 +47,31 @@ Item {
color: "white" color: "white"
width: parent.width width: parent.width
height: parent.height 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 fontSizeMode: Text.VerticalFit
font.pixelSize: appearance.scaleFactor * (height - anchors.topMargin
- anchors.bottomMargin - 2)
font.bold: true
opacity: 1 opacity: 1
visible: menuTitleBar.visible visible: menuTitleBar.visible
&& ((!appearance.titleOnlyOnFullscreen) && ((!appearance.titleOnlyOnFullscreen)
|| (mainWindow.visibility == Window.FullScreen || (mainWindow.visibility == Window.FullScreen
|| mainWindow.visibility == Window.Maximized)) || mainWindow.visibility == Window.Maximized))
font {
family: appearance.fontName
bold: true
pixelSize: appearance.scaleFactor * (height - anchors.topMargin
- anchors.bottomMargin - 2)
}
anchors {
left: parent.left
leftMargin: 4
bottom: parent.bottom
bottomMargin: 4
top: parent.top
}
Connections { Connections {
target: player target: player
onTitleChanged: function (title) { onTitleChanged: function (title) {
titleLabel.text = title titleLabel.text = title
mainWindow.title = title mainWindow.title = "KittehPlayer - " + title
} }
} }
} }

View file

@ -8,13 +8,7 @@ import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
SmoothButton { SmoothButton {
id: playPauseButton
iconSource: "icons/" + appearance.themeName + "/pause.svg" iconSource: "icons/" + appearance.themeName + "/pause.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.TogglePlayPause) player.playerCommand(Enums.Commands.TogglePlayPause)
} }

View file

@ -8,14 +8,7 @@ import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
SmoothButton { SmoothButton {
id: playlistNextButton
//icon.name: "next"
iconSource: "icons/" + appearance.themeName + "/next.svg" iconSource: "icons/" + appearance.themeName + "/next.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.NextPlaylistItem) player.playerCommand(Enums.Commands.NextPlaylistItem)
} }

View file

@ -9,13 +9,7 @@ import player 1.0
SmoothButton { SmoothButton {
id: playlistPrevButton id: playlistPrevButton
objectName: "playlistPrevButton"
iconSource: "icons/" + appearance.themeName + "/prev.svg" iconSource: "icons/" + appearance.themeName + "/prev.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
visible: appearance.themeName == "Youtube" ? false : true visible: appearance.themeName == "Youtube" ? false : true
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.PreviousPlaylistItem) player.playerCommand(Enums.Commands.PreviousPlaylistItem)

View file

@ -10,11 +10,6 @@ import player 1.0
SmoothButton { SmoothButton {
id: settingsButton id: settingsButton
iconSource: "icons/" + appearance.themeName + "/settings.svg" iconSource: "icons/" + appearance.themeName + "/settings.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
onClicked: { onClicked: {
var aptn = appearance.themeName var aptn = appearance.themeName

View file

@ -4,32 +4,41 @@ import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0
import QtGraphicalEffects 1.0
import QtQuick 2.0 import QtQuick 2.0
Control { Control {
id: root id: root
property alias iconSource: icon.source hoverEnabled: true
property alias iconColor: icon.color property alias iconSource: buttonImage.source
property alias iconHeight: icon.iconHeight
property alias iconWidth: icon.iconWidth
property alias containsMouse: mouseArea.containsMouse property alias containsMouse: mouseArea.containsMouse
background: Item {} background: null
property bool iconRight: false
focusPolicy: Qt.NoFocus focusPolicy: Qt.NoFocus
signal clicked signal clicked
leftPadding: appearance.themeName leftPadding: root.height / (appearance.themeName == "Niconico" ? 2.5 : 12)
== "YouTube" ? iconWidth / 12 : appearance.themeName
== "RoosterTeeth" ? iconWidth / 12 : iconWidth / 2.5
rightPadding: root.leftPadding rightPadding: root.leftPadding
contentItem: ButtonImage { contentItem: Image {
id: icon id: buttonImage
smooth: true
fillMode: Image.PreserveAspectFit
sourceSize.height: Math.floor(root.parent.height / (appearance.themeName == "Niconico" ? 2 : 1.25))
sourceSize.width: Math.floor(root.parent.height / (appearance.themeName == "Niconico" ? 2 : 1.25))
ColorOverlay {
id: colorOverlay
anchors.fill: parent
source: parent
color: root.hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
} }
}
MouseArea { MouseArea {
id: mouseArea id: mouseArea

View file

@ -10,18 +10,20 @@ import player 1.0
Text { Text {
id: speedText id: speedText
text: "1x" text: "1x"
font.family: appearance.fontName verticalAlignment: Text.AlignVCenter
font.pixelSize: layout.height / 2.5
color: speedStatusMouseArea.containsMouse ? getAppearanceValueForTheme( color: speedStatusMouseArea.containsMouse ? getAppearanceValueForTheme(
appearance.themeName, appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme( "buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, appearance.themeName,
"buttonColor") "buttonColor")
verticalAlignment: Text.AlignVCenter font {
family: appearance.fontName
pixelSize: layout.height / 2.5
}
Connections { Connections {
target: player target: player
onSpeedChanged: function (speed) { onSpeedChanged: function (speed) {
speedText.text = String(speed) + "x" text = String(speed) + "x"
} }
} }
MouseArea { MouseArea {
@ -29,7 +31,7 @@ Text {
anchors.fill: parent anchors.fill: parent
height: parent.height height: parent.height
hoverEnabled: true hoverEnabled: true
propagateComposedEvents: false propagateComposedEvents: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
} }
} }

View file

@ -9,17 +9,13 @@ import player 1.0
SmoothButton { SmoothButton {
id: volumeButton id: volumeButton
objectName: "volumeButton"
iconSource: "icons/" + appearance.themeName + "/volume-up.svg" iconSource: "icons/" + appearance.themeName + "/volume-up.svg"
hoverEnabled: true
iconColor: hovered ? getAppearanceValueForTheme(
appearance.themeName,
"buttonHoverColor") : getAppearanceValueForTheme(
appearance.themeName, "buttonColor")
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.ToggleMute) player.playerCommand(Enums.Commands.ToggleMute)
} }
function updateStatus(status) { Connections {
target: player
onVolumeStatusChanged: function(status) {
if (status == Enums.VolumeStatus.Muted) { if (status == Enums.VolumeStatus.Muted) {
volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-mute.svg" volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-mute.svg"
} else if (status == Enums.VolumeStatus.Low) { } else if (status == Enums.VolumeStatus.Low) {
@ -28,9 +24,5 @@ SmoothButton {
volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-up.svg" volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-up.svg"
} }
} }
Connections {
target: player
onVolumeStatusChanged: updateStatus
} }
} }

View file

@ -1,10 +1,4 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0 import player 1.0
Item { Item {
@ -15,37 +9,34 @@ Item {
PlaylistPrevButton { PlaylistPrevButton {
id: playlistPrevButton id: playlistPrevButton
anchors.left: parent.left anchors {
anchors.top: parent.top left: parent.left
anchors.bottom: parent.bottom top: parent.top
bottom: parent.bottom
}
width: visible ? playlistNextButton.width : 0 width: visible ? playlistNextButton.width : 0
iconHeight: parent.height / 1.25
iconWidth: parent.height / 1.25
} }
PlayPauseButton { PlayPauseButton {
id: playPauseButton id: playPauseButton
anchors.left: playlistPrevButton.right anchors {
anchors.top: parent.top left: playlistPrevButton.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
leftPadding: 14 leftPadding: 14
} }
PlaylistNextButton { PlaylistNextButton {
id: playlistNextButton id: playlistNextButton
anchors.left: playPauseButton.right anchors {
anchors.top: parent.top left: playPauseButton.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
} }
MouseArea { MouseArea {
id: mouseAreaVolumeArea id: mouseAreaVolumeArea
anchors.bottom: parent.bottom anchors.fill: volumeSlider
anchors.top: parent.top
anchors.left: volumeSlider.left
anchors.right: volumeSlider.right
width: volumeSlider.width width: volumeSlider.width
hoverEnabled: true hoverEnabled: true
propagateComposedEvents: true propagateComposedEvents: true
@ -55,42 +46,47 @@ Item {
VolumeButton { VolumeButton {
id: volumeButton id: volumeButton
anchors.left: playlistNextButton.right anchors {
anchors.top: parent.top left: playlistNextButton.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
z: 50 z: 50
} }
VolumeSlider { VolumeSlider {
id: volumeSlider id: volumeSlider
anchors.left: volumeButton.right anchors {
anchors.top: parent.top left: volumeButton.right
anchors.bottom: parent.bottom top: parent.top
bottom: parent.bottom
}
height: parent.height height: parent.height
visible: mouseAreaVolumeArea.containsMouse || volumeButton.hovered visible: mouseAreaVolumeArea.containsMouse || volumeButton.hovered
width: visible ? implicitWidth : 0 width: visible ? implicitWidth : 0
} }
TimeLabel { TimeLabel {
anchors.left: volumeSlider.right anchors {
anchors.top: parent.top left: volumeSlider.right
anchors.bottom: parent.bottom top: parent.top
bottom: parent.bottom
leftMargin: parent.width / 128
}
} }
SettingsButton { SettingsButton {
id: settingsButton id: settingsButton
anchors.right: fullscreenButton.left anchors {
anchors.top: parent.top right: fullscreenButton.left
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
} }
FullscreenButton { FullscreenButton {
id: fullscreenButton id: fullscreenButton
anchors.right: parent.right anchors {
anchors.top: parent.top right: parent.right
anchors.bottom: parent.bottom top: parent.top
iconHeight: parent.height / 1.25 bottom: parent.bottom
iconWidth: parent.height / 1.25 }
} }
} }

View file

@ -17,7 +17,6 @@ Window {
height: 480 height: 480
property int virtualHeight: Screen.height * appearance.scaleFactor property int virtualHeight: Screen.height * appearance.scaleFactor
property int virtualWidth: Screen.width * appearance.scaleFactor property int virtualWidth: Screen.width * appearance.scaleFactor
property bool onTop: false property bool onTop: false
QMLDebugger { QMLDebugger {
@ -213,8 +212,8 @@ Window {
anchors.fill: parent anchors.fill: parent
width: parent.width width: parent.width
height: parent.height height: parent.height
z: 1
logging: loggingSettings.logBackend logging: loggingSettings.logBackend
z: 1
Action { Action {
onTriggered: { onTriggered: {
@ -307,7 +306,10 @@ Window {
} }
MouseArea { MouseArea {
anchors.fill: parent anchors {
fill: parent
bottomMargin: controlsBar.combinedHeight
}
width: parent.width width: parent.width
height: parent.height height: parent.height
enabled: appearance.swipeToResize enabled: appearance.swipeToResize
@ -316,7 +318,6 @@ Window {
property int xPrev: 0 property int xPrev: 0
hoverEnabled: false hoverEnabled: false
propagateComposedEvents: true propagateComposedEvents: true
anchors.bottomMargin: controlsBar.combinedHeight
z: 1010 z: 1010
onPressed: { onPressed: {
xStart = mouse.x xStart = mouse.x
@ -358,10 +359,12 @@ Window {
MouseArea { MouseArea {
id: mouseAreaBar id: mouseAreaBar
width: parent.width width: parent.width
height: controlsBar.combinedHeight height: controlsBar.combinedHeight * 1.5
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
hoverEnabled: true hoverEnabled: true
anchors {
bottom: parent.bottom
bottomMargin: 0
}
onEntered: { onEntered: {
mouseAreaPlayerTimer.stop() mouseAreaPlayerTimer.stop()
} }
@ -372,16 +375,18 @@ Window {
z: 10 z: 10
focus: true focus: true
width: parent.width width: parent.width
anchors.bottom: mouseAreaBar.top
anchors.bottomMargin: 10
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: topBar.bottom
anchors.topMargin: 0
hoverEnabled: true hoverEnabled: true
propagateComposedEvents: true propagateComposedEvents: true
anchors {
bottom: mouseAreaBar.top
bottomMargin: 10
right: parent.right
rightMargin: 0
left: parent.left
leftMargin: 0
top: topBar.bottom
topMargin: 0
}
Timer { Timer {
id: mouseTapTimer id: mouseTapTimer
@ -454,16 +459,20 @@ Window {
visible: false visible: false
height: parent.height height: parent.height
width: parent.width width: parent.width
anchors.fill: parent
anchors.topMargin: mainWindow.virtualHeight / 20
anchors.leftMargin: mainWindow.virtualHeight / 20
font.family: appearance.fontName
textFormat: Text.RichText textFormat: Text.RichText
font.pixelSize: mainWindow.virtualHeight / 50
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignTop verticalAlignment: Text.AlignTop
renderType: Text.NativeRendering renderType: Text.NativeRendering
lineHeight: 1 lineHeight: 1
font {
family: appearance.fontName
pixelSize: mainWindow.virtualHeight / 50
}
anchors {
fill: parent
topMargin: mainWindow.virtualHeight / 20
leftMargin: mainWindow.virtualHeight / 20
}
Component.onCompleted: { Component.onCompleted: {
console.error(statsForNerdsText.lineHeight, font.pixelSize) console.error(statsForNerdsText.lineHeight, font.pixelSize)
} }

View file

@ -4,13 +4,13 @@
<file>main.qml</file> <file>main.qml</file>
<file>CustomMenu.qml</file> <file>CustomMenu.qml</file>
<file>ControlsBar.qml</file> <file>ControlsBar.qml</file>
<file>SubtitlesBar.qml</file>
<file>MainMenu.qml</file> <file>MainMenu.qml</file>
<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="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="VerticalVolume.qml">UIComponents/VerticalVolume.qml</file> <file alias="VerticalVolume.qml">UIComponents/VerticalVolume.qml</file>
<file alias="SpeedText.qml">UIComponents/SpeedText.qml</file> <file alias="SpeedText.qml">UIComponents/SpeedText.qml</file>
<file alias="ForwardButton.qml">UIComponents/ForwardButton.qml</file> <file alias="ForwardButton.qml">UIComponents/ForwardButton.qml</file>