Improve more details

pull/1/head
reionwong 5 years ago
parent 0e36014d15
commit 56a80f3822

2
.gitignore vendored

@ -50,3 +50,5 @@ compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*
/build/*

@ -12,11 +12,11 @@ set(PROJECT_SOURCES
qml.qrc
)
add_executable(screenlocker
add_executable(cutefish-screenlocker
${PROJECT_SOURCES}
)
target_link_libraries(screenlocker
target_link_libraries(cutefish-screenlocker
PRIVATE
Qt5::Core
Qt5::DBus
@ -26,3 +26,5 @@ target_link_libraries(screenlocker
${X11_LIBRARIES}
)
install(TARGETS cutefish-screenlocker RUNTIME DESTINATION /usr/bin)

@ -38,7 +38,7 @@ private:
QList<QQuickView *> m_views;
org_kde_ksld *m_ksldInterface = nullptr;
bool m_testing = true;
bool m_testing = false;
};
#endif // APPLICATION_H

@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/">
<file>qml/LockScreen.qml</file>
<file>qml/Greeter.qml</file>
</qresource>
</RCC>

@ -1,5 +0,0 @@
import QtQuick 2.0
Item {
}

@ -1,9 +1,29 @@
import QtQuick 2.0
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Rion Wong <reionwong@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import Cutefish.Accounts 1.0 as Accounts
import FishUI 1.0 as FishUI
Item {
@ -11,6 +31,9 @@ Item {
property alias notification: message.text
LayoutMirroring.enabled: Qt.locale().textDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
Image {
id: wallpaperImage
anchors.fill: parent
@ -33,66 +56,226 @@ Item {
visible: true
}
Accounts.UserAccount {
id: currentUser
}
Timer {
repeat: true
running: true
interval: 1000
onTriggered: {
timeLabel.updateInfo()
dateLabel.updateInfo()
}
}
Component.onCompleted: {
timeLabel.updateInfo()
dateLabel.updateInfo()
}
Item {
id: _topItem
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: _mainItem.top
anchors.bottomMargin: root.height * 0.1
Label {
id: timeLabel
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignHCenter
font.pointSize: 35
color: "white"
function updateInfo() {
timeLabel.text = new Date().toLocaleString(Qt.locale(), "hh:mm")
}
}
Label {
id: dateLabel
anchors.top: timeLabel.bottom
anchors.topMargin: FishUI.Units.largeSpacing
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: 19
color: "white"
function updateInfo() {
dateLabel.text = new Date().toLocaleDateString(Qt.locale(), Locale.LongFormat)
}
}
DropShadow {
anchors.fill: timeLabel
source: timeLabel
z: -1
horizontalOffset: 1
verticalOffset: 1
radius: 10
samples: radius * 4
spread: 0.35
color: Qt.rgba(0, 0, 0, 0.8)
opacity: 0.1
visible: true
}
DropShadow {
anchors.fill: dateLabel
source: dateLabel
z: -1
horizontalOffset: 1
verticalOffset: 1
radius: 10
samples: radius * 4
spread: 0.35
color: Qt.rgba(0, 0, 0, 0.8)
opacity: 0.1
visible: true
}
}
Item {
id: _mainItem
anchors.centerIn: parent
width: 260 + FishUI.Units.largeSpacing * 3
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 4
Layout.alignment: Qt.AlignHCenter
Rectangle {
anchors.fill: parent
radius: FishUI.Theme.bigRadius + 2
color: FishUI.Theme.darkMode ? "#424242" : "white"
opacity: 0.5
}
ColumnLayout {
id: _mainLayout
anchors.fill: parent
spacing: FishUI.Units.largeSpacing * 1.5
anchors.margins: FishUI.Units.largeSpacing * 1.5
spacing: FishUI.Units.smallSpacing
Item {
Layout.fillHeight: true
Image {
id: userIcon
property int iconSize: 60
Layout.preferredHeight: iconSize
Layout.preferredWidth: iconSize
sourceSize: Qt.size(iconSize, iconSize)
source: currentUser.iconFileName ? "file:///" + currentUser.iconFileName : "image://icontheme/default-user"
Layout.alignment: Qt.AlignHCenter
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: userIcon.width
height: userIcon.height
Rectangle {
anchors.fill: parent
radius: parent.height / 2
}
}
}
}
Label {
Layout.alignment: Qt.AlignHCenter
text: "cutefish"
color: "white"
text: currentUser.userName
}
Item {
height: 1
}
TextField {
id: password
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: 40
Layout.preferredWidth: 240
Layout.preferredWidth: 260
placeholderText: qsTr("Password")
focus: true
echoMode: TextInput.Password
background: Rectangle {
color: "white"
opacity: 0.4
color: FishUI.Theme.darkMode ? "#7B7B7B" : "white"
radius: FishUI.Theme.bigRadius
opacity: 0.5
}
Keys.onEnterPressed: authenticator.tryUnlock(password.text)
Keys.onReturnPressed: authenticator.tryUnlock(password.text)
Keys.onEnterPressed: root.tryUnlock()
Keys.onReturnPressed: root.tryUnlock()
Keys.onEscapePressed: password.text = ""
}
Button {
id: unlockBtn
hoverEnabled: true
focusPolicy: Qt.NoFocus
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: 40
Layout.preferredWidth: 240
Layout.preferredWidth: 260
text: qsTr("Unlock")
onClicked: authenticator.tryUnlock(password.text)
onClicked: root.tryUnlock()
scale: unlockBtn.pressed ? 0.95 : 1.0
Behavior on scale {
NumberAnimation {
duration: 100
}
}
// contentItem: Text {
// text: unlockBtn.text
// font: unlockBtn.font
// horizontalAlignment: Text.AlignHCenter
// verticalAlignment: Text.AlignVCenter
// elide: Text.ElideRight
// color: "#1C1C1C"
// }
background: Rectangle {
color: FishUI.Theme.darkMode ? "#7B7B7B" : "white"
opacity: unlockBtn.pressed ? 0.3 : unlockBtn.hovered ? 0.4 : 0.5
radius: FishUI.Theme.bigRadius
}
}
}
}
Label {
id: message
text: ""
Layout.alignment: Qt.AlignHCenter
anchors.top: _mainItem.bottom
anchors.topMargin: FishUI.Units.largeSpacing
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
color: "white"
Behavior on opacity {
NumberAnimation {
duration: 250
}
}
opacity: text == "" ? 0 : 1
}
Item {
Layout.fillHeight: true
function tryUnlock() {
if (!password.text) {
root.notification = qsTr("Please enter your password")
return
}
authenticator.tryUnlock(password.text)
}
Connections {
@ -100,6 +283,7 @@ Item {
function onFailed() {
root.notification = qsTr("Unlocking failed")
}
function onGraceLockedChanged() {
if (!authenticator.graceLocked) {
root.notification = ""
@ -107,9 +291,11 @@ Item {
password.focus = true
}
}
function onMessage(text) {
root.notification = text
}
function onError(text) {
root.notification = text
}

Loading…
Cancel
Save