summaryrefslogtreecommitdiff
path: root/raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml
diff options
context:
space:
mode:
authorgabeszm <vgabor92@protonmail.com>2026-09-13 10:48:36 +0200
committergabeszm <vgabor92@protonmail.com>2026-09-13 10:48:36 +0200
commitb132f616fc27a62ad9612ec42a19b027e72a52b7 (patch)
treebf4d29f6c4246d560fb3cd97aba059f638191ed5 /raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml
parenta65fb557cfce85e27448139e9c0317c36b7d06cb (diff)
downloadRaveOS-PKGBUILD-b132f616fc27a62ad9612ec42a19b027e72a52b7.tar.gz
RaveOS-PKGBUILD-b132f616fc27a62ad9612ec42a19b027e72a52b7.zip
fix responsive ui
Diffstat (limited to 'raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml')
-rw-r--r--raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml153
1 files changed, 99 insertions, 54 deletions
diff --git a/raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml b/raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml
index d16c496..ee8852e 100644
--- a/raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml
+++ b/raveos-sddm-theme/sddm-rave-theme/Components/UserSwitcher.qml
@@ -4,7 +4,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
-import QtQuick.Effects
+import QtQuick.Effects 6.5
Item {
id: userSwitcher
@@ -26,14 +26,38 @@ Item {
signal userSwitched(int idx, string name)
// ── Segédfüggvények ───────────────────────────────────────────────────────────────────
- function isImagePath(p) {
- return p && p !== ""
- }
+ function resolveUserIcon(idx) {
+ var list = []
+ var count = (typeof userModel !== "undefined" && userModel) ? userModel.count : 0
+ if (count === 0 || idx < 0 || idx >= count) return list
+
+ var qIdx = userModel.index(idx, 0)
+ var directIcon = userModel.data(qIdx, Qt.UserRole + 4) || ""
+ var home = userModel.data(qIdx, Qt.UserRole + 3) || ""
+ var uName = userModel.data(qIdx, Qt.UserRole + 1) || ""
+
+ function addCandidate(p) {
+ if (!p || p === "") return
+ var s = p.toString().trim()
+ if (s === "") return
+ var url = (s.startsWith("file://") || s.startsWith("image://") || s.startsWith("qrc://") || s.startsWith("http")) ? s : ("file://" + s)
+ if (list.indexOf(url) === -1) {
+ list.push(url)
+ }
+ }
- function getUserIcon(idx) {
- // Qt.UserRole+4 = IconRole (ebben az SDDM verziban a Home = +3)
- var icon = userModel.data(userModel.index(idx, 0), Qt.UserRole + 4)
- return isImagePath(icon) ? icon : ""
+ if (directIcon !== "") addCandidate(directIcon)
+ if (home !== "") {
+ addCandidate(home + "/.face.icon")
+ addCandidate(home + "/.face")
+ }
+ if (uName !== "") {
+ addCandidate("/var/lib/AccountsService/icons/" + uName)
+ addCandidate("/var/lib/AccountsService/icons/" + uName + ".png")
+ addCandidate("/home/" + uName + "/.face.icon")
+ addCandidate("/home/" + uName + "/.face")
+ }
+ return list
}
function getUserName(idx) {
@@ -56,7 +80,7 @@ Item {
border.color: btnArea.containsMouse
? Qt.rgba(1, 1, 1, 0.45)
: Qt.rgba(1, 1, 1, 0.22)
- border.width: 1
+ border.width: root.font.pointSize * 0.08
Behavior on color { ColorAnimation { duration: 150 } }
Behavior on border.color{ ColorAnimation { duration: 150 } }
@@ -73,18 +97,25 @@ Item {
height: root.font.pointSize * 1.6
radius: width / 2
clip: true
- color: Qt.rgba(0.10, 0.10, 0.18, 0.70)
+ color: Qt.rgba(1, 1, 1, 0.15)
anchors.verticalCenter: parent.verticalCenter
- Image {
- id: miniPhoto
- anchors.fill: parent
- source: userSwitcher.getUserIcon(userSwitcher.selectedIndex)
- fillMode: Image.PreserveAspectCrop
- smooth: true
- visible: false
+ property var miniCandidates: userSwitcher.resolveUserIcon(userSwitcher.selectedIndex)
+ property int miniAttempt: 0
+
+ Connections {
+ target: userSwitcher
+ function onSelectedIndexChanged() {
+ miniAvatarCircle.miniCandidates = userSwitcher.resolveUserIcon(userSwitcher.selectedIndex)
+ miniAvatarCircle.miniAttempt = 0
+ if (miniAvatarCircle.miniCandidates.length > 0) {
+ miniPhoto.source = miniAvatarCircle.miniCandidates[0]
+ } else {
+ miniPhoto.source = ""
+ }
+ }
}
-
+
Item {
id: miniMask
anchors.fill: parent
@@ -96,15 +127,25 @@ Item {
color: "black"
}
}
-
- MultiEffect {
+
+ Image {
+ id: miniPhoto
anchors.fill: parent
- source: miniPhoto
- visible: miniPhoto.status === Image.Ready && miniPhoto.source !== ""
- maskEnabled: true
- maskSource: miniMask
- maskThresholdMin: 0.5
- maskSpreadAtMin: 1.0
+ source: miniAvatarCircle.miniCandidates.length > 0 ? miniAvatarCircle.miniCandidates[0] : ""
+ fillMode: Image.PreserveAspectCrop
+ smooth: true
+ visible: status === Image.Ready
+ layer.enabled: true
+ layer.effect: MultiEffect {
+ maskEnabled: true
+ maskSource: miniMask
+ }
+ onStatusChanged: {
+ if (status === Image.Error && miniAvatarCircle.miniAttempt < miniAvatarCircle.miniCandidates.length - 1) {
+ miniAvatarCircle.miniAttempt++
+ miniPhoto.source = miniAvatarCircle.miniCandidates[miniAvatarCircle.miniAttempt]
+ }
+ }
}
Image {
@@ -113,7 +154,7 @@ Item {
height: parent.height * 0.70
source: Qt.resolvedUrl("../Assets/User.svg")
fillMode: Image.PreserveAspectFit
- visible: miniPhoto.status !== Image.Ready || miniPhoto.source === ""
+ visible: miniPhoto.status !== Image.Ready
opacity: 0.80
}
}
@@ -123,6 +164,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
text: userSwitcher.selectedName
color: "#ffffff"
+ style: Text.Raised
+ styleColor: Qt.rgba(0, 0, 0, 0.40)
font.pointSize: root.font.pointSize * 0.82
font.family: root.font.family
}
@@ -176,10 +219,10 @@ Item {
}
background: Rectangle {
- radius: config.RoundCorners !== "" ? parseInt(config.RoundCorners) : 16
+ radius: config.RoundCorners !== "" ? parseInt(config.RoundCorners) : root.font.pointSize * 1.2
color: config.BackgroundColor
border.color: Qt.rgba(1, 1, 1, 0.18)
- border.width: 1
+ border.width: root.font.pointSize * 0.08
}
// Fejléc
@@ -199,7 +242,7 @@ Item {
// Elválasztó vonal
Rectangle {
width: parent.width
- height: 1
+ height: root.font.pointSize * 0.08
color: Qt.rgba(1, 1, 1, 0.12)
}
@@ -210,7 +253,7 @@ Item {
height: Math.min(contentHeight, root.font.pointSize * 22)
model: userModel
clip: true
- spacing: 2
+ spacing: root.font.pointSize * 0.15
boundsBehavior: Flickable.StopAtBounds
ScrollIndicator.vertical: ScrollIndicator { }
@@ -219,7 +262,7 @@ Item {
id: delegateRect
width: userList.width
height: root.font.pointSize * 4
- radius: config.RoundCorners !== "" ? parseInt(config.RoundCorners) / 2 : 8
+ radius: config.RoundCorners !== "" ? parseInt(config.RoundCorners) / 2 : root.font.pointSize * 0.6
// Kiemelés: aktív felhasználó
property bool isActive: index === userSwitcher.selectedIndex
@@ -247,17 +290,9 @@ Item {
color: Qt.rgba(0.12, 0.12, 0.20, 0.80)
anchors.verticalCenter: parent.verticalCenter
- property string iconPath: userSwitcher.getUserIcon(index)
+ property var delegateCandidates: userSwitcher.resolveUserIcon(index)
+ property int delegateAttempt: 0
- Image {
- id: delegatePhoto
- anchors.fill: parent
- source: parent.iconPath
- fillMode: Image.PreserveAspectCrop
- smooth: true
- visible: false
- }
-
Item {
id: delegateMask
anchors.fill: parent
@@ -269,15 +304,25 @@ Item {
color: "black"
}
}
-
- MultiEffect {
+
+ Image {
+ id: delegatePhoto
anchors.fill: parent
- source: delegatePhoto
- visible: delegatePhoto.status === Image.Ready && parent.iconPath !== ""
- maskEnabled: true
- maskSource: delegateMask
- maskThresholdMin: 0.5
- maskSpreadAtMin: 1.0
+ source: delegateAvatarCircle.delegateCandidates.length > 0 ? delegateAvatarCircle.delegateCandidates[0] : ""
+ fillMode: Image.PreserveAspectCrop
+ smooth: true
+ visible: status === Image.Ready
+ layer.enabled: true
+ layer.effect: MultiEffect {
+ maskEnabled: true
+ maskSource: delegateMask
+ }
+ onStatusChanged: {
+ if (status === Image.Error && delegateAvatarCircle.delegateAttempt < delegateAvatarCircle.delegateCandidates.length - 1) {
+ delegateAvatarCircle.delegateAttempt++
+ delegatePhoto.source = delegateAvatarCircle.delegateCandidates[delegateAvatarCircle.delegateAttempt]
+ }
+ }
}
Image {
@@ -286,7 +331,7 @@ Item {
height: parent.height * 0.65
source: Qt.resolvedUrl("../Assets/User.svg")
fillMode: Image.PreserveAspectFit
- visible: delegatePhoto.status !== Image.Ready || parent.iconPath === ""
+ visible: delegatePhoto.status !== Image.Ready
opacity: 0.75
}
}
@@ -305,13 +350,13 @@ Item {
// Aktív jelző csík a bal oldalon
Rectangle {
visible: delegateRect.isActive
- width: 3
+ width: root.font.pointSize * 0.23
height: parent.height * 0.55
- radius: 2
+ radius: root.font.pointSize * 0.15
color: Qt.rgba(74/255, 222/255, 128/255, 0.90)
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
- anchors.leftMargin: 2
+ anchors.leftMargin: root.font.pointSize * 0.15
}
MouseArea {