diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 5e438f085..6d37cc374 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -1330,6 +1330,8 @@ "clock-style-label": "Clock style", "compact-lockscreen-description": "Show only the login input and system controls, hiding weather and media widgets.", "compact-lockscreen-label": "Compact lock screen", + "enable-lockscreen-media-controls-description": "Show interactive media playback controls on the lock screen.", + "enable-lockscreen-media-controls-label": "Lock screen media controls", "lock-on-suspend-description": "Automatically lock the screen when suspending the system.", "lock-on-suspend-label": "Lock on suspend", "lock-screen-animations-description": "Enable or disable lockscreen animations.", diff --git a/Assets/settings-default.json b/Assets/settings-default.json index c06699dac..789023e3e 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -88,6 +88,7 @@ "lockOnSuspend": true, "showSessionButtonsOnLockScreen": true, "showHibernateOnLockScreen": false, + "enableLockScreenMediaControls": false, "enableShadows": true, "shadowDirection": "bottom_right", "shadowOffsetX": 2, diff --git a/Assets/settings-search-index.json b/Assets/settings-search-index.json index 6bb740906..f99283d89 100644 --- a/Assets/settings-search-index.json +++ b/Assets/settings-search-index.json @@ -1277,6 +1277,15 @@ "subTab": 0, "subTabLabel": "common.appearance" }, + { + "labelKey": "panels.lock-screen.enable-lockscreen-media-controls-label", + "descriptionKey": "panels.lock-screen.enable-lockscreen-media-controls-description", + "widget": "NToggle", + "tab": 11, + "tabLabel": "panels.lock-screen.title", + "subTab": 0, + "subTabLabel": "common.appearance" + }, { "labelKey": "panels.lock-screen.lock-screen-animations-label", "descriptionKey": "panels.lock-screen.lock-screen-animations-description", diff --git a/Commons/Settings.qml b/Commons/Settings.qml index a45e786e6..84583d43e 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -280,6 +280,7 @@ Singleton { property bool lockOnSuspend: true property bool showSessionButtonsOnLockScreen: true property bool showHibernateOnLockScreen: false + property bool enableLockScreenMediaControls: false property bool enableShadows: true property string shadowDirection: "bottom_right" property int shadowOffsetX: 2 diff --git a/Modules/LockScreen/LockScreenPanel.qml b/Modules/LockScreen/LockScreenPanel.qml index 35801fddc..7a3342af5 100644 --- a/Modules/LockScreen/LockScreenPanel.qml +++ b/Modules/LockScreen/LockScreenPanel.qml @@ -342,6 +342,124 @@ Item { elide: Text.ElideRight } } + + // Media controls (when enabled) + RowLayout { + spacing: Style.marginXS + visible: Settings.data.general.enableLockScreenMediaControls + Layout.alignment: Qt.AlignHCenter + + Rectangle { + width: 28 + height: 28 + radius: Math.min(Style.radiusL, width / 2) + color: prevButtonArea.containsMouse ? Color.mPrimary : Qt.alpha(Color.mOnSurface, 0.1) + visible: MediaService.canGoPrevious + + NIcon { + anchors.centerIn: parent + icon: "media-prev" + pointSize: Style.fontSizeM + color: prevButtonArea.containsMouse ? Color.mOnPrimary : Color.mOnSurface + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + easing.type: Easing.OutCubic + } + } + } + + MouseArea { + id: prevButtonArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: MediaService.canGoPrevious ? MediaService.previous() : {} + } + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + easing.type: Easing.OutCubic + } + } + } + + Rectangle { + width: 32 + height: 32 + radius: Math.min(Style.radiusL, width / 2) + color: playPauseButtonArea.containsMouse ? Color.mPrimary : Qt.alpha(Color.mOnSurface, 0.15) + visible: MediaService.canPlay || MediaService.canPause + + NIcon { + anchors.centerIn: parent + icon: MediaService.isPlaying ? "media-pause" : "media-play" + pointSize: Style.fontSizeL + color: playPauseButtonArea.containsMouse ? Color.mOnPrimary : Color.mOnSurface + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + easing.type: Easing.OutCubic + } + } + } + + MouseArea { + id: playPauseButtonArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: (MediaService.canPlay || MediaService.canPause) ? MediaService.playPause() : {} + } + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + easing.type: Easing.OutCubic + } + } + } + + Rectangle { + width: 28 + height: 28 + radius: Math.min(Style.radiusL, width / 2) + color: nextButtonArea.containsMouse ? Color.mPrimary : Qt.alpha(Color.mOnSurface, 0.1) + visible: MediaService.canGoNext + + NIcon { + anchors.centerIn: parent + icon: "media-next" + pointSize: Style.fontSizeM + color: nextButtonArea.containsMouse ? Color.mOnPrimary : Color.mOnSurface + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + easing.type: Easing.OutCubic + } + } + } + + MouseArea { + id: nextButtonArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: MediaService.canGoNext ? MediaService.next() : {} + } + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + easing.type: Easing.OutCubic + } + } + } + } } } diff --git a/Modules/Panels/Settings/Tabs/LockScreen/AppearanceSubTab.qml b/Modules/Panels/Settings/Tabs/LockScreen/AppearanceSubTab.qml index dec6995b5..545b04785 100644 --- a/Modules/Panels/Settings/Tabs/LockScreen/AppearanceSubTab.qml +++ b/Modules/Panels/Settings/Tabs/LockScreen/AppearanceSubTab.qml @@ -76,6 +76,15 @@ ColumnLayout { defaultValue: Settings.getDefaultValue("general.compactLockScreen") } + NToggle { + label: I18n.tr("panels.lock-screen.enable-lockscreen-media-controls-label") + description: I18n.tr("panels.lock-screen.enable-lockscreen-media-controls-description") + checked: Settings.data.general.enableLockScreenMediaControls + onToggled: checked => Settings.data.general.enableLockScreenMediaControls = checked + visible: !Settings.data.general.compactLockScreen + defaultValue: Settings.getDefaultValue("general.enableLockScreenMediaControls") + } + NToggle { label: I18n.tr("panels.lock-screen.lock-screen-animations-label") description: I18n.tr("panels.lock-screen.lock-screen-animations-description")