Skip to content

Commit

Permalink
fix reset button logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichunjo committed Nov 25, 2024
1 parent f30e9ee commit 5c4bced
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions vspreview/shortcuts/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"AbtractShortcutSectionQYAMLObject",
"ShortCutLineEdit",
"ResetPushButton",
"HiddenResetPushButton",
"TitleLabel",
"Modifier",
"ModifierModel",
Expand Down Expand Up @@ -126,10 +125,8 @@ def __init__(
super().__init__(name, *args, tooltip=tooltip, **kwargs)
self.setMaximumWidth(55)


class HiddenResetPushButton(ResetPushButton):
def __init__(self) -> None:
super().__init__("")
def make_hidden(self) -> None:
self.setText(None)
self.setFlat(True)
self.setEnabled(False)

Expand Down Expand Up @@ -175,21 +172,15 @@ def setup_ui(self) -> None: ...
def setup_ui_shortcut(
self, label: str, widget: QWidget, default: QKeySequence | None = None, hide_reset: bool = False
) -> None:
childrens: list[QWidget] = [QLabel(label), widget]
button = ResetPushButton("Reset", self.parent)

button: QWidget

if hide_reset or default is None:
button = HiddenResetPushButton()
elif isinstance(widget, ShortCutLineEdit):
button = ResetPushButton("Reset", self.parent, clicked=lambda: widget.setText(default.toString()))
widget.setText(default.toString())
if not isinstance(widget, ShortCutLineEdit) or hide_reset or default is None:
button.make_hidden()
else:
button = widget

childrens.append(button)

HBoxLayout(self.parent.vlayout, childrens)
widget.setText(default.toString())
button.clicked.connect(lambda: widget.setText(default.toString()))

HBoxLayout(self.parent.vlayout, [QLabel(label), widget, button])

def setup_shortcuts(self) -> None: ...

Expand Down

0 comments on commit 5c4bced

Please sign in to comment.