mirror of
https://github.com/luneko/SweetTokyoNight.git
synced 2025-12-16 08:29:53 +01:00
Kde: Add sddm theme
This commit is contained in:
445
kde/sddm/Main.qml
Normal file
445
kde/sddm/Main.qml
Normal file
@@ -0,0 +1,445 @@
|
||||
import QtQuick 2.8
|
||||
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Controls 1.1
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||
|
||||
import "components"
|
||||
|
||||
PlasmaCore.ColorScope {
|
||||
id: root
|
||||
|
||||
readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software
|
||||
|
||||
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
||||
|
||||
width: 1600
|
||||
height: 900
|
||||
|
||||
property string notificationMessage
|
||||
property string clock_color: "#fff"
|
||||
|
||||
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: keystateSource
|
||||
engine: "keystate"
|
||||
connectedSources: "Caps Lock"
|
||||
}
|
||||
|
||||
Image {
|
||||
id: wallpaper
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
source: config.background || config.Background
|
||||
asynchronous: true
|
||||
cache: true
|
||||
clip: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: loginScreenRoot
|
||||
anchors.fill: parent
|
||||
|
||||
property bool uiVisible: true
|
||||
property bool blockUI: mainStack.depth > 1 || userListComponent.mainPasswordBox.text.length > 0 || inputPanel.keyboardActive || config.type != "image"
|
||||
|
||||
hoverEnabled: true
|
||||
drag.filterChildren: true
|
||||
onPressed: uiVisible = true;
|
||||
onPositionChanged: uiVisible = true;
|
||||
onUiVisibleChanged: {
|
||||
if (blockUI) {
|
||||
fadeoutTimer.running = false;
|
||||
} else if (uiVisible) {
|
||||
fadeoutTimer.restart();
|
||||
}
|
||||
}
|
||||
onBlockUIChanged: {
|
||||
if (blockUI) {
|
||||
fadeoutTimer.running = false;
|
||||
uiVisible = true;
|
||||
} else {
|
||||
fadeoutTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
uiVisible = true;
|
||||
event.accepted = false;
|
||||
}
|
||||
|
||||
//takes one full minute for the ui to disappear
|
||||
Timer {
|
||||
id: fadeoutTimer
|
||||
running: true
|
||||
interval: 60000
|
||||
onTriggered: {
|
||||
if (!loginScreenRoot.blockUI) {
|
||||
loginScreenRoot.uiVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Clock {
|
||||
id: clock
|
||||
visible: true
|
||||
x: parent.width - width - 10
|
||||
y: parent.height - height - 10
|
||||
}
|
||||
|
||||
|
||||
StackView {
|
||||
id: mainStack
|
||||
anchors.left: parent.left
|
||||
height: root.height
|
||||
width: parent.width / 3
|
||||
|
||||
focus: true //StackView is an implicit focus scope, so we need to give this focus so the item inside will have it
|
||||
|
||||
Timer {
|
||||
//SDDM has a bug in 0.13 where even though we set the focus on the right item within the window, the window doesn't have focus
|
||||
//it is fixed in 6d5b36b28907b16280ff78995fef764bb0c573db which will be 0.14
|
||||
//we need to call "window->activate()" *After* it's been shown. We can't control that in QML so we use a shoddy timer
|
||||
//it's been this way for all Plasma 5.x without a huge problem
|
||||
running: true
|
||||
repeat: false
|
||||
interval: 200
|
||||
onTriggered: mainStack.forceActiveFocus()
|
||||
}
|
||||
|
||||
initialItem: Login {
|
||||
id: userListComponent
|
||||
userListModel: userModel
|
||||
loginScreenUiVisible: loginScreenRoot.uiVisible
|
||||
userListCurrentIndex: userModel.lastIndex >= 0 ? userModel.lastIndex : 0
|
||||
lastUserName: userModel.lastUser
|
||||
|
||||
showUserList: {
|
||||
if ( !userListModel.hasOwnProperty("count")
|
||||
|| !userListModel.hasOwnProperty("disableAvatarsThreshold"))
|
||||
return (userList.y + mainStack.y) > 0
|
||||
|
||||
if ( userListModel.count == 0 ) return false
|
||||
|
||||
return userListModel.count <= userListModel.disableAvatarsThreshold && (userList.y + mainStack.y) > 0
|
||||
}
|
||||
|
||||
notificationMessage: {
|
||||
var text = ""
|
||||
if (keystateSource.data["Caps Lock"]["Locked"]) {
|
||||
text += i18nd("plasma_lookandfeel_org.kde.lookandfeel","Caps Lock is on")
|
||||
if (root.notificationMessage) {
|
||||
text += " • "
|
||||
}
|
||||
}
|
||||
text += root.notificationMessage
|
||||
return text
|
||||
}
|
||||
|
||||
actionItems: [
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/suspend.svgz")
|
||||
text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel","Suspend to RAM","Sleep")
|
||||
onClicked: sddm.suspend()
|
||||
enabled: sddm.canSuspend
|
||||
visible: !inputPanel.keyboardActive
|
||||
},
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/restart.svgz")
|
||||
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart")
|
||||
onClicked: sddm.reboot()
|
||||
enabled: sddm.canReboot
|
||||
visible: !inputPanel.keyboardActive
|
||||
},
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/shutdown.svgz")
|
||||
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down")
|
||||
onClicked: sddm.powerOff()
|
||||
enabled: sddm.canPowerOff
|
||||
visible: !inputPanel.keyboardActive
|
||||
},
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/change_user.svgz")
|
||||
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Different User")
|
||||
onClicked: mainStack.push(userPromptComponent)
|
||||
enabled: true
|
||||
visible: !userListComponent.showUsernamePrompt && !inputPanel.keyboardActive
|
||||
}]
|
||||
|
||||
onLoginRequest: {
|
||||
root.notificationMessage = ""
|
||||
sddm.login(username, password, sessionButton.currentIndex)
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: units.longDuration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: inputPanel
|
||||
state: "hidden"
|
||||
property bool keyboardActive: item ? item.active : false
|
||||
onKeyboardActiveChanged: {
|
||||
if (keyboardActive) {
|
||||
state = "visible"
|
||||
} else {
|
||||
state = "hidden";
|
||||
}
|
||||
}
|
||||
source: "components/VirtualKeyboard.qml"
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
function showHide() {
|
||||
state = state == "hidden" ? "visible" : "hidden";
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "visible"
|
||||
PropertyChanges {
|
||||
target: mainStack
|
||||
y: Math.min(0, root.height - inputPanel.height - userListComponent.visibleBoundary)
|
||||
}
|
||||
PropertyChanges {
|
||||
target: inputPanel
|
||||
y: root.height - inputPanel.height
|
||||
opacity: 1
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "hidden"
|
||||
PropertyChanges {
|
||||
target: mainStack
|
||||
y: 0
|
||||
}
|
||||
PropertyChanges {
|
||||
target: inputPanel
|
||||
y: root.height - root.height/4
|
||||
opacity: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
from: "hidden"
|
||||
to: "visible"
|
||||
SequentialAnimation {
|
||||
ScriptAction {
|
||||
script: {
|
||||
inputPanel.item.activated = true;
|
||||
Qt.inputMethod.show();
|
||||
}
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: mainStack
|
||||
property: "y"
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: inputPanel
|
||||
property: "y"
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
OpacityAnimator {
|
||||
target: inputPanel
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
from: "visible"
|
||||
to: "hidden"
|
||||
SequentialAnimation {
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: mainStack
|
||||
property: "y"
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: inputPanel
|
||||
property: "y"
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
OpacityAnimator {
|
||||
target: inputPanel
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
}
|
||||
ScriptAction {
|
||||
script: {
|
||||
Qt.inputMethod.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Component {
|
||||
id: userPromptComponent
|
||||
Login {
|
||||
showUsernamePrompt: true
|
||||
notificationMessage: root.notificationMessage
|
||||
loginScreenUiVisible: loginScreenRoot.uiVisible
|
||||
|
||||
// using a model rather than a QObject list to avoid QTBUG-75900
|
||||
userListModel: ListModel {
|
||||
ListElement {
|
||||
name: ""
|
||||
iconSource: ""
|
||||
}
|
||||
Component.onCompleted: {
|
||||
// as we can't bind inside ListElement
|
||||
setProperty(0, "name", i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Type in Username and Password"));
|
||||
}
|
||||
}
|
||||
|
||||
onLoginRequest: {
|
||||
root.notificationMessage = ""
|
||||
sddm.login(username, password, sessionButton.currentIndex)
|
||||
}
|
||||
|
||||
actionItems: [
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/suspend.svgz")
|
||||
text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel","Suspend to RAM","Sleep")
|
||||
onClicked: sddm.suspend()
|
||||
enabled: sddm.canSuspend
|
||||
visible: !inputPanel.keyboardActive
|
||||
},
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/restart.svgz")
|
||||
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart")
|
||||
onClicked: sddm.reboot()
|
||||
enabled: sddm.canReboot
|
||||
visible: !inputPanel.keyboardActive
|
||||
},
|
||||
ActionButton {
|
||||
iconSource: Qt.resolvedUrl("assets/shutdown.svgz")
|
||||
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down")
|
||||
onClicked: sddm.powerOff()
|
||||
enabled: sddm.canPowerOff
|
||||
visible: !inputPanel.keyboardActive
|
||||
},
|
||||
ActionButton {
|
||||
iconSource: "go-previous"
|
||||
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","List Users")
|
||||
onClicked: mainStack.pop()
|
||||
visible: !inputPanel.keyboardActive
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: formBg
|
||||
anchors.fill: mainStack
|
||||
anchors.centerIn: mainStack
|
||||
color: "#401E2326"
|
||||
z:-1
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: blurArea
|
||||
sourceItem: wallpaper
|
||||
width: formBg.width
|
||||
height: formBg.height
|
||||
anchors.centerIn: formBg
|
||||
sourceRect: Qt.rect(x,y,width,height)
|
||||
visible: true
|
||||
z:-2
|
||||
}
|
||||
|
||||
GaussianBlur {
|
||||
id: blur
|
||||
height: formBg.height
|
||||
width: formBg.width
|
||||
source: blurArea
|
||||
radius: 50
|
||||
samples: 50 * 2 + 1
|
||||
cached: true
|
||||
anchors.centerIn: formBg
|
||||
visible: true
|
||||
z:-2
|
||||
}
|
||||
|
||||
//Footer
|
||||
RowLayout {
|
||||
id: footer
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
margins: units.smallSpacing
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: units.longDuration
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.ToolButton {
|
||||
text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to show/hide virtual keyboard", "Virtual Keyboard")
|
||||
iconName: inputPanel.keyboardActive ? "input-keyboard-virtual-on" : "input-keyboard-virtual-off"
|
||||
onClicked: inputPanel.showHide()
|
||||
visible: inputPanel.status == Loader.Ready
|
||||
}
|
||||
|
||||
KeyboardButton {
|
||||
}
|
||||
|
||||
SessionButton {
|
||||
id: sessionButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: sddm
|
||||
onLoginFailed: {
|
||||
notificationMessage = i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Login Failed")
|
||||
}
|
||||
onLoginSucceeded: {
|
||||
//note SDDM will kill the greeter at some random point after this
|
||||
//there is no certainty any transition will finish, it depends on the time it
|
||||
//takes to complete the init
|
||||
mainStack.opacity = 0
|
||||
footer.opacity = 0
|
||||
}
|
||||
}
|
||||
|
||||
onNotificationMessageChanged: {
|
||||
if (notificationMessage) {
|
||||
notificationResetTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: notificationResetTimer
|
||||
interval: 3000
|
||||
onTriggered: notificationMessage = ""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user