RaveOS-KDE/releng/airootfs/root/raveos-sddm/Main.qml

329 lines
9.9 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import QtQuick.Window 2.15
Rectangle {
id: root
width: Window.width
height: Window.height
color: "black"
// Property a kiválasztott felhasználónak
property string currentUser: userModel.lastUser || ""
property int defaultSession: {
// Keressük meg a Wayland session indexét
for (var i = 0; i < sessionModel.rowCount(); i++) {
var session = sessionModel.data(sessionModel.index(i, 0), Qt.UserRole + 4) // session file path
if (session.indexOf("wayland") !== -1) {
return i
}
}
return sessionModel.lastIndex // Ha nem találtunk wayland-et, használjuk az utolsót
}
Component.onCompleted: {
// Alapértelmezett felhasználó és session beállítása
if (userModel.lastUser !== "") {
currentUser = userModel.lastUser
} else {
for (var i = 0; i < userModel.count; i++) {
var userName = userModel.data(userModel.index(i, 0), Qt.UserRole + 1)
if (userName && userName !== "") {
currentUser = userName
break
}
}
}
}
// Háttérkép blur effekttel
Item {
id: backgroundItem
anchors.fill: parent
Image {
id: backgroundImage
anchors.fill: parent
source: config.background || "background.png"
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: true
clip: true
mipmap: true
visible: false
}
FastBlur {
anchors.fill: backgroundImage
source: backgroundImage
radius: 32
cached: true
}
}
// Power gombok konténere
Rectangle {
id: powerButtonsContainer
width: powerButton.width + restartButton.width + 20
height: powerButton.height
color: "transparent"
anchors {
right: parent.right
bottom: parent.bottom
rightMargin: parent.width * 0.02
bottomMargin: parent.height * 0.02
}
// Restart gomb
Rectangle {
id: restartButton
width: 40
height: 40
radius: width / 2
color: Qt.rgba(255, 255, 255, 0.2)
border.color: Qt.rgba(255, 255, 255, 0.3)
border.width: 1
anchors {
right: powerButton.left
rightMargin: 20
}
PlasmaCore.IconItem {
id: restartIcon
anchors.centerIn: parent
source: "system-reboot"
width: parent.width * 0.6
height: width
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: sddm.reboot()
onEntered: parent.color = Qt.rgba(255, 255, 255, 0.3)
onExited: parent.color = Qt.rgba(255, 255, 255, 0.2)
}
layer.enabled: true
layer.effect: DropShadow {
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#80000000"
}
}
// Power gomb
Rectangle {
id: powerButton
width: 40
height: 40
radius: width / 2
color: Qt.rgba(255, 255, 255, 0.2)
border.color: Qt.rgba(255, 255, 255, 0.3)
border.width: 1
anchors.right: parent.right
PlasmaCore.IconItem {
id: powerIcon
anchors.centerIn: parent
source: "system-shutdown"
width: parent.width * 0.6
height: width
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: sddm.powerOff()
onEntered: parent.color = Qt.rgba(255, 255, 255, 0.3)
onExited: parent.color = Qt.rgba(255, 255, 255, 0.2)
}
layer.enabled: true
layer.effect: DropShadow {
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#80000000"
}
}
}
// Fő bejelentkező konténer
Item {
id: mainLoginContainer
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: parent.height * 0.15
width: Math.min(parent.width * 0.3, 400)
height: loginBox.height + passwordContainer.height + 40
// Profilkép és felhasználónév konténer
Rectangle {
id: loginBox
width: parent.width
height: profileContainer.height + usernameText.height + 20
color: "transparent"
anchors.bottom: passwordContainer.top
anchors.bottomMargin: 20
Rectangle {
id: profileContainer
width: 90
height: width
radius: width/2
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
color: "transparent"
Image {
id: profileImage
anchors.fill: parent
source: config.face || "face.png"
fillMode: Image.PreserveAspectCrop
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle {
width: profileImage.width
height: profileImage.height
radius: width/2
}
}
}
layer.enabled: true
layer.effect: DropShadow {
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#80000000"
}
}
Text {
id: usernameText
anchors.top: profileContainer.bottom
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
text: currentUser
color: "white"
font.family: "SF Pro Display"
font.pointSize: 14
opacity: 0.9
}
}
// Jelszó mező konténer
Rectangle {
id: passwordContainer
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: 200
height: 36
radius: height / 2
color: Qt.rgba(255, 255, 255, 0.2)
border.color: Qt.rgba(255, 255, 255, 0.3)
border.width: 1
TextField {
id: passwordField
anchors.fill: parent
anchors.margins: 2
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: TextInput.AlignHCenter
echoMode: TextInput.Password
placeholderText: "Enter Password"
font.family: "SF Pro Display"
font.pointSize: 12
focus: true
background: Rectangle {
color: "transparent"
radius: parent.height / 2
}
color: "white"
onAccepted: {
if (currentUser !== "") {
// Használjuk az alapértelmezett wayland session-t
sddm.login(currentUser, text, defaultSession)
}
}
Component.onCompleted: {
forceActiveFocus()
}
}
}
}
// OS Logo
Image {
id: osLogo
source: config["os-logo"] || "rave-os-2.png"
width: 150
height: 50
fillMode: Image.PreserveAspectFit
anchors {
horizontalCenter: parent.horizontalCenter
top: mainLoginContainer.bottom
topMargin: parent.height * 0.05
}
antialiasing: true
}
// Felső óra és dátum
Column {
id: timeColumn
anchors {
horizontalCenter: parent.horizontalCenter
bottom: mainLoginContainer.top
bottomMargin: parent.height * 0.02
}
spacing: 5
Text {
id: dateText
text: Qt.formatDateTime(new Date(), "dddd, MMMM d")
color: Qt.rgba(1, 1, 1, 0.7)
font.pointSize: 18
font.family: "SF Pro Display"
font.weight: Font.Bold
anchors.horizontalCenter: parent.horizontalCenter
}
Text {
id: timeText
text: Qt.formatDateTime(new Date(), "HH:mm")
color: Qt.rgba(1, 1, 1, 0.7)
font.pointSize: 66
font.family: "SF Pro Display"
font.weight: Font.Bold
anchors.horizontalCenter: parent.horizontalCenter
renderType: Text.QtRendering
smooth: true
antialiasing: true
}
}
Timer {
interval: 1000
running: true
repeat: true
onTriggered: {
timeText.text = Qt.formatDateTime(new Date(), "HH:mm")
dateText.text = Qt.formatDateTime(new Date(), "dddd, MMMM d")
}
}
}