change appearence

This commit is contained in:
eximus
2017-03-29 17:31:08 +01:00
parent d959059971
commit d9f82409c0

602
Main.qml
View File

@@ -1,356 +1,344 @@
/*************************************************************************** import QtQuick 2.0
* Copyright (c) 2015 Víctor Granda García <victorgrandagarcia@gmail.com>
* Copyright (c) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
* Copyright (c) 2013 Abdurrahman AVCI <abdurrahmanavci@gmail.com>
* Copyright (c) 2013 Fabio Almeida| <fabio_r11@hotmail.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 QtQuick 2.2
import SddmComponents 2.0 import SddmComponents 2.0
import QtMultimedia 5.8 import QtMultimedia 5.8
Rectangle { Rectangle {
id: container // Main Container
width: 1024 id: container
height: 768 width: 1920
height: 1080
LayoutMirroring.enabled: Qt.locale().textDirection == Qt.RightToLeft LayoutMirroring.enabled: Qt.locale().textDirection == Qt.RightToLeft
LayoutMirroring.childrenInherit: true LayoutMirroring.childrenInherit: true
property int sessionIndex: session.index property int sessionIndex: session.index
TextConstants { // Inherited from SDDMComponents
id: textConstants TextConstants {
} id: textConstants
Connections {
target: sddm
onLoginSucceeded: {
} }
onLoginFailed: { // Set SDDM actions
errorMessage.color = "#dc322f" Connections {
errorMessage.text = textConstants.loginFailed target: sddm
} onLoginSucceeded: {
}
FontLoader {
id: textFont; name: config.displayFont
}
Repeater {
model: screenModel
Background {
x: geometry.x; y: geometry.y; width: geometry.width; height:geometry.height
source: config.background
fillMode: Image.PreserveAspectCrop
onStatusChanged: {
if (status == Image.Error && source != config.defaultBackground) {
source = config.defaultBackground
} }
}
}
}
MediaPlayer { onLoginFailed: {
id: mediaplayer error_message.color = "#dc322f"
autoPlay: true error_message.text = textConstants.loginFailed
loops: MediaPlayer.Infinite }
source: config.background
muted: true
}
VideoOutput {
fillMode: VideoOutput.PreserveAspectCrop
anchors.fill: parent
source: mediaplayer
}
Rectangle {
anchors.fill: parent
color: "transparent"
Rectangle {
id: clockContainer
width: parent.width / 2
height: parent.height * 0.2
color: "transparent"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 40
Clock {
id: clock
color: "white"
timeFont.family: textFont.name
dateFont.family: textFont.name
}
} }
Rectangle { // Set Font
width: parent.width / 2
height: parent.height * 0.3
color: "transparent"
anchors.leftMargin: 40
anchors.top: clockContainer.bottom
anchors.left: parent.left
clip: true
Item { FontLoader {
id: usersContainer id: textFont; name: config.displayFont
width: 3 * parent.width / 4; }
height: parent.height
Column { // Set Background Image
id: nameColumn Repeater {
width: parent.width * 0.4 model: screenModel
spacing: 10 Background {
anchors.margins: 10 id: background
x: geometry.x; y: geometry.y; width: geometry.width; height:geometry.height
Text { source: config.background
id: lblName fillMode: Image.PreserveAspectCrop
width: parent.width onStatusChanged: {
text: textConstants.userName if (status == Image.Error && source != config.defaultBackground) {
font.family: textFont.name source = config.defaultBackground
font.bold: true }
font.pixelSize: 16
color: "white"
}
TextBox {
id: name
width: parent.width
text: userModel.lastUser
font: textFont.name
color: "#25000000"
borderColor: "transparent"
textColor: "white"
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
sddm.login(name.text, password.text, session.index)
event.accepted = true
}
} }
KeyNavigation.backtab: layoutBox; KeyNavigation.tab: password
}
Text {
id: errorMessage
anchors.left: name.left
//text: textConstants.prompt
font.family: textFont.name
font.pixelSize: 12
color: "white"
}
} }
Column {
id: passColumn
width: parent.width * 0.4
spacing: 10
anchors.margins: 10
anchors.left: nameColumn.right
Text {
id: lblPassword
width: parent.width
text: textConstants.password
font.family: textFont.name
font.bold: true
font.pixelSize: 16
color: "white"
}
PasswordBox {
id: password
width: parent.width
font: textFont.name
color: "#25000000"
borderColor: "transparent"
textColor: "white"
tooltipBG: "#25000000"
tooltipFG: "#dc322f"
image: "warning_red.png"
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
sddm.login(name.text, password.text, session.index)
event.accepted = true
}
}
KeyNavigation.backtab: name; KeyNavigation.tab: loginButton
}
Button {
id: loginButton
text: textConstants.login
width: parent.width * 0.4
anchors.right: password.right
color: "#404753"
disabledColor: "#dc322f"
activeColor: "#268bd2"
pressedColor: "#2aa198"
textColor: "white"
font: textFont.name
onClicked: sddm.login(name.text, password.text, session.index)
KeyNavigation.backtab: password; KeyNavigation.tab: btnReboot
}
}
}
} }
}
Rectangle {
id: actionBar
anchors.top: parent.top;
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width; height: 40
color: "transparent"
Row { // Set Background Video
anchors.left: parent.left MediaPlayer {
anchors.margins: 5 id: mediaplayer
height: parent.height autoPlay: true
spacing: 10 loops: MediaPlayer.Infinite
source: config.background
muted: true
}
Text { VideoOutput {
height: parent.height fillMode: VideoOutput.PreserveAspectCrop
anchors.verticalCenter: parent.verticalCenter anchors.fill: parent
source: mediaplayer
}
font.family: textFont.name // Clock and Login Area
verticalAlignment: Text.AlignVCenter Rectangle {
id: rectangle
anchors.fill: parent
color: "transparent" color: "transparent"
}
ComboBox { Rectangle {
id: session id: login_container
width: 245 y: 566
height: 20 width: parent.width * 0.3
anchors.verticalCenter: parent.verticalCenter height: parent.height * 0.2
color: "#25000000" color: "transparent"
textColor: "white" anchors.left: parent.left
borderColor: "transparent" anchors.leftMargin: 174
hoverColor: "#073642"
arrowColor: "#25000000"
model: sessionModel Row {
index: sessionModel.lastIndex id: username_row
anchors.right: parent.right
anchors.rightMargin: 100
anchors.left: parent.left
anchors.leftMargin: 100
transformOrigin: Item.Center
anchors.margins: 10
spacing: 10
KeyNavigation.backtab: btnShutdown; KeyNavigation.tab: layoutBox Text {
} id: username_label
width: 376
text: textConstants.userName
horizontalAlignment: Text.AlignHCenter
font.family: textFont.name
font.bold: true
font.pixelSize: 16
color: "white"
}
Text { TextBox {
height: parent.height id: username_input_box
anchors.verticalCenter: parent.verticalCenter width: parent.width
text: userModel.lastUser
font: textFont.name
color: "#25000000"
borderColor: "transparent"
textColor: "white"
font.family: textFont.name Keys.onPressed: {
font.pixelSize: 16 if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
font.bold: true sddm.login(username_input_box.text, password_input_box.text, session.index)
verticalAlignment: Text.AlignVCenter event.accepted = true
color: "white" }
} }
ComboBox { KeyNavigation.backtab: layoutBox; KeyNavigation.tab: password_input_box
id: layoutBox }
model: keyboard.layouts Text {
index: keyboard.currentLayout id: error_message
width: 50 font.family: textFont.name
height: 20 font.pixelSize: 12
anchors.verticalCenter: parent.verticalCenter color: "white"
color: "#25000000" anchors.left: username_input_box.left
textColor: "white" anchors.leftMargin: 376
borderColor: "transparent" }
hoverColor: "#073642" }
arrowIcon: "arrow.svg"
arrowColor: "#25000000"
onValueChanged: keyboard.currentLayout = id Row {
id: password_row
anchors.right: parent.right
anchors.rightMargin: 100
anchors.left: parent.left
anchors.leftMargin: 100
anchors.top: username_row.bottom
anchors.topMargin: 10
spacing: 10
Connections { Text {
target: keyboard id: password_label
width: parent.width
text: textConstants.password
horizontalAlignment: Text.AlignHCenter
font.family: textFont.name
font.bold: true
font.pixelSize: 16
color: "white"
}
PasswordBox {
id: password_input_box
width: parent.width
font: textFont.name
color: "#25000000"
borderColor: "transparent"
textColor: "white"
tooltipBG: "#25000000"
tooltipFG: "#dc322f"
image: "warning_red.png"
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
sddm.login(username_input_box.text, password_input_box.text, session.index)
event.accepted = true
}
}
KeyNavigation.backtab: username_input_box; KeyNavigation.tab: login_button
}
}
Button {
id: login_button
text: textConstants.login
anchors.top: password_input_box.bottom
anchors.topMargin: 5
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
color: "#404753"
disabledColor: "#dc322f"
activeColor: "#268bd2"
pressedColor: "#2aa198"
textColor: "white"
font: textFont.name
onClicked: sddm.login(username_input_box.text, password_input_box.text, session.index)
KeyNavigation.backtab: password_input_box; KeyNavigation.tab: reboot_button
}
onCurrentLayoutChanged: combo.index = keyboard.currentLayout
} }
rowDelegate: Rectangle { Clock {
color: "transparent" id: clock
y: 405
Text {
anchors.margins: 4
anchors.top: parent.top
anchors.bottom: parent.bottom
verticalAlignment: Text.AlignVCenter
text: modelItem ? modelItem.modelData.shortName : "zz"
font.family: textFont.name
font.pixelSize: 14
color: "white" color: "white"
} anchors.left: parent.left
anchors.leftMargin: 268
timeFont.family: textFont.name
dateFont.family: textFont.name
} }
KeyNavigation.backtab: session; KeyNavigation.tab: name
}
} }
Row { // Top Bar
height: parent.height Rectangle {
anchors.right: parent.right id: actionBar
anchors.margins: 5 anchors.top: parent.top;
spacing: 10 anchors.horizontalCenter: parent.horizontalCenter
width: parent.width; height: 40
color: "transparent"
ImageButton { Row {
id: btnReboot id: row_left
height: parent.height anchors.left: parent.left
source: "reboot.svg" anchors.margins: 5
height: parent.height
spacing: 10
visible: sddm.canReboot Text {
onClicked: sddm.reboot() height: parent.height
KeyNavigation.backtab: loginButton; KeyNavigation.tab: btnShutdown anchors.verticalCenter: parent.verticalCenter
}
ImageButton { font.family: textFont.name
id: btnShutdown verticalAlignment: Text.AlignVCenter
height: parent.height color: "transparent"
source: "shutdown.svg" }
visible: sddm.canPowerOff ComboBox {
id: session
width: 145
height: 20
anchors.verticalCenter: parent.verticalCenter
color: "transparent"
textColor: "white"
borderColor: "transparent"
hoverColor: "#073642"
arrowColor: "#25000000"
onClicked: sddm.powerOff() model: sessionModel
index: sessionModel.lastIndex
KeyNavigation.backtab: btnReboot; KeyNavigation.tab: session KeyNavigation.backtab: shutdown_button; KeyNavigation.tab: layoutBox
} }
Text {
height: parent.height
anchors.verticalCenter: parent.verticalCenter
font.family: textFont.name
font.pixelSize: 16
font.bold: true
verticalAlignment: Text.AlignVCenter
color: "white"
}
ComboBox {
id: language
model: keyboard.layouts
index: keyboard.currentLayout
width: 50
height: 20
anchors.verticalCenter: parent.verticalCenter
color: "transparent"
textColor: "white"
borderColor: "transparent"
hoverColor: "#073642"
arrowIcon: "arrow.svg"
arrowColor: "#25000000"
onValueChanged: keyboard.currentLayout = id
Connections {
target: keyboard
onCurrentLayoutChanged: combo.index = keyboard.currentLayout
}
rowDelegate: Rectangle {
color: "transparent"
Text {
anchors.margins: 4
anchors.top: parent.top
anchors.bottom: parent.bottom
verticalAlignment: Text.AlignVCenter
text: modelItem ? modelItem.modelData.shortName : "zz"
font.family: textFont.name
font.pixelSize: 14
color: "white"
}
}
KeyNavigation.backtab: session; KeyNavigation.tab: username_input_box
}
}
Row {
id: row_right
height: parent.height
anchors.right: parent.right
anchors.margins: 5
spacing: 10
ImageButton {
id: reboot_button
height: parent.height
source: "reboot.svg"
visible: sddm.canReboot
onClicked: sddm.reboot()
KeyNavigation.backtab: login_button; KeyNavigation.tab: shutdown_button
}
ImageButton {
id: shutdown_button
height: parent.height
source: "shutdown.svg"
visible: sddm.canPowerOff
onClicked: sddm.powerOff()
KeyNavigation.backtab: reboot_button; KeyNavigation.tab: session
}
}
} }
}
Component.onCompleted: {
if (name.text == "") // Set Focus
name.focus = true Component.onCompleted: {
if (username_input_box.text == "")
username_input_box.focus = true
else else
password.focus = true password_input_box.focus = true
} }
} }