Skip to content

Instantly share code, notes, and snippets.

@artixnous artixnous/Main.qml
Created Mar 22, 2017

Embed
What would you like to do?
QML file for SDDM theme demonstrated at https://www.youtube.com/watch?v=Btolv7Y4okY
/***************************************************************************
* Copyright (c) 2013 Abdurrahman AVCI <abdurrahmanavci@gmail.com
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*
***************************************************************************/
import QtMultimedia 5.0
import QtQuick 2.0
import SddmComponents 2.0
Rectangle {
id: container
width: 1024
height: 768
property int sessionIndex: session.index
Connections {
target: sddm
onLoginSucceeded: {
}
onLoginFailed: {
txtMessage.text = qsTr("Login failed. Please try again.")
listView.currentItem.password.text = ""
}
}
FontLoader { id: clockFont; source: "UbuntuMono-B.ttf" }
Repeater {
model: screenModel
VideoOutput {
source: player
anchors.fill: parent
MediaPlayer {
id: player
source: "bf.mp4"
autoLoad: true
autoPlay: true
loops: -1
}
}
}
Rectangle {
property variant geometry: screenModel.geometry(screenModel.primary)
x: geometry.x; y: geometry.y; width: geometry.width; height: geometry.height
color: "transparent"
Component {
id: userDelegate
PictureBox {
anchors.verticalCenter: parent.verticalCenter
name: (model.realName === "") ? model.name : model.realName
icon: model.icon
focus: (listView.currentIndex === index) ? true : false
state: (listView.currentIndex === index) ? "active" : ""
onLogin: sddm.login(model.name, password, sessionIndex);
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: listView.currentIndex = index
onClicked: listView.focus = true
}
}
}
Row {
anchors.fill: parent
Rectangle {
width: parent.width / 3 ; height: parent.height / 3
color: "#00000000"
Clock {
id: clock
anchors.centerIn: parent
color: "white"
timeFont.family: clockFont.name
}
}
Rectangle {
width: parent.width ; height: parent.height / 0.6
color: "#22000000"
clip: true
Item {
id: usersContainer
width: parent.width; height: 300
anchors.verticalCenter: parent.verticalCenter
ImageButton {
id: prevUser
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.margins: 10
source: "angle-left.png"
onClicked: listView.decrementCurrentIndex()
KeyNavigation.backtab: btnShutdown; KeyNavigation.tab: listView
}
ListView {
id: listView
height: parent.height
anchors.left: prevUser.right; anchors.right: nextUser.left
anchors.verticalCenter: parent.verticalCenter
anchors.margins: 10
clip: true
focus: true
spacing: 5
model: userModel
delegate: userDelegate
orientation: ListView.Horizontal
currentIndex: userModel.lastIndex
KeyNavigation.backtab: prevUser; KeyNavigation.tab: nextUser
}
ImageButton {
id: nextUser
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.margins: 10
source: "angle-right.png"
onClicked: listView.incrementCurrentIndex()
KeyNavigation.backtab: listView; KeyNavigation.tab: session
}
}
Text {
id: txtMessage
anchors.top: usersContainer.top
anchors.margins: 0
anchors.horizontalCenter: parent.horizontalCenter
color: "white"
text: qsTr("Select your user and enter password.")
font.pixelSize: 24
}
}
}
Rectangle {
id: actionBar
anchors.top: parent.top;
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width; height: 30
Row {
anchors.left: parent.left
anchors.margins: 5
height: parent.height
spacing: 5
Text {
height: parent.height
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Session:")
font.pixelSize: 18
verticalAlignment: Text.AlignVCenter
}
ComboBox {
id: session
width: 245
anchors.verticalCenter: parent.verticalCenter
arrowIcon: "angle-down.png"
model: sessionModel
index: sessionModel.lastIndex
font.pixelSize: 16
KeyNavigation.backtab: nextUser; KeyNavigation.tab: btnReboot
}
}
Row {
height: parent.height
anchors.right: parent.right
anchors.margins: 5
spacing: 5
ImageButton {
id: btnReboot
height: parent.height
source: "reboot.png"
visible: sddm.canReboot
onClicked: sddm.reboot()
KeyNavigation.backtab: session; KeyNavigation.tab: btnShutdown
}
ImageButton {
id: btnShutdown
height: parent.height
source: "shutdown.png"
visible: sddm.canPowerOff
onClicked: sddm.powerOff()
KeyNavigation.backtab: btnReboot; KeyNavigation.tab: prevUser
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.