265 lines
8.1 KiB
QML
265 lines
8.1 KiB
QML
/***********************************************************************/
|
|
|
|
import QtQuick 2.0
|
|
import QtGraphicalEffects 1.0
|
|
import SddmComponents 2.0
|
|
|
|
|
|
Rectangle {
|
|
id: root
|
|
width: 640
|
|
height: 480
|
|
state: "stateLogin"
|
|
|
|
readonly property int hMargin: 40
|
|
readonly property int vMargin: 30
|
|
readonly property int m_powerButtonSize: 40
|
|
readonly property color textColor: "#ffffff"
|
|
|
|
TextConstants { id: textConstants }
|
|
|
|
states: [
|
|
State {
|
|
name: "statePower"
|
|
PropertyChanges { target: loginFrame; opacity: 0}
|
|
PropertyChanges { target: powerFrame; opacity: 1}
|
|
PropertyChanges { target: sessionFrame; opacity: 0}
|
|
PropertyChanges { target: userFrame; opacity: 0}
|
|
PropertyChanges { target: bgBlur; radius: 30}
|
|
},
|
|
State {
|
|
name: "stateSession"
|
|
PropertyChanges { target: loginFrame; opacity: 0}
|
|
PropertyChanges { target: powerFrame; opacity: 0}
|
|
PropertyChanges { target: sessionFrame; opacity: 1}
|
|
PropertyChanges { target: userFrame; opacity: 0}
|
|
PropertyChanges { target: bgBlur; radius: 30}
|
|
},
|
|
State {
|
|
name: "stateUser"
|
|
PropertyChanges { target: loginFrame; opacity: 0}
|
|
PropertyChanges { target: powerFrame; opacity: 0}
|
|
PropertyChanges { target: sessionFrame; opacity: 0}
|
|
PropertyChanges { target: userFrame; opacity: 1}
|
|
PropertyChanges { target: bgBlur; radius: 30}
|
|
},
|
|
State {
|
|
name: "stateLogin"
|
|
PropertyChanges { target: loginFrame; opacity: 1}
|
|
PropertyChanges { target: powerFrame; opacity: 0}
|
|
PropertyChanges { target: sessionFrame; opacity: 0}
|
|
PropertyChanges { target: userFrame; opacity: 0}
|
|
PropertyChanges { target: bgBlur; radius: 0}
|
|
}
|
|
|
|
]
|
|
transitions: Transition {
|
|
PropertyAnimation { duration: 100; properties: "opacity"; }
|
|
PropertyAnimation { duration: 300; properties: "radius"; }
|
|
}
|
|
|
|
Repeater {
|
|
model: screenModel
|
|
Background {
|
|
x: geometry.x; y: geometry.y; width: geometry.width; height:geometry.height
|
|
source: config.background
|
|
fillMode: Image.Tile
|
|
onStatusChanged: {
|
|
if (status == Image.Error && source !== config.defaultBackground) {
|
|
source = config.defaultBackground
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: mainFrame
|
|
property variant geometry: screenModel.geometry(screenModel.primary)
|
|
x: geometry.x; y: geometry.y; width: geometry.width; height: geometry.height
|
|
|
|
Image {
|
|
id: mainFrameBackground
|
|
anchors.fill: parent
|
|
source: "background.jpg"
|
|
}
|
|
|
|
FastBlur {
|
|
id: bgBlur
|
|
anchors.fill: mainFrameBackground
|
|
source: mainFrameBackground
|
|
radius: 0
|
|
}
|
|
|
|
Item {
|
|
id: centerArea
|
|
width: parent.width
|
|
height: parent.height / 3
|
|
anchors.top: parent.top
|
|
anchors.topMargin: parent.height / 5
|
|
|
|
PowerFrame {
|
|
id: powerFrame
|
|
anchors.fill: parent
|
|
enabled: root.state == "statePower"
|
|
onNeedClose: root.state = "stateLogin"
|
|
onNeedShutdown: sddm.powerOff()
|
|
onNeedRestart: sddm.reboot()
|
|
onNeedSuspend: sddm.suspend()
|
|
}
|
|
|
|
SessionFrame {
|
|
id: sessionFrame
|
|
anchors.fill: parent
|
|
enabled: root.state == "stateSession"
|
|
onSelected: {
|
|
console.log("Selected session:", index)
|
|
root.state = "stateLogin"
|
|
loginFrame.sessionIndex = index
|
|
}
|
|
onNeedClose: root.state = "stateLogin"
|
|
}
|
|
|
|
UserFrame {
|
|
id: userFrame
|
|
anchors.fill: parent
|
|
enabled: root.state == "stateUser"
|
|
onSelected: {
|
|
console.log("Select user:", userName)
|
|
root.state = "stateLogin"
|
|
loginFrame.userName = userName
|
|
}
|
|
onNeedClose: root.state = "stateLogin"
|
|
}
|
|
|
|
LoginFrame {
|
|
id: loginFrame
|
|
anchors.fill: parent
|
|
enabled: root.state == "stateLogin"
|
|
opacity: 0
|
|
transformOrigin: Item.Top
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: timeArea
|
|
visible: ! loginFrame.isProcessing
|
|
anchors {
|
|
bottom: parent.bottom
|
|
left: parent.left
|
|
}
|
|
width: parent.width / 3
|
|
height: parent.height / 5
|
|
|
|
Text {
|
|
id: timeText
|
|
anchors {
|
|
left: parent.left
|
|
leftMargin: hMargin
|
|
bottom: dateText.top
|
|
bottomMargin: 5
|
|
}
|
|
|
|
font.pointSize: 50
|
|
color: textColor
|
|
|
|
function updateTime() {
|
|
text = new Date().toLocaleString(Qt.locale("en_US"), "hh:mm")
|
|
}
|
|
}
|
|
|
|
Text {
|
|
id: dateText
|
|
anchors {
|
|
left: parent.left
|
|
leftMargin: hMargin
|
|
bottom: parent.bottom
|
|
bottomMargin: vMargin
|
|
}
|
|
|
|
font.pointSize: 18
|
|
color: textColor
|
|
|
|
function updateDate() {
|
|
text = new Date().toLocaleString(Qt.locale("en_US"), "yyyy-MM-dd dddd")
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
interval: 1000
|
|
repeat: true
|
|
running: true
|
|
onTriggered: {
|
|
timeText.updateTime()
|
|
dateText.updateDate()
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
timeText.updateTime()
|
|
dateText.updateDate()
|
|
}
|
|
}
|
|
|
|
Item {
|
|
id: powerArea
|
|
visible: ! loginFrame.isProcessing
|
|
anchors {
|
|
bottom: parent.bottom
|
|
right: parent.right
|
|
}
|
|
width: parent.width / 3
|
|
height: parent.height / 7
|
|
|
|
Row {
|
|
spacing: 20
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: hMargin
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
ImageButton {
|
|
id: sessionButton
|
|
width: m_powerButtonSize
|
|
height: m_powerButtonSize
|
|
visible: sessionFrame.isMultipleSessions()
|
|
source: sessionFrame.getCurrentSessionIconIndicator()
|
|
onClicked: root.state = "stateSession"
|
|
}
|
|
|
|
ImageButton {
|
|
id: userButton
|
|
width: m_powerButtonSize
|
|
height: m_powerButtonSize
|
|
visible: userFrame.isMultipleUsers()
|
|
|
|
source: "icons/switchframe/userswitch_normal.png"
|
|
onClicked: {
|
|
console.log("Switch User...")
|
|
root.state = "stateUser"
|
|
}
|
|
}
|
|
|
|
ImageButton {
|
|
id: shutdownButton
|
|
width: m_powerButtonSize
|
|
height: m_powerButtonSize
|
|
visible: true//sddm.canPowerOff
|
|
|
|
source: "icons/switchframe/powermenu.png"
|
|
onClicked: {
|
|
console.log("Show shutdown menu")
|
|
root.state = "statePower"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
z: -1
|
|
anchors.fill: parent
|
|
onClicked: root.state = "stateLogin"
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: loginFrame.captureFocus()
|
|
}
|