feat: add option to disable media controls
This commit is contained in:
@@ -62,6 +62,10 @@ PLAYING]]></default>
|
|||||||
<label>Enable text shadow</label>
|
<label>Enable text shadow</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="showMediaControls" type="Bool">
|
||||||
|
<label>Show media controls</label>
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
<entry name="trackTextVerticalSpacing" type="Int">
|
<entry name="trackTextVerticalSpacing" type="Int">
|
||||||
<label>Track text vertical spacing</label>
|
<label>Track text vertical spacing</label>
|
||||||
<default>5</default>
|
<default>5</default>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ MouseArea {
|
|||||||
property int configuredBackgroundRadius: 0
|
property int configuredBackgroundRadius: 0
|
||||||
property string configuredForegroundColor: "white"
|
property string configuredForegroundColor: "white"
|
||||||
property bool configuredTextShadowEnabled: false
|
property bool configuredTextShadowEnabled: false
|
||||||
|
property bool configuredShowMediaControls: true
|
||||||
property int configuredTrackTextVerticalSpacing: 5
|
property int configuredTrackTextVerticalSpacing: 5
|
||||||
property int configuredLabelVerticalSpacing: 0
|
property int configuredLabelVerticalSpacing: 0
|
||||||
property int configuredSeparatorGapLabel: 4
|
property int configuredSeparatorGapLabel: 4
|
||||||
@@ -44,9 +45,10 @@ MouseArea {
|
|||||||
readonly property int effectiveSeparatorGapTrack: Math.max(0, configuredSeparatorGapTrack)
|
readonly property int effectiveSeparatorGapTrack: Math.max(0, configuredSeparatorGapTrack)
|
||||||
readonly property int effectiveSeparatorHeight: Math.max(0, Math.min(100, configuredSeparatorHeight))
|
readonly property int effectiveSeparatorHeight: Math.max(0, Math.min(100, configuredSeparatorHeight))
|
||||||
readonly property var effectiveLabelLines: (configuredLabelText || "").split(/\r?\n/)
|
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 hasTrackInfo: player.ready && (((player.title || "").trim().length > 0) || ((player.artists || "").trim().length > 0))
|
||||||
readonly property bool rawHoverActive: rootHoverHandler.hovered
|
readonly property bool rawHoverActive: mediaControlsEnabled && rootHoverHandler.hovered
|
||||||
readonly property bool controlsHoverActive: rawHoverActive || hoverExitTimer.running
|
readonly property bool controlsHoverActive: mediaControlsEnabled && (rawHoverActive || hoverExitTimer.running)
|
||||||
readonly property bool nowPlayingLabelsVisible: {
|
readonly property bool nowPlayingLabelsVisible: {
|
||||||
if (effectiveLabelVisibilityMode === "always")
|
if (effectiveLabelVisibilityMode === "always")
|
||||||
return true;
|
return true;
|
||||||
@@ -61,12 +63,25 @@ MouseArea {
|
|||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onRawHoverActiveChanged: {
|
onRawHoverActiveChanged: {
|
||||||
|
if (!mediaControlsMouseArea.mediaControlsEnabled) {
|
||||||
|
hoverExitTimer.stop();
|
||||||
|
return ;
|
||||||
|
}
|
||||||
if (rawHoverActive)
|
if (rawHoverActive)
|
||||||
hoverExitTimer.stop();
|
hoverExitTimer.stop();
|
||||||
else
|
else
|
||||||
hoverExitTimer.restart();
|
hoverExitTimer.restart();
|
||||||
}
|
}
|
||||||
|
onMediaControlsEnabledChanged: {
|
||||||
|
if (!mediaControlsMouseArea.mediaControlsEnabled)
|
||||||
|
hoverExitTimer.stop();
|
||||||
|
|
||||||
|
}
|
||||||
Keys.onPressed: (event) => {
|
Keys.onPressed: (event) => {
|
||||||
|
if (!mediaControlsMouseArea.mediaControlsEnabled) {
|
||||||
|
event.accepted = false;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
if (!event.modifiers) {
|
if (!event.modifiers) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
if (event.key === Qt.Key_Space || event.key === Qt.Key_K)
|
if (event.key === Qt.Key_Space || event.key === Qt.Key_K)
|
||||||
@@ -83,6 +98,7 @@ MouseArea {
|
|||||||
HoverHandler {
|
HoverHandler {
|
||||||
id: rootHoverHandler
|
id: rootHoverHandler
|
||||||
|
|
||||||
|
enabled: mediaControlsMouseArea.mediaControlsEnabled
|
||||||
margin: 60
|
margin: 60
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,9 +222,9 @@ MouseArea {
|
|||||||
id: mediaControls
|
id: mediaControls
|
||||||
|
|
||||||
Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight
|
Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight
|
||||||
enabled: mediaControlsMouseArea.controlsHoverActive
|
enabled: mediaControlsMouseArea.mediaControlsEnabled && mediaControlsMouseArea.controlsHoverActive
|
||||||
opacity: mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea ? 1 : 0
|
opacity: mediaControlsMouseArea.mediaControlsEnabled && mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea ? 1 : 0
|
||||||
visible: mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea
|
visible: mediaControlsMouseArea.mediaControlsEnabled && mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea
|
||||||
|
|
||||||
QQC2.Button {
|
QQC2.Button {
|
||||||
Layout.preferredWidth: buttonSize
|
Layout.preferredWidth: buttonSize
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ KCM.SimpleKCM {
|
|||||||
property alias cfg_backgroundRadius: backgroundRadiusSpinBox.value
|
property alias cfg_backgroundRadius: backgroundRadiusSpinBox.value
|
||||||
property alias cfg_foregroundColor: foregroundColorField.text
|
property alias cfg_foregroundColor: foregroundColorField.text
|
||||||
property alias cfg_textShadowEnabled: textShadowCheckBox.checked
|
property alias cfg_textShadowEnabled: textShadowCheckBox.checked
|
||||||
|
property alias cfg_showMediaControls: showMediaControlsCheckBox.checked
|
||||||
property alias cfg_trackTextVerticalSpacing: trackTextVerticalSpacingSpinBox.value
|
property alias cfg_trackTextVerticalSpacing: trackTextVerticalSpacingSpinBox.value
|
||||||
property alias cfg_labelVerticalSpacing: labelVerticalSpacingSpinBox.value
|
property alias cfg_labelVerticalSpacing: labelVerticalSpacingSpinBox.value
|
||||||
property alias cfg_separatorGapLabel: separatorGapLabelSpinBox.value
|
property alias cfg_separatorGapLabel: separatorGapLabelSpinBox.value
|
||||||
@@ -181,6 +182,13 @@ KCM.SimpleKCM {
|
|||||||
text: i18n("Enable")
|
text: i18n("Enable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQC2.CheckBox {
|
||||||
|
id: showMediaControlsCheckBox
|
||||||
|
|
||||||
|
Kirigami.FormData.label: i18n("Media controls:")
|
||||||
|
text: i18n("Show media controls")
|
||||||
|
}
|
||||||
|
|
||||||
QQC2.SpinBox {
|
QQC2.SpinBox {
|
||||||
id: separatorHeightSpinBox
|
id: separatorHeightSpinBox
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ PlasmoidItem {
|
|||||||
// qmllint disable missing-property
|
// qmllint disable missing-property
|
||||||
property bool configuredTextShadowEnabled: plasmoid.configuration.textShadowEnabled
|
property bool configuredTextShadowEnabled: plasmoid.configuration.textShadowEnabled
|
||||||
// qmllint disable missing-property
|
// qmllint disable missing-property
|
||||||
|
property bool configuredShowMediaControls: plasmoid.configuration.showMediaControls
|
||||||
|
// qmllint disable missing-property
|
||||||
property int configuredTrackTextVerticalSpacing: plasmoid.configuration.trackTextVerticalSpacing
|
property int configuredTrackTextVerticalSpacing: plasmoid.configuration.trackTextVerticalSpacing
|
||||||
// qmllint disable missing-property
|
// qmllint disable missing-property
|
||||||
property int configuredLabelVerticalSpacing: plasmoid.configuration.labelVerticalSpacing
|
property int configuredLabelVerticalSpacing: plasmoid.configuration.labelVerticalSpacing
|
||||||
@@ -89,6 +91,7 @@ PlasmoidItem {
|
|||||||
configuredBackgroundRadius: root.configuredBackgroundRadius
|
configuredBackgroundRadius: root.configuredBackgroundRadius
|
||||||
configuredForegroundColor: root.configuredForegroundColor
|
configuredForegroundColor: root.configuredForegroundColor
|
||||||
configuredTextShadowEnabled: root.configuredTextShadowEnabled
|
configuredTextShadowEnabled: root.configuredTextShadowEnabled
|
||||||
|
configuredShowMediaControls: root.configuredShowMediaControls
|
||||||
configuredTrackTextVerticalSpacing: root.configuredTrackTextVerticalSpacing
|
configuredTrackTextVerticalSpacing: root.configuredTrackTextVerticalSpacing
|
||||||
configuredLabelVerticalSpacing: root.configuredLabelVerticalSpacing
|
configuredLabelVerticalSpacing: root.configuredLabelVerticalSpacing
|
||||||
configuredSeparatorGapLabel: root.configuredSeparatorGapLabel
|
configuredSeparatorGapLabel: root.configuredSeparatorGapLabel
|
||||||
@@ -116,6 +119,7 @@ PlasmoidItem {
|
|||||||
configuredBackgroundRadius: root.configuredBackgroundRadius
|
configuredBackgroundRadius: root.configuredBackgroundRadius
|
||||||
configuredForegroundColor: root.configuredForegroundColor
|
configuredForegroundColor: root.configuredForegroundColor
|
||||||
configuredTextShadowEnabled: root.configuredTextShadowEnabled
|
configuredTextShadowEnabled: root.configuredTextShadowEnabled
|
||||||
|
configuredShowMediaControls: root.configuredShowMediaControls
|
||||||
configuredTrackTextVerticalSpacing: root.configuredTrackTextVerticalSpacing
|
configuredTrackTextVerticalSpacing: root.configuredTrackTextVerticalSpacing
|
||||||
configuredLabelVerticalSpacing: root.configuredLabelVerticalSpacing
|
configuredLabelVerticalSpacing: root.configuredLabelVerticalSpacing
|
||||||
configuredSeparatorGapLabel: root.configuredSeparatorGapLabel
|
configuredSeparatorGapLabel: root.configuredSeparatorGapLabel
|
||||||
|
|||||||
Reference in New Issue
Block a user