From 2385b24d13c37f060367590e30a1423afbffc90d Mon Sep 17 00:00:00 2001 From: Isaac Wolford <98766012+cybergeek1943@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:45:17 -0600 Subject: [PATCH 1/2] Update line_edit.py - Adding new focus change Signals Added the following signals: - focusRecieved - focusLost This is useful because it provides an easy way to detect when the user has clicked on the LineEdit. For example, this could be used to show and hide a confirm button. --- qfluentwidgets/components/widgets/line_edit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qfluentwidgets/components/widgets/line_edit.py b/qfluentwidgets/components/widgets/line_edit.py index 7e00bb3fe..63ae98976 100644 --- a/qfluentwidgets/components/widgets/line_edit.py +++ b/qfluentwidgets/components/widgets/line_edit.py @@ -56,7 +56,10 @@ def paintEvent(self, e): class LineEdit(QLineEdit): """ Line edit """ - + + focusLost: Signal = Signal() + focusRecieved: Signal = Signal() + def __init__(self, parent=None): super().__init__(parent=parent) self._isClearButtonEnabled = False @@ -100,11 +103,13 @@ def completer(self): def focusOutEvent(self, e): super().focusOutEvent(e) self.clearButton.hide() + self.focusLost.emit() def focusInEvent(self, e): super().focusInEvent(e) if self.isClearButtonEnabled(): self.clearButton.setVisible(bool(self.text())) + self.focusRecieved.emit() def __onTextChanged(self, text): """ text changed slot """ @@ -434,4 +439,4 @@ def inputMethodQuery(self, query: Qt.InputMethodQuery): else: return super().inputMethodQuery(query) - passwordVisible = Property(bool, isPasswordVisible, setPasswordVisible) \ No newline at end of file + passwordVisible = Property(bool, isPasswordVisible, setPasswordVisible) From 00956a2c8319a377e87a9e4dbecb4f5e97ad0759 Mon Sep 17 00:00:00 2001 From: Isaac Wolford <98766012+cybergeek1943@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:06:50 -0600 Subject: [PATCH 2/2] Update line_edit.py - Correct spelling mistake --- qfluentwidgets/components/widgets/line_edit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qfluentwidgets/components/widgets/line_edit.py b/qfluentwidgets/components/widgets/line_edit.py index 63ae98976..296086650 100644 --- a/qfluentwidgets/components/widgets/line_edit.py +++ b/qfluentwidgets/components/widgets/line_edit.py @@ -58,7 +58,7 @@ class LineEdit(QLineEdit): """ Line edit """ focusLost: Signal = Signal() - focusRecieved: Signal = Signal() + focusReceived: Signal = Signal() def __init__(self, parent=None): super().__init__(parent=parent) @@ -109,7 +109,7 @@ def focusInEvent(self, e): super().focusInEvent(e) if self.isClearButtonEnabled(): self.clearButton.setVisible(bool(self.text())) - self.focusRecieved.emit() + self.focusReceived.emit() def __onTextChanged(self, text): """ text changed slot """