From 8fbc30e17ed97e567ef95626fce38ebff2ccc24e Mon Sep 17 00:00:00 2001 From: namedkitten Date: Wed, 22 Apr 2020 13:17:08 +0100 Subject: [PATCH] Format Code, Fix progress bar overlap on background. --- format-code.sh | 3 +- spdlog | 1 - src/qml/ControlsBar.qml | 5 +-- src/qml/CustomMenu.qml | 3 +- src/qml/Dialogs/PlaylistDialog.qml | 15 +++---- src/qml/MainMenu.qml | 48 ++++++++++----------- src/qml/RoosterTeethButtonLayout.qml | 10 ++--- src/qml/UIComponents/BackwardButton.qml | 6 +-- src/qml/UIComponents/ButtonImage.qml | 11 ++--- src/qml/UIComponents/ForwardButton.qml | 6 +-- src/qml/UIComponents/FullscreenButton.qml | 6 +-- src/qml/UIComponents/PlayPauseButton.qml | 6 +-- src/qml/UIComponents/PlaylistNextButton.qml | 6 +-- src/qml/UIComponents/PlaylistPrevButton.qml | 6 +-- src/qml/UIComponents/SettingsButton.qml | 6 +-- src/qml/UIComponents/SmoothButton.qml | 17 ++++---- src/qml/UIComponents/VerticalVolume.qml | 6 +-- src/qml/UIComponents/VideoProgress.qml | 5 +-- src/qml/UIComponents/VolumeButton.qml | 6 +-- src/qml/UIComponents/VolumeSlider.qml | 12 +++--- src/qml/YouTubeButtonLayout.qml | 1 + src/qml/main.qml | 6 ++- 22 files changed, 93 insertions(+), 98 deletions(-) delete mode 160000 spdlog diff --git a/format-code.sh b/format-code.sh index 9f5c33b..bd0d747 100755 --- a/format-code.sh +++ b/format-code.sh @@ -1,5 +1,6 @@ +#!/usr/bin/env bash SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd $SOURCE_DIR 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 +popd diff --git a/spdlog b/spdlog deleted file mode 160000 index 2b326e9..0000000 --- a/spdlog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2b326e90b82f74492229b8d2b27d66d088386e74 diff --git a/src/qml/ControlsBar.qml b/src/qml/ControlsBar.qml index b8019bd..df2c583 100644 --- a/src/qml/ControlsBar.qml +++ b/src/qml/ControlsBar.qml @@ -38,9 +38,7 @@ Item { if (component.status == Component.Error) { console.error("Error loading component: " + component.errorString()) } - component.createObject(controlsBar, { - - }) + component.createObject(controlsBar, {}) } Item { @@ -137,7 +135,6 @@ Item { anchors.left: parent.left anchors.right: parent.right anchors.bottomMargin: 0 - bottomPadding: 0 } } } diff --git a/src/qml/CustomMenu.qml b/src/qml/CustomMenu.qml index bc8a26a..24bb7f3 100644 --- a/src/qml/CustomMenu.qml +++ b/src/qml/CustomMenu.qml @@ -9,6 +9,5 @@ Menu { color: getAppearanceValueForTheme(appearance.themeName, "mainBackground") } - delegate: CustomMenuItem { - } + delegate: CustomMenuItem {} } diff --git a/src/qml/Dialogs/PlaylistDialog.qml b/src/qml/Dialogs/PlaylistDialog.qml index ddab905..3b3fa1c 100644 --- a/src/qml/Dialogs/PlaylistDialog.qml +++ b/src/qml/Dialogs/PlaylistDialog.qml @@ -50,7 +50,7 @@ Dialog { var component = Qt.createComponent("ThumbnailProcess.qml") var thumbnailerProcess = component.createObject( playlistDialog, { - name: thumbnailJobs[0] + "name": thumbnailJobs[0] }) if (String(titleJobs[0]).indexOf("://") !== -1) { @@ -85,7 +85,7 @@ Dialog { } var component = Qt.createComponent("TitleProcess.qml") var titleProcess = component.createObject(playlistDialog, { - name: titleJobs[0] + "name": titleJobs[0] }) titleProcess.start("youtube-dl", ["--get-title", titleJobs[0]]) @@ -107,10 +107,10 @@ Dialog { for (var thing in playlist) { var item = playlist[thing] playlistModel.append({ - playlistItemTitle: item["title"], - playlistItemFilename: item["filename"], - current: item["current"], - playlistPos: thing + "playlistItemTitle": item["title"], + "playlistItemFilename": item["filename"], + "current": item["current"], + "playlistPos": thing }) } } @@ -212,8 +212,7 @@ Dialog { id: playlistModel } delegate: playlistDelegate - highlight: Item { - } + highlight: Item {} snapMode: ListView.SnapToItem flickableDirection: Flickable.VerticalFlick boundsBehavior: Flickable.StopAtBounds diff --git a/src/qml/MainMenu.qml b/src/qml/MainMenu.qml index dd701a7..50f669b 100644 --- a/src/qml/MainMenu.qml +++ b/src/qml/MainMenu.qml @@ -51,31 +51,31 @@ MenuBar { var component = Qt.createComponent("TrackItem.qml") if (trackType == "sub") { var action = component.createObject(subMenu, { - text: trackLang, - trackID: String( - trackID), - trackType: "sid", - checked: track["selected"] + "text": trackLang, + "trackID": String( + trackID), + "trackType": "sid", + "checked": track["selected"] }) action.ActionGroup.group = subMenuGroup subMenu.addAction(action) } else if (trackType == "audio") { var action = component.createObject(audioMenu, { - text: trackTitle + trackLang, - trackID: String( - trackID), - trackType: "aid", - checked: track["selected"] + "text": trackTitle + trackLang, + "trackID": String( + trackID), + "trackType": "aid", + "checked": track["selected"] }) action.ActionGroup.group = audioMenuGroup audioMenu.addAction(action) } else if (trackType == "video") { var action = component.createObject(videoMenu, { - text: "Video " + trackID + trackTitle, - trackID: String( - trackID), - trackType: "vid", - checked: track["selected"] + "text": "Video " + trackID + trackTitle, + "trackID": String( + trackID), + "trackType": "vid", + "checked": track["selected"] }) action.ActionGroup.group = videoMenuGroup videoMenu.addAction(action) @@ -337,8 +337,7 @@ MenuBar { shortcut: keybinds.mute } - MenuSeparator { - } + MenuSeparator {} CustomMenu { title: translate.getTranslation("AUDIO_DEVICES", i18n.language) @@ -359,9 +358,9 @@ MenuBar { var audioDevice = audioDevices[thing] var component = Qt.createComponent("AudioDeviceItem.qml") var action = component.createObject(audioDeviceMenu, { - text: audioDevices[thing]["description"], - deviceID: String( - audioDevices[thing]["name"]) + "text": audioDevices[thing]["description"], + "deviceID": String( + audioDevices[thing]["name"]) }) action.ActionGroup.group = audioDeviceMenuGroup audioDeviceMenu.addAction(action) @@ -373,8 +372,7 @@ MenuBar { } } - MenuSeparator { - } + MenuSeparator {} CustomMenu { title: translate.getTranslation("AUDIO", i18n.language) @@ -401,8 +399,7 @@ MenuBar { } shortcut: keybinds.cycleVideo } - MenuSeparator { - } + MenuSeparator {} CustomMenu { title: translate.getTranslation("VIDEO", i18n.language) @@ -435,8 +432,7 @@ MenuBar { } shortcut: keybinds.cycleSubBackwards } - MenuSeparator { - } + MenuSeparator {} CustomMenu { title: translate.getTranslation("SUBTITLES", i18n.language) diff --git a/src/qml/RoosterTeethButtonLayout.qml b/src/qml/RoosterTeethButtonLayout.qml index de74cfe..c7a37d9 100644 --- a/src/qml/RoosterTeethButtonLayout.qml +++ b/src/qml/RoosterTeethButtonLayout.qml @@ -48,11 +48,11 @@ Item { iconWidth: parent.height / 1.25 hoverEnabled: true iconColor: hovered - || mouseAreaVolumeArea.containsMouse ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, - "buttonColor") + || mouseAreaVolumeArea.containsMouse ? getAppearanceValueForTheme( + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, + "buttonColor") } VerticalVolume { diff --git a/src/qml/UIComponents/BackwardButton.qml b/src/qml/UIComponents/BackwardButton.qml index ec7b6b8..7768c23 100644 --- a/src/qml/UIComponents/BackwardButton.qml +++ b/src/qml/UIComponents/BackwardButton.qml @@ -13,9 +13,9 @@ SmoothButton { hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") onClicked: { player.playerCommand(Enums.Commands.Seek, "-10") } diff --git a/src/qml/UIComponents/ButtonImage.qml b/src/qml/UIComponents/ButtonImage.qml index 85dc39d..d5a18a1 100644 --- a/src/qml/UIComponents/ButtonImage.qml +++ b/src/qml/UIComponents/ButtonImage.qml @@ -5,12 +5,13 @@ import QtGraphicalEffects 1.0 Image { id: root smooth: true - + property alias color: colorOverlay.color - property int size: 24 + property int iconHeight: 24 + property int iconWidth: 24 fillMode: Image.PreserveAspectFit - sourceSize.width: size - sourceSize.height: size + sourceSize.height: iconHeight + sourceSize.width: iconWidth ColorOverlay { id: colorOverlay @@ -18,4 +19,4 @@ Image { 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 41764d5..bae1f14 100644 --- a/src/qml/UIComponents/ForwardButton.qml +++ b/src/qml/UIComponents/ForwardButton.qml @@ -12,9 +12,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/forward.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") onClicked: { player.playerCommand(Enums.Commands.Seek, "10") } diff --git a/src/qml/UIComponents/FullscreenButton.qml b/src/qml/UIComponents/FullscreenButton.qml index fb520e8..48f3b7f 100644 --- a/src/qml/UIComponents/FullscreenButton.qml +++ b/src/qml/UIComponents/FullscreenButton.qml @@ -12,9 +12,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/fullscreen.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") Layout.alignment: Qt.AlignVCenter | Qt.AlignRight onClicked: { diff --git a/src/qml/UIComponents/PlayPauseButton.qml b/src/qml/UIComponents/PlayPauseButton.qml index 31320b5..616cb39 100644 --- a/src/qml/UIComponents/PlayPauseButton.qml +++ b/src/qml/UIComponents/PlayPauseButton.qml @@ -12,9 +12,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/pause.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") onClicked: { player.playerCommand(Enums.Commands.TogglePlayPause) } diff --git a/src/qml/UIComponents/PlaylistNextButton.qml b/src/qml/UIComponents/PlaylistNextButton.qml index 5cb0c7c..0e83396 100644 --- a/src/qml/UIComponents/PlaylistNextButton.qml +++ b/src/qml/UIComponents/PlaylistNextButton.qml @@ -13,9 +13,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/next.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") onClicked: { player.playerCommand(Enums.Commands.NextPlaylistItem) } diff --git a/src/qml/UIComponents/PlaylistPrevButton.qml b/src/qml/UIComponents/PlaylistPrevButton.qml index 34178dd..6b49fae 100644 --- a/src/qml/UIComponents/PlaylistPrevButton.qml +++ b/src/qml/UIComponents/PlaylistPrevButton.qml @@ -13,9 +13,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/prev.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") visible: appearance.themeName == "Youtube" ? false : true onClicked: { player.playerCommand(Enums.Commands.PreviousPlaylistItem) diff --git a/src/qml/UIComponents/SettingsButton.qml b/src/qml/UIComponents/SettingsButton.qml index 102d773..ec35a85 100644 --- a/src/qml/UIComponents/SettingsButton.qml +++ b/src/qml/UIComponents/SettingsButton.qml @@ -12,9 +12,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/settings.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") Layout.alignment: Qt.AlignVCenter | Qt.AlignRight onClicked: { var aptn = appearance.themeName diff --git a/src/qml/UIComponents/SmoothButton.qml b/src/qml/UIComponents/SmoothButton.qml index 4cbe2ae..ab8bae4 100644 --- a/src/qml/UIComponents/SmoothButton.qml +++ b/src/qml/UIComponents/SmoothButton.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Dialogs 1.3 -import QtQuick.Layouts 1.2 +import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import Qt.labs.settings 1.0 @@ -11,18 +11,19 @@ Control { id: root property alias iconSource: icon.source property alias iconColor: icon.color - property alias iconHeight: icon.size - property alias iconWidth: icon.size + property alias iconHeight: icon.iconHeight + property alias iconWidth: icon.iconWidth background: Item {} property bool iconRight: false focusPolicy: Qt.NoFocus - - signal clicked(); + signal clicked //onClicked: print('buttonClick') - leftPadding: appearance.themeName == "YouTube" ? iconWidth / 12 : appearance.themeName == "RoosterTeeth" ? iconWidth / 12 : iconWidth / 2.5 + leftPadding: appearance.themeName + == "YouTube" ? iconWidth / 12 : appearance.themeName + == "RoosterTeeth" ? iconWidth / 12 : iconWidth / 2.5 rightPadding: root.leftPadding contentItem: ButtonImage { @@ -34,6 +35,6 @@ Control { id: mouseArea anchors.fill: parent propagateComposedEvents: true - onClicked: root.clicked() + onClicked: root.clicked() } -} \ No newline at end of file +} diff --git a/src/qml/UIComponents/VerticalVolume.qml b/src/qml/UIComponents/VerticalVolume.qml index 3495a10..958cc43 100644 --- a/src/qml/UIComponents/VerticalVolume.qml +++ b/src/qml/UIComponents/VerticalVolume.qml @@ -20,9 +20,9 @@ Rectangle { orientation: Qt.Vertical - implicitWidth: Math.max(background ? background.implicitWidth : 0, - (handle ? handle.implicitWidth : 0) - + leftPadding + rightPadding) + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + (handle ? handle.implicitWidth : 0) + leftPadding + rightPadding) implicitHeight: Math.max( background.implicitHeight, handle.implicitHeight + topPadding + bottomPadding) diff --git a/src/qml/UIComponents/VideoProgress.qml b/src/qml/UIComponents/VideoProgress.qml index 96c30e5..bfcf089 100644 --- a/src/qml/UIComponents/VideoProgress.qml +++ b/src/qml/UIComponents/VideoProgress.qml @@ -97,8 +97,7 @@ Slider { ProgressBar { id: cachedLength - background: Item { - } + background: Item {} contentItem: Item { Rectangle { width: cachedLength.visualPosition * parent.width @@ -123,7 +122,7 @@ Slider { for (var i = 0, len = chapters.length; i < len; i++) { var component = Qt.createComponent("ChapterMarker.qml") var marker = component.createObject(chapterMarkers, { - time: chapters[i]["time"] + "time": chapters[i]["time"] }) } } diff --git a/src/qml/UIComponents/VolumeButton.qml b/src/qml/UIComponents/VolumeButton.qml index 9455fda..6065151 100644 --- a/src/qml/UIComponents/VolumeButton.qml +++ b/src/qml/UIComponents/VolumeButton.qml @@ -13,9 +13,9 @@ SmoothButton { iconSource: "icons/" + appearance.themeName + "/volume-up.svg" hoverEnabled: true iconColor: hovered ? getAppearanceValueForTheme( - appearance.themeName, - "buttonHoverColor") : getAppearanceValueForTheme( - appearance.themeName, "buttonColor") + appearance.themeName, + "buttonHoverColor") : getAppearanceValueForTheme( + appearance.themeName, "buttonColor") onClicked: { player.playerCommand(Enums.Commands.ToggleMute) } diff --git a/src/qml/UIComponents/VolumeSlider.qml b/src/qml/UIComponents/VolumeSlider.qml index cee02ac..424a514 100644 --- a/src/qml/UIComponents/VolumeSlider.qml +++ b/src/qml/UIComponents/VolumeSlider.qml @@ -14,12 +14,12 @@ Slider { palette.dark: "#f00" hoverEnabled: true - implicitWidth: Math.max(background ? background.implicitWidth : 0, - (handle ? handle.implicitWidth : 0) - + leftPadding + rightPadding) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - (handle ? handle.implicitHeight : 0) - + topPadding + bottomPadding) + implicitWidth: Math.max( + background ? background.implicitWidth : 0, + (handle ? handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max( + background ? background.implicitHeight : 0, + (handle ? handle.implicitHeight : 0) + topPadding + bottomPadding) onMoved: { player.playerCommand(Enums.Commands.SetVolume, Math.round(volumeBar.value).toString()) diff --git a/src/qml/YouTubeButtonLayout.qml b/src/qml/YouTubeButtonLayout.qml index 28c0a4c..f9eba22 100644 --- a/src/qml/YouTubeButtonLayout.qml +++ b/src/qml/YouTubeButtonLayout.qml @@ -29,6 +29,7 @@ Item { anchors.bottom: parent.bottom iconHeight: parent.height / 1.25 iconWidth: parent.height / 1.25 + leftPadding: 14 } PlaylistNextButton { id: playlistNextButton diff --git a/src/qml/main.qml b/src/qml/main.qml index 9ac4834..51a4c84 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -439,12 +439,14 @@ Window { anchors.top: parent.top font.family: appearance.fontName fontSizeMode: Text.VerticalFit - font.pixelSize: appearance.scaleFactor*(height-anchors.topMargin-anchors.bottomMargin-2) + 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)) + || (mainWindow.visibility == Window.FullScreen + || mainWindow.visibility == Window.Maximized)) Connections { target: player onTitleChanged: function (title) {