From d9e522f05f7bff284d64dadff96ecdf69debddf2 Mon Sep 17 00:00:00 2001 From: Jacob Babor Date: Sun, 12 Jan 2025 04:33:22 -0600 Subject: [PATCH] Fuck it we vendor more shit --- theme/Main.qml | 11 +- theme/components/SaltPasswordBox.qml | 162 +++++++++++++++++++++++++++ theme/components/SaltTextBox.qml | 92 +++++++++++++++ 3 files changed, 261 insertions(+), 4 deletions(-) create mode 100644 theme/components/SaltPasswordBox.qml create mode 100644 theme/components/SaltTextBox.qml diff --git a/theme/Main.qml b/theme/Main.qml index f7fd69b..70404a5 100644 --- a/theme/Main.qml +++ b/theme/Main.qml @@ -105,7 +105,7 @@ Rectangle { font.pixelSize: 13 } - TextBox { + SaltTextBox { id: name width: parent.width; height: 50 text: userModel.lastUser @@ -113,6 +113,7 @@ Rectangle { font.pixelSize: 13 radius: 8 textColor: "#ebdbb2" + borderWidth: 4 borderColor: "#32302f" focusColor: "#83a598" hoverColor: "#504945" @@ -142,13 +143,14 @@ Rectangle { font.pixelSize: 13 } - PasswordBox { + SaltPasswordBox { id: password width: parent.width; height: 50 font.family: "IBM Plex Sans" font.pixelSize: 13 radius: 8 textColor: "#ebdbb2" + borderWidth: 4 borderColor: "#32302f" focusColor: "#83a598" hoverColor: "#504945" @@ -188,6 +190,7 @@ Rectangle { radius: 8 textColor: "#ebdbb2" borderColor: "#32302f" + borderWidth: 4 focusColor: "#83a598" hoverColor: "#504945" color: "#282828" @@ -195,7 +198,7 @@ Rectangle { model: sessionModel index: sessionModel.lastIndex - KeyNavigation.backtab: password; KeyNavigation.tab: layoutBox + KeyNavigation.backtab: password; KeyNavigation.tab: loginButton } } @@ -225,7 +228,7 @@ Rectangle { onClicked: sddm.login(name.text, password.text, sessionIndex) - KeyNavigation.backtab: layoutBox; KeyNavigation.tab: shutdownButton + KeyNavigation.backtab: session; KeyNavigation.tab: shutdownButton font.family: "IBM Plex Sans" font.pixelSize: 13 textColor: "#282828" diff --git a/theme/components/SaltPasswordBox.qml b/theme/components/SaltPasswordBox.qml new file mode 100644 index 0000000..4aeb7d5 --- /dev/null +++ b/theme/components/SaltPasswordBox.qml @@ -0,0 +1,162 @@ +/*************************************************************************** +* Copyright (c) 2013 Nikita Mikhaylov +* +* 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.0 + +FocusScope { + id: container + width: 80; height: 30 + + property alias borderWidth: txtMain.borderWidth + property alias color: txtMain.color + property alias borderColor: txtMain.borderColor + property alias focusColor: txtMain.focusColor + property alias hoverColor: txtMain.hoverColor + property alias radius: txtMain.radius + property alias font: txtMain.font + property alias textColor: txtMain.textColor + property alias echoMode: txtMain.echoMode + property alias text: txtMain.text + + property alias image: img.source + property double imageFadeIn: 300 + property double imageFadeOut: 200 + + property alias tooltipEnabled: tooltip.visible + property alias tooltipText: tooltipText.text + property alias tooltipFG: tooltipText.color + property alias tooltipBG: tooltip.color + + SaltTextBox { + id: txtMain + width: parent.width; height: parent.height + font.pixelSize: 14 + + echoMode: TextInput.Password + + focus: true + } + + Image { + id: img + opacity: 0 + state: keyboard.capsLock ? "activated" : "" + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + fillMode: Image.PreserveAspectFit + + smooth: true + height: parent.height * 0.8 + + source: "warning.png" + sourceSize.width: width + sourceSize.height: height + + anchors.rightMargin: 0.3 * width + + states: [ + State { + name: "activated" + PropertyChanges { target: img; opacity: 1; } + }, + State { + name: "" + PropertyChanges { target: img; opacity: 0; } + } + ] + + transitions: [ + Transition { + to: "activated" + NumberAnimation { target: img; property: "opacity"; from: 0; to: 1; duration: imageFadeIn; } + }, + + Transition { + to: "" + NumberAnimation { target: img; property: "opacity"; from: 1; to: 0; duration: imageFadeOut; } + } + ] + + MouseArea { + id: hoverArea + + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.ArrowCursor + + onEntered: { + tooltip.x = mouseX + img.x + 10 + tooltip.y = mouseY + 10 + } + + onPositionChanged: { + tooltip.x = mouseX + img.x + 10 + tooltip.y = mouseY + 10 + } + } + } + + Rectangle { + id: tooltip + color: "lightblue" + border.color: "black" + border.width: 1 + + width: 1.1 * tooltipText.implicitWidth + height: 1.4 * tooltipText.implicitHeight + radius: 2 + opacity: 0 + + state: hoverArea.containsMouse && img.state == "activated" ? "activated" : "" + + states: [ + State { + name: "activated" + PropertyChanges { target: tooltip; opacity: 1 } + }, + State { + name: "" + PropertyChanges { target: tooltip; opacity: 0 } + } + ] + + transitions: [ + Transition { + to: "activated" + NumberAnimation { target: tooltip; property: "opacity"; from: 0; to: 1; duration: imageFadeIn; } + }, + + Transition { + to: "" + NumberAnimation { target: tooltip; property: "opacity"; from: 1; to: 0; duration: imageFadeOut; } + } + ] + + Text { + id: tooltipText + anchors.centerIn: parent; + text: textConstants.capslockWarning + } + } +} diff --git a/theme/components/SaltTextBox.qml b/theme/components/SaltTextBox.qml new file mode 100644 index 0000000..068daf0 --- /dev/null +++ b/theme/components/SaltTextBox.qml @@ -0,0 +1,92 @@ +/*************************************************************************** +* Copyright (c) 2013 Abdurrahman AVCI +* +* 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.0 + +FocusScope { + id: container + width: 80; height: 30 + + property color color: "white" + property color borderColor: "#ababab" + property color focusColor: "#266294" + property color hoverColor: "#5692c4" + property alias borderWidth: main.border.width + property alias radius: main.radius + property alias font: txtMain.font + property alias textColor: txtMain.color + property alias echoMode: txtMain.echoMode + property alias text: txtMain.text + + Rectangle { + id: main + + anchors.fill: parent + + color: container.color + border.color: container.borderColor + border.width: 1 + + states: [ + State { + name: "hover"; when: mouseArea.containsMouse + PropertyChanges { target: main; border.color: container.hoverColor } + }, + State { + name: "focus"; when: container.activeFocus && !mouseArea.containsMouse + PropertyChanges { target: main; border.color: container.focusColor } + } + ] + + transitions: Transition { + ColorAnimation { duration: 100 } + } + } + + MouseArea { + id: mouseArea + anchors.fill: container + + cursorShape: Qt.IBeamCursor + + hoverEnabled: true + + onEntered: if (main.state == "") main.state = "hover"; + onExited: if (main.state == "hover") main.state = ""; + onClicked: container.focus = true; + } + + TextInput { + id: txtMain + width: parent.width - 16 + anchors.centerIn: parent + + color: "black" + + clip: true + focus: true + + passwordCharacter: "\u25cf" + } +}