feat: widgets Qol features - #288
Conversation
29a696b to
4ba82e0
Compare
There was a problem hiding this comment.
What's good
- The first key after
set_value()now replaces the prefill instead of appending to it, which is what a touch keyboard should do. in_rangeis computed once instead of three times, andset_enforce_rangedefaults to enforcing, so every existing numpad caller keeps its behaviour.- A disabled
BlocksCustomLinEditnow looks disabled, and_disabled_bg_coloris allocated with the other paint colours instead of insidepaintEvent. - The keyboard select button gets a real
yes.svgicon. - Dead code gone: the empty
mouseReleaseEventoverride and the comment banners incolorWheelWidget. - The keyboard test is updated to the new replace behaviour.
1. keyboardPage.py:249: the firsttime wipe runs before the enter/clear branches, so the first tap after set_value() destroys the prefill
Open the keyboard on an existing SSID and tap Enter to accept it: an empty string is submitted. Tap Clear: the whole value is wiped instead of one char. networkWindow.py:3767, filamentTab.py:805, addFilamentPage.py:95 and addSpoolPage.py:165 all prefill through set_value(), so all of them are affected. Only a printable key should consume the flag:
def value_inserted(self, value: str) -> None:
if value == "&&":
value = "&"
if self.firsttime and value not in ("enter", "clear"):
self.current_value = ""
self.firsttime = False2. keyboardPage.py:217: firsttime is armed in show(), which Qt bypasses
setVisible(True), showFullScreen() and QStackedWidget.setCurrentWidget() never call the Python show() override, so the flag stays False and the next edit appends to the previous value. numpadPage already uses showEvent, match it:
def showEvent(self, a0: QtGui.QShowEvent | None) -> None:
self._geometry_calc()
self.firsttime = True
return super().showEvent(a0)3. numpadPage.py:64: in_range is computed before the clear branch changes current_value
clear shortens the value at lines 76-77, but the glow test at line 79 still uses the old snapshot, so the glow is one keystroke behind: deleting a digit back into range leaves it glowing, deleting out of range leaves it clean. Recompute after the change, and keep a separate snapshot for the enter branch if it needs the old value:
elif "clear" in value:
...
in_range = self.min_value <= int(self.current_value) <= self.max_value
if not in_range and self.enforce_range:4. numpadPage.py:44-45: showEvent resets enforce_range, silently undoing set_enforce_range(False)
Any caller that configures the numpad before showing it gets the setting reverted, so the API only works if called after show(), an ordering rule nobody can see. Reset enforce_range wherever min_value/max_value are reset instead:
def showEvent(self, a0: QtGui.QShowEvent | None) -> None:
self.firsttime = True
self.min_max_label.setVisible(self.enforce_range)
return super().showEvent(a0)5. blocks_linedit.py:107: the disabled state greys the background but not the text
_draw_text always uses self._text_color, so a disabled field paints full-black text on the new grey background and still reads as editable:
painter.setPen(self._text_color if self.isEnabled() else self._disabled_bg_color.darker(160))6. blocks_linedit.py:85: the isEnabled() guard in mousePressEvent is unreachable
Qt does not deliver mouse events to disabled widgets, they go to the parent. The guard is harmless but dead, the paintEvent change is what carries this feature:
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None:
"""Handle mouse press"""
self.clicked.emit()
super().mousePressEvent(event)7. colorWheelWidget.py:108: deleting the commented-out mousePressEvent leaves the wheel drag-only
_pick is only reachable from mouseMoveEvent, which needs movement. A clean tap on the touchscreen (press + release, no motion) selects nothing. The comment was the reminder that this was missing:
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None:
self._pick(event.position())8. numpadPage.py:146-148: the 60x60 QWidget spacer is a real widget in the tree
It only balances the header, a layout spacer does the same:
self.header_layout.addSpacing(60)
Description
BlocksScreen/lib/panels/widgets/keyboardPage.py
BlocksScreen/lib/utils/blocks_linedit.py
BlocksScreen/lib/panels/widgets/numpadPage.py