diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index eeccdeb..a6683ee 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -62,6 +62,10 @@ PLAYING]]> false + + + true + 5 diff --git a/package/contents/ui/Representation.qml b/package/contents/ui/Representation.qml index 1989c66..49f22c1 100644 --- a/package/contents/ui/Representation.qml +++ b/package/contents/ui/Representation.qml @@ -20,6 +20,7 @@ MouseArea { property int configuredBackgroundRadius: 0 property string configuredForegroundColor: "white" property bool configuredTextShadowEnabled: false + property bool configuredShowMediaControls: true property int configuredTrackTextVerticalSpacing: 5 property int configuredLabelVerticalSpacing: 0 property int configuredSeparatorGapLabel: 4 @@ -44,9 +45,10 @@ MouseArea { readonly property int effectiveSeparatorGapTrack: Math.max(0, configuredSeparatorGapTrack) readonly property int effectiveSeparatorHeight: Math.max(0, Math.min(100, configuredSeparatorHeight)) readonly property var effectiveLabelLines: (configuredLabelText || "").split(/\r?\n/) + readonly property bool mediaControlsEnabled: configuredShowMediaControls readonly property bool hasTrackInfo: player.ready && (((player.title || "").trim().length > 0) || ((player.artists || "").trim().length > 0)) - readonly property bool rawHoverActive: rootHoverHandler.hovered - readonly property bool controlsHoverActive: rawHoverActive || hoverExitTimer.running + readonly property bool rawHoverActive: mediaControlsEnabled && rootHoverHandler.hovered + readonly property bool controlsHoverActive: mediaControlsEnabled && (rawHoverActive || hoverExitTimer.running) readonly property bool nowPlayingLabelsVisible: { if (effectiveLabelVisibilityMode === "always") return true; @@ -61,12 +63,25 @@ MouseArea { acceptedButtons: Qt.NoButton hoverEnabled: true onRawHoverActiveChanged: { + if (!mediaControlsMouseArea.mediaControlsEnabled) { + hoverExitTimer.stop(); + return ; + } if (rawHoverActive) hoverExitTimer.stop(); else hoverExitTimer.restart(); } + onMediaControlsEnabledChanged: { + if (!mediaControlsMouseArea.mediaControlsEnabled) + hoverExitTimer.stop(); + + } Keys.onPressed: (event) => { + if (!mediaControlsMouseArea.mediaControlsEnabled) { + event.accepted = false; + return ; + } if (!event.modifiers) { event.accepted = true; if (event.key === Qt.Key_Space || event.key === Qt.Key_K) @@ -83,6 +98,7 @@ MouseArea { HoverHandler { id: rootHoverHandler + enabled: mediaControlsMouseArea.mediaControlsEnabled margin: 60 } @@ -206,9 +222,9 @@ MouseArea { id: mediaControls Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight - enabled: mediaControlsMouseArea.controlsHoverActive - opacity: mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea ? 1 : 0 - visible: mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea + enabled: mediaControlsMouseArea.mediaControlsEnabled && mediaControlsMouseArea.controlsHoverActive + opacity: mediaControlsMouseArea.mediaControlsEnabled && mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea ? 1 : 0 + visible: mediaControlsMouseArea.mediaControlsEnabled && mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea QQC2.Button { Layout.preferredWidth: buttonSize diff --git a/package/contents/ui/configGeneral.qml b/package/contents/ui/configGeneral.qml index 470ae60..fe567b1 100644 --- a/package/contents/ui/configGeneral.qml +++ b/package/contents/ui/configGeneral.qml @@ -22,6 +22,7 @@ KCM.SimpleKCM { property alias cfg_backgroundRadius: backgroundRadiusSpinBox.value property alias cfg_foregroundColor: foregroundColorField.text property alias cfg_textShadowEnabled: textShadowCheckBox.checked + property alias cfg_showMediaControls: showMediaControlsCheckBox.checked property alias cfg_trackTextVerticalSpacing: trackTextVerticalSpacingSpinBox.value property alias cfg_labelVerticalSpacing: labelVerticalSpacingSpinBox.value property alias cfg_separatorGapLabel: separatorGapLabelSpinBox.value @@ -181,6 +182,13 @@ KCM.SimpleKCM { text: i18n("Enable") } + QQC2.CheckBox { + id: showMediaControlsCheckBox + + Kirigami.FormData.label: i18n("Media controls:") + text: i18n("Show media controls") + } + QQC2.SpinBox { id: separatorHeightSpinBox diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index d903508..35a2931 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -39,6 +39,8 @@ PlasmoidItem { // qmllint disable missing-property property bool configuredTextShadowEnabled: plasmoid.configuration.textShadowEnabled // qmllint disable missing-property + property bool configuredShowMediaControls: plasmoid.configuration.showMediaControls + // qmllint disable missing-property property int configuredTrackTextVerticalSpacing: plasmoid.configuration.trackTextVerticalSpacing // qmllint disable missing-property property int configuredLabelVerticalSpacing: plasmoid.configuration.labelVerticalSpacing @@ -89,6 +91,7 @@ PlasmoidItem { configuredBackgroundRadius: root.configuredBackgroundRadius configuredForegroundColor: root.configuredForegroundColor configuredTextShadowEnabled: root.configuredTextShadowEnabled + configuredShowMediaControls: root.configuredShowMediaControls configuredTrackTextVerticalSpacing: root.configuredTrackTextVerticalSpacing configuredLabelVerticalSpacing: root.configuredLabelVerticalSpacing configuredSeparatorGapLabel: root.configuredSeparatorGapLabel @@ -116,6 +119,7 @@ PlasmoidItem { configuredBackgroundRadius: root.configuredBackgroundRadius configuredForegroundColor: root.configuredForegroundColor configuredTextShadowEnabled: root.configuredTextShadowEnabled + configuredShowMediaControls: root.configuredShowMediaControls configuredTrackTextVerticalSpacing: root.configuredTrackTextVerticalSpacing configuredLabelVerticalSpacing: root.configuredLabelVerticalSpacing configuredSeparatorGapLabel: root.configuredSeparatorGapLabel