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 # QtCreator local machine specific files for imported projects
*creator.user* *creator.user*
/build/*

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

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

@ -1,6 +1,5 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>qml/LockScreen.qml</file> <file>qml/LockScreen.qml</file>
<file>qml/Greeter.qml</file>
</qresource> </qresource>
</RCC> </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.Window 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import Cutefish.Accounts 1.0 as Accounts
import FishUI 1.0 as FishUI import FishUI 1.0 as FishUI
Item { Item {
@ -11,6 +31,9 @@ Item {
property alias notification: message.text property alias notification: message.text
LayoutMirroring.enabled: Qt.locale().textDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
Image { Image {
id: wallpaperImage id: wallpaperImage
anchors.fill: parent anchors.fill: parent
@ -33,66 +56,226 @@ Item {
visible: true visible: true
} }
ColumnLayout { Accounts.UserAccount {
anchors.fill: parent id: currentUser
spacing: FishUI.Units.largeSpacing * 1.5 }
Item { Timer {
Layout.fillHeight: true 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 { Label {
id: timeLabel
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
text: "cutefish" font.pointSize: 35
color: "white" color: "white"
}
TextField { function updateInfo() {
id: password timeLabel.text = new Date().toLocaleString(Qt.locale(), "hh:mm")
Layout.alignment: Qt.AlignHCenter }
Layout.preferredHeight: 40 }
Layout.preferredWidth: 240
placeholderText: qsTr("Password")
focus: true
echoMode: TextInput.Password Label {
id: dateLabel
anchors.top: timeLabel.bottom
anchors.topMargin: FishUI.Units.largeSpacing
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: 19
color: "white"
background: Rectangle { function updateInfo() {
color: "white" dateLabel.text = new Date().toLocaleDateString(Qt.locale(), Locale.LongFormat)
opacity: 0.4
radius: FishUI.Theme.bigRadius
} }
}
Keys.onEnterPressed: authenticator.tryUnlock(password.text) DropShadow {
Keys.onReturnPressed: authenticator.tryUnlock(password.text) anchors.fill: timeLabel
Keys.onEscapePressed: password.text = "" 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
} }
Button { DropShadow {
Layout.alignment: Qt.AlignHCenter anchors.fill: dateLabel
Layout.preferredHeight: 40 source: dateLabel
Layout.preferredWidth: 240 z: -1
text: qsTr("Unlock") horizontalOffset: 1
onClicked: authenticator.tryUnlock(password.text) verticalOffset: 1
radius: 10
samples: radius * 4
spread: 0.35
color: Qt.rgba(0, 0, 0, 0.8)
opacity: 0.1
visible: true
} }
}
Label { Item {
id: message id: _mainItem
text: "" anchors.centerIn: parent
Layout.alignment: Qt.AlignHCenter width: 260 + FishUI.Units.largeSpacing * 3
font.bold: true height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 4
color: "white"
Behavior on opacity { Layout.alignment: Qt.AlignHCenter
NumberAnimation {
duration: 250 Rectangle {
anchors.fill: parent
radius: FishUI.Theme.bigRadius + 2
color: FishUI.Theme.darkMode ? "#424242" : "white"
opacity: 0.5
}
ColumnLayout {
id: _mainLayout
anchors.fill: parent
anchors.margins: FishUI.Units.largeSpacing * 1.5
spacing: FishUI.Units.smallSpacing
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
}
}
} }
} }
opacity: text == "" ? 0 : 1
Label {
Layout.alignment: Qt.AlignHCenter
text: currentUser.userName
}
Item {
height: 1
}
TextField {
id: password
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: 40
Layout.preferredWidth: 260
placeholderText: qsTr("Password")
focus: true
echoMode: TextInput.Password
background: Rectangle {
color: FishUI.Theme.darkMode ? "#7B7B7B" : "white"
radius: FishUI.Theme.bigRadius
opacity: 0.5
}
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: 260
text: qsTr("Unlock")
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: ""
anchors.top: _mainItem.bottom
anchors.topMargin: FishUI.Units.largeSpacing
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
color: "white"
Behavior on opacity {
NumberAnimation {
duration: 250
}
} }
Item { opacity: text == "" ? 0 : 1
Layout.fillHeight: true }
function tryUnlock() {
if (!password.text) {
root.notification = qsTr("Please enter your password")
return
} }
authenticator.tryUnlock(password.text)
} }
Connections { Connections {
@ -100,6 +283,7 @@ Item {
function onFailed() { function onFailed() {
root.notification = qsTr("Unlocking failed") root.notification = qsTr("Unlocking failed")
} }
function onGraceLockedChanged() { function onGraceLockedChanged() {
if (!authenticator.graceLocked) { if (!authenticator.graceLocked) {
root.notification = "" root.notification = ""
@ -107,9 +291,11 @@ Item {
password.focus = true password.focus = true
} }
} }
function onMessage(text) { function onMessage(text) {
root.notification = text root.notification = text
} }
function onError(text) { function onError(text) {
root.notification = text root.notification = text
} }

Loading…
Cancel
Save