diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9841988..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.fontFamily": "monospace" -} \ No newline at end of file diff --git a/format-code.sh b/format-code.sh index 9d4f523..9f5c33b 100755 --- a/format-code.sh +++ b/format-code.sh @@ -1,5 +1,5 @@ SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd $SOURCE_DIR -qmlfmt -w src/qml/*.qml src/qml/*/*.qml -clang-format -style mozilla -i src/* src/Backends/*/* -popd +find . -name "*.qml" -exec qmlfmt -w {} \; +find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" -exec clang-format90 -style mozilla -i {} \; +popdi i diff --git a/spdlog b/spdlog new file mode 160000 index 0000000..2b326e9 --- /dev/null +++ b/spdlog @@ -0,0 +1 @@ +Subproject commit 2b326e90b82f74492229b8d2b27d66d088386e74 diff --git a/src/backendinterface.hpp b/src/backendinterface.hpp index 5c4bc43..268954e 100644 --- a/src/backendinterface.hpp +++ b/src/backendinterface.hpp @@ -1,7 +1,7 @@ #ifndef BackendInterface_H #define BackendInterface_H -#include #include "enums.hpp" +#include class BackendInterface { public: diff --git a/src/logger.h b/src/logger.h index 349e339..4df0fd6 100644 --- a/src/logger.h +++ b/src/logger.h @@ -1,11 +1,11 @@ #ifndef LOGGER_HPP #define LOGGER_HPP -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include // IWYU pragma: keep +#include // IWYU pragma: keep std::shared_ptr initLogger(std::string name); diff --git a/src/qml/NiconicoButtonLayout.qml b/src/qml/NiconicoButtonLayout.qml index 9b4676f..939fee7 100644 --- a/src/qml/NiconicoButtonLayout.qml +++ b/src/qml/NiconicoButtonLayout.qml @@ -17,16 +17,16 @@ Item { anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } VolumeButton { id: volumeButton anchors.left: playPauseButton.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } VolumeSlider { anchors.left: volumeButton.right @@ -39,16 +39,16 @@ Item { anchors.right: backwardButton.left anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } BackwardButton { id: backwardButton anchors.right: timeLabel.left anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } TimeLabel { id: timeLabel @@ -61,16 +61,16 @@ Item { anchors.left: timeLabel.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } PlaylistNextButton { id: playlistNextButton anchors.left: forwardButton.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } FullscreenButton { @@ -78,15 +78,15 @@ Item { anchors.right: settingsButton.left anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } SettingsButton { id: settingsButton anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 2 - icon.width: parent.height / 2 + iconHeight: parent.height / 2 + iconWidth: parent.height / 2 } } diff --git a/src/qml/RoosterTeethButtonLayout.qml b/src/qml/RoosterTeethButtonLayout.qml index 71f73c9..de74cfe 100644 --- a/src/qml/RoosterTeethButtonLayout.qml +++ b/src/qml/RoosterTeethButtonLayout.qml @@ -16,22 +16,20 @@ Item { id: playPauseButton anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } MouseArea { id: mouseAreaVolumeArea - anchors.bottom: volumeButton.bottom - anchors.left: volumeSliderArea.left anchors.right: volumeSliderArea.right - anchors.top: volumeSliderArea.top - height: layout.height + volumeButton.height - + (volumeSliderArea.visible ? volumeSliderArea.height : 0) + anchors.bottom: volumeButton.bottom + anchors.left: volumeButton.left + height: parent.height + (volumeSliderArea.visible ? volumeSliderArea.height : 0) hoverEnabled: true + z: 500 propagateComposedEvents: true acceptedButtons: Qt.NoButton - onEntered: { mouseAreaPlayerTimer.stop() } @@ -46,9 +44,10 @@ Item { anchors.left: playPauseButton.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 - icon.color: hovered + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 + hoverEnabled: true + iconColor: hovered || mouseAreaVolumeArea.containsMouse ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( @@ -95,15 +94,15 @@ Item { anchors.right: settingsButton.left anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } SettingsButton { id: settingsButton anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } } diff --git a/src/qml/UIComponents/BackwardButton.qml b/src/qml/UIComponents/BackwardButton.qml index f47cf85..ec7b6b8 100644 --- a/src/qml/UIComponents/BackwardButton.qml +++ b/src/qml/UIComponents/BackwardButton.qml @@ -7,19 +7,16 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: backwardButton - icon.source: "icons/" + appearance.themeName + "/backward.svg" + iconSource: "icons/" + appearance.themeName + "/backward.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") - display: AbstractButton.IconOnly onClicked: { player.playerCommand(Enums.Commands.Seek, "-10") } - background: Item { - } } diff --git a/src/qml/UIComponents/ButtonImage.qml b/src/qml/UIComponents/ButtonImage.qml new file mode 100644 index 0000000..85dc39d --- /dev/null +++ b/src/qml/UIComponents/ButtonImage.qml @@ -0,0 +1,21 @@ +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 size: 24 + fillMode: Image.PreserveAspectFit + sourceSize.width: size + sourceSize.height: size + + ColorOverlay { + id: colorOverlay + anchors.fill: root + source: root + color: "#000000" + } +} \ No newline at end of file diff --git a/src/qml/UIComponents/ForwardButton.qml b/src/qml/UIComponents/ForwardButton.qml index cc2b231..41764d5 100644 --- a/src/qml/UIComponents/ForwardButton.qml +++ b/src/qml/UIComponents/ForwardButton.qml @@ -7,18 +7,15 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: forwardButton - icon.source: "icons/" + appearance.themeName + "/forward.svg" + iconSource: "icons/" + appearance.themeName + "/forward.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") - display: AbstractButton.IconOnly onClicked: { player.playerCommand(Enums.Commands.Seek, "10") } - background: Item { - } } diff --git a/src/qml/UIComponents/FullscreenButton.qml b/src/qml/UIComponents/FullscreenButton.qml index b1834cf..fb520e8 100644 --- a/src/qml/UIComponents/FullscreenButton.qml +++ b/src/qml/UIComponents/FullscreenButton.qml @@ -7,21 +7,17 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: fullscreenButton - icon.source: "icons/" + appearance.themeName + "/fullscreen.svg" + iconSource: "icons/" + appearance.themeName + "/fullscreen.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") Layout.alignment: Qt.AlignVCenter | Qt.AlignRight - display: AbstractButton.IconOnly onClicked: { toggleFullscreen() } - - background: Item { - } } diff --git a/src/qml/UIComponents/PlayPauseButton.qml b/src/qml/UIComponents/PlayPauseButton.qml index 9987812..31320b5 100644 --- a/src/qml/UIComponents/PlayPauseButton.qml +++ b/src/qml/UIComponents/PlayPauseButton.qml @@ -7,27 +7,24 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: playPauseButton - icon.source: "icons/" + appearance.themeName + "/pause.svg" + iconSource: "icons/" + appearance.themeName + "/pause.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") - display: AbstractButton.IconOnly onClicked: { player.playerCommand(Enums.Commands.TogglePlayPause) } - background: Item { - } Connections { target: player onPlayStatusChanged: function (status) { if (status == Enums.PlayStatus.Playing) { - icon.source = "qrc:/icons/" + appearance.themeName + "/pause.svg" + iconSource = "qrc:/icons/" + appearance.themeName + "/pause.svg" } else if (status == Enums.PlayStatus.Paused) { - icon.source = "qrc:/icons/" + appearance.themeName + "/play.svg" + iconSource = "qrc:/icons/" + appearance.themeName + "/play.svg" } } } diff --git a/src/qml/UIComponents/PlaylistNextButton.qml b/src/qml/UIComponents/PlaylistNextButton.qml index c79d946..5cb0c7c 100644 --- a/src/qml/UIComponents/PlaylistNextButton.qml +++ b/src/qml/UIComponents/PlaylistNextButton.qml @@ -7,19 +7,16 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: playlistNextButton //icon.name: "next" - icon.source: "icons/" + appearance.themeName + "/next.svg" + iconSource: "icons/" + appearance.themeName + "/next.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") - display: AbstractButton.IconOnly onClicked: { player.playerCommand(Enums.Commands.NextPlaylistItem) } - background: Item { - } } diff --git a/src/qml/UIComponents/PlaylistPrevButton.qml b/src/qml/UIComponents/PlaylistPrevButton.qml index 6041395..34178dd 100644 --- a/src/qml/UIComponents/PlaylistPrevButton.qml +++ b/src/qml/UIComponents/PlaylistPrevButton.qml @@ -7,22 +7,19 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: playlistPrevButton objectName: "playlistPrevButton" - icon.source: "icons/" + appearance.themeName + "/prev.svg" + iconSource: "icons/" + appearance.themeName + "/prev.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") - display: AbstractButton.IconOnly visible: appearance.themeName == "Youtube" ? false : true onClicked: { player.playerCommand(Enums.Commands.PreviousPlaylistItem) } - background: Item { - } Connections { target: player onPlaylistPositionChanged: function (position) { diff --git a/src/qml/UIComponents/SettingsButton.qml b/src/qml/UIComponents/SettingsButton.qml index d41c1da..102d773 100644 --- a/src/qml/UIComponents/SettingsButton.qml +++ b/src/qml/UIComponents/SettingsButton.qml @@ -7,23 +7,18 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: settingsButton - //icon.name: "settings" - icon.source: "icons/" + appearance.themeName + "/settings.svg" + iconSource: "icons/" + appearance.themeName + "/settings.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") Layout.alignment: Qt.AlignVCenter | Qt.AlignRight - display: AbstractButton.IconOnly - onClicked: { var aptn = appearance.themeName appearance.themeName = aptn == "YouTube" ? "RoosterTeeth" : aptn == "RoosterTeeth" ? "Niconico" : "YouTube" } - background: Item { - } } diff --git a/src/qml/UIComponents/SmoothButton.qml b/src/qml/UIComponents/SmoothButton.qml new file mode 100644 index 0000000..4cbe2ae --- /dev/null +++ b/src/qml/UIComponents/SmoothButton.qml @@ -0,0 +1,39 @@ +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 QtQuick 2.0 + +Control { + id: root + property alias iconSource: icon.source + property alias iconColor: icon.color + property alias iconHeight: icon.size + property alias iconWidth: icon.size + + background: Item {} + property bool iconRight: false + + focusPolicy: Qt.NoFocus + + + signal clicked(); + //onClicked: print('buttonClick') + leftPadding: appearance.themeName == "YouTube" ? iconWidth / 12 : appearance.themeName == "RoosterTeeth" ? iconWidth / 12 : iconWidth / 2.5 + rightPadding: root.leftPadding + + contentItem: ButtonImage { + id: icon + source: "cup.svg" + } + + MouseArea { + id: mouseArea + anchors.fill: parent + propagateComposedEvents: true + onClicked: root.clicked() + } +} \ No newline at end of file diff --git a/src/qml/UIComponents/VolumeButton.qml b/src/qml/UIComponents/VolumeButton.qml index 29b4f1a..9455fda 100644 --- a/src/qml/UIComponents/VolumeButton.qml +++ b/src/qml/UIComponents/VolumeButton.qml @@ -7,29 +7,25 @@ import Qt.labs.settings 1.0 import Qt.labs.platform 1.0 as LabsPlatform import player 1.0 -Button { +SmoothButton { id: volumeButton objectName: "volumeButton" - icon.source: "icons/" + appearance.themeName + "/volume-up.svg" + iconSource: "icons/" + appearance.themeName + "/volume-up.svg" hoverEnabled: true - icon.color: hovered ? getAppearanceValueForTheme( + iconColor: hovered ? getAppearanceValueForTheme( appearance.themeName, "buttonHoverColor") : getAppearanceValueForTheme( appearance.themeName, "buttonColor") - display: AbstractButton.IconOnly onClicked: { player.playerCommand(Enums.Commands.ToggleMute) } - background: Item { - } - function updateStatus(status) { if (status == Enums.VolumeStatus.Muted) { - volumeButton.icon.source = "qrc:/icons/" + appearance.themeName + "/volume-mute.svg" + volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-mute.svg" } else if (status == Enums.VolumeStatus.Low) { - volumeButton.icon.source = "qrc:/icons/" + appearance.themeName + "/volume-down.svg" + volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-down.svg" } else if (status == Enums.VolumeStatus.Normal) { - volumeButton.icon.source = "qrc:/icons/" + appearance.themeName + "/volume-up.svg" + volumeButton.iconSource = "qrc:/icons/" + appearance.themeName + "/volume-up.svg" } } diff --git a/src/qml/UIComponents/VolumeSlider.qml b/src/qml/UIComponents/VolumeSlider.qml index 151bd65..cee02ac 100644 --- a/src/qml/UIComponents/VolumeSlider.qml +++ b/src/qml/UIComponents/VolumeSlider.qml @@ -12,6 +12,7 @@ Slider { to: 100 value: 100 palette.dark: "#f00" + hoverEnabled: true implicitWidth: Math.max(background ? background.implicitWidth : 0, (handle ? handle.implicitWidth : 0) diff --git a/src/qml/YouTubeButtonLayout.qml b/src/qml/YouTubeButtonLayout.qml index ab8ac98..28c0a4c 100644 --- a/src/qml/YouTubeButtonLayout.qml +++ b/src/qml/YouTubeButtonLayout.qml @@ -19,24 +19,24 @@ Item { anchors.top: parent.top anchors.bottom: parent.bottom width: visible ? playlistNextButton.width : 0 - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } PlayPauseButton { id: playPauseButton anchors.left: playlistPrevButton.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } PlaylistNextButton { id: playlistNextButton anchors.left: playPauseButton.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } MouseArea { @@ -49,6 +49,7 @@ Item { hoverEnabled: true propagateComposedEvents: true acceptedButtons: Qt.NoButton + z: 500 } VolumeButton { @@ -56,8 +57,8 @@ Item { anchors.left: playlistNextButton.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } VolumeSlider { id: volumeSlider @@ -79,15 +80,15 @@ Item { anchors.right: fullscreenButton.left anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } FullscreenButton { id: fullscreenButton anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - icon.height: parent.height / 1.25 - icon.width: parent.height / 1.25 + iconHeight: parent.height / 1.25 + iconWidth: parent.height / 1.25 } } diff --git a/src/qml/main.qml b/src/qml/main.qml index 7c03e98..9ac4834 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -226,7 +226,7 @@ Window { } function startPlayer() { - console.info(qmlDebugger.properties(player)) + //console.info(qmlDebugger.properties(player)) console.info("OwO!") var args = Qt.application.arguments diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index 8294de4..2ca6d2a 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -8,6 +8,8 @@ YouTubeButtonLayout.qml NiconicoButtonLayout.qml RoosterTeethButtonLayout.qml + UIComponents/SmoothButton.qml + UIComponents/ButtonImage.qml UIComponents/VerticalVolume.qml UIComponents/SpeedText.qml UIComponents/ForwardButton.qml diff --git a/src/qml/qml.qrc.depends b/src/qml/qml.qrc.depends index 8294de4..2ca6d2a 100644 --- a/src/qml/qml.qrc.depends +++ b/src/qml/qml.qrc.depends @@ -8,6 +8,8 @@ YouTubeButtonLayout.qml NiconicoButtonLayout.qml RoosterTeethButtonLayout.qml + UIComponents/SmoothButton.qml + UIComponents/ButtonImage.qml UIComponents/VerticalVolume.qml UIComponents/SpeedText.qml UIComponents/ForwardButton.qml