shift-shell/components/mobileshell/qml/actiondrawer/private/QuickSettingsDelegate.qml
Devin Lin e196a91c8b actiondrawer: Use contextually correct colors and dark background at all times
This commit changes the action drawer colorsets to be contextually correct. The panel background would use the window background colors (instead of the view ones), and quicksettings delegates would use colors from the Button color set (rather than the view).

This also changes the background scrim to always be dark even in light mode. I think this is important to do because we have two views (notifications, and quick settings), which currently don't have much in the way of colours to distinguish the two. 

This commit also makes some changes to the notifications widget in order for its card foreground to be the standard theme colors.

![image](/uploads/b4e42984da926bc266d6c53d59a323b7/image.png){width=200}
![image](/uploads/4dc71502cdf85b5cbf6a2497a2384939/image.png){width=200}
![image](/uploads/ebd2d57ed46161ec8bb240a36c7069e7/image.png){width=300}

![image](/uploads/99656ee4cc322ee7412d7aef1c696893/image.png){width=200}
![image](/uploads/c0521a64069077fbe7e44b23159227e7/image.png){width=200}
![image](/uploads/6567a1bf42092d914a56d03ac5d7be54/image.png){width=300}
2025-09-18 09:29:53 -04:00

118 lines
4.1 KiB
QML

/*
* SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com>
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.1
import QtQuick.Layouts 1.1
import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.state as MobileShellState
import org.kde.plasma.components 3.0 as PlasmaComponents
MobileShell.BaseItem {
id: root
required property bool restrictedPermissions
// Model interface
required property string text
required property string status
required property string icon
required property bool enabled
required property string settingsCommand
required property var toggleFunction
signal closeRequested()
// set by children
property var iconItem
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Button
readonly property color enabledButtonBorderColor: Qt.darker(Kirigami.Theme.highlightColor, 1.25)
readonly property color disabledButtonBorderColor: separatorColorHelper(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, 0.2)
readonly property color enabledButtonColor: Kirigami.ColorUtils.tintWithAlpha(Kirigami.Theme.highlightColor, Kirigami.Theme.backgroundColor, 0.6)
readonly property color enabledButtonPressedColor: Kirigami.ColorUtils.tintWithAlpha(Kirigami.Theme.highlightColor, Kirigami.Theme.backgroundColor, 0.4);
readonly property color disabledButtonColor: Kirigami.Theme.backgroundColor
readonly property color disabledButtonPressedColor: Qt.darker(disabledButtonColor, 1.1)
function separatorColorHelper(bg, fg, baseRatio) {
if (Kirigami.ColorUtils.brightnessForColor(bg) === Kirigami.ColorUtils.Light) {
return Kirigami.ColorUtils.linearInterpolation(bg, fg, baseRatio);
} else {
return Kirigami.ColorUtils.linearInterpolation(bg, fg, baseRatio / 2);
}
}
// scale animation on press
property real zoomScale: 1
Behavior on zoomScale {
NumberAnimation {
duration: Kirigami.Units.longDuration
easing.type: Easing.OutExpo
}
}
transform: Scale {
origin.x: root.width / 2;
origin.y: root.height / 2;
xScale: root.zoomScale
yScale: root.zoomScale
}
function delegateClick() {
if (root.toggle) {
root.toggle();
} else if (root.toggleFunction) {
root.toggleFunction();
} else if (root.settingsCommand && !root.restrictedPermissions) {
closeRequested();
MobileShellState.ShellDBusClient.openAppLaunchAnimationWithPosition(
__getCurrentScreenNumber(),
root.icon,
root.text,
'org.kde.mobile.plasmasettings', // settings window id
-1,
-1,
Math.min(root.iconItem.width, root.iconItem.height));
MobileShell.ShellUtil.executeCommand(root.settingsCommand);
}
}
function delegatePressAndHold() {
if (root.settingsCommand && !root.restrictedPermissions) {
closeRequested();
MobileShellState.ShellDBusClient.openAppLaunchAnimationWithPosition(
__getCurrentScreenNumber(),
root.icon,
root.text,
'org.kde.mobile.plasmasettings', // settings window id
-1,
-1,
Math.min(root.iconItem.width, root.iconItem.height));
MobileShell.ShellUtil.executeCommand(root.settingsCommand);
} else if (root.toggleFunction) {
root.toggleFunction();
}
}
function __getCurrentScreenNumber() {
const screens = Qt.application.screens;
for (let i = 0; i < screens.length; i++) {
if (screens[i].name === Screen.name) {
return i;
}
}
return 0;
}
}