Skip to content

abstract

Classes:

MAX_WIDTH_LINE_EDIT module-attribute

MAX_WIDTH_LINE_EDIT = 90

MODIFIERS_KEYS module-attribute

MODIFIERS_KEYS = (Key_Control, Key_Alt, Key_Shift, Key_Meta)

AbtractShortcutSection

Methods:

Attributes:

parent instance-attribute

unassigned_default property

unassigned_default: QKeySequence

create_shortcut

create_shortcut(
    key: ShortCutLineEdit | QKeySequence | StandardKey | str | int | None,
    parent: QObject | None,
    handler: Callable[[], None],
) -> None
Source code
187
188
189
190
191
192
193
194
195
196
197
198
199
def create_shortcut(
    self,
    key: ShortCutLineEdit | QKeySequence | QKeySequence.StandardKey | str | int | None,
    parent: QObject | None,
    handler: Callable[[], None],
) -> None:
    if isinstance(key, str) and not key:
        return None

    if isinstance(key, ShortCutLineEdit):
        key = key.text()

    Shortcut(key, parent, handler)

setup_shortcuts

setup_shortcuts() -> None
Source code
185
def setup_shortcuts(self) -> None: ...

setup_ui

setup_ui() -> None
Source code
170
def setup_ui(self) -> None: ...

setup_ui_shortcut

setup_ui_shortcut(
    label: str,
    widget: QWidget,
    default: QKeySequence | None = None,
    hide_reset: bool = False,
) -> None
Source code
172
173
174
175
176
177
178
179
180
181
182
183
def setup_ui_shortcut(
    self, label: str, widget: QWidget, default: QKeySequence | None = None, hide_reset: bool = False
) -> None:
    button = ResetPushButton("Reset", self.parent)

    if not isinstance(widget, ShortCutLineEdit) or hide_reset or default is None:
        button.make_hidden()
    else:
        widget.setText(default.toString())
        button.clicked.connect(lambda: widget.setText(default.toString()))

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

AbtractShortcutSectionQYAMLObject

Bases: AbtractShortcutSection, QYAMLObject

Methods:

Attributes:

parent instance-attribute

unassigned_default property

unassigned_default: QKeySequence

create_shortcut

create_shortcut(
    key: ShortCutLineEdit | QKeySequence | StandardKey | str | int | None,
    parent: QObject | None,
    handler: Callable[[], None],
) -> None
Source code
187
188
189
190
191
192
193
194
195
196
197
198
199
def create_shortcut(
    self,
    key: ShortCutLineEdit | QKeySequence | QKeySequence.StandardKey | str | int | None,
    parent: QObject | None,
    handler: Callable[[], None],
) -> None:
    if isinstance(key, str) and not key:
        return None

    if isinstance(key, ShortCutLineEdit):
        key = key.text()

    Shortcut(key, parent, handler)

setup_shortcuts

setup_shortcuts() -> None
Source code
185
def setup_shortcuts(self) -> None: ...

setup_ui

setup_ui() -> None
Source code
170
def setup_ui(self) -> None: ...

setup_ui_shortcut

setup_ui_shortcut(
    label: str,
    widget: QWidget,
    default: QKeySequence | None = None,
    hide_reset: bool = False,
) -> None
Source code
172
173
174
175
176
177
178
179
180
181
182
183
def setup_ui_shortcut(
    self, label: str, widget: QWidget, default: QKeySequence | None = None, hide_reset: bool = False
) -> None:
    button = ResetPushButton("Reset", self.parent)

    if not isinstance(widget, ShortCutLineEdit) or hide_reset or default is None:
        button.make_hidden()
    else:
        widget.setText(default.toString())
        button.clicked.connect(lambda: widget.setText(default.toString()))

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

AbtractShortcutSectionYAMLObjectSingleton

Bases: AbtractShortcutSection, QAbstractYAMLObjectSingleton

Methods:

Attributes:

parent instance-attribute

unassigned_default property

unassigned_default: QKeySequence

create_shortcut

create_shortcut(
    key: ShortCutLineEdit | QKeySequence | StandardKey | str | int | None,
    parent: QObject | None,
    handler: Callable[[], None],
) -> None
Source code
187
188
189
190
191
192
193
194
195
196
197
198
199
def create_shortcut(
    self,
    key: ShortCutLineEdit | QKeySequence | QKeySequence.StandardKey | str | int | None,
    parent: QObject | None,
    handler: Callable[[], None],
) -> None:
    if isinstance(key, str) and not key:
        return None

    if isinstance(key, ShortCutLineEdit):
        key = key.text()

    Shortcut(key, parent, handler)

setup_shortcuts

setup_shortcuts() -> None
Source code
185
def setup_shortcuts(self) -> None: ...

setup_ui

setup_ui() -> None
Source code
170
def setup_ui(self) -> None: ...

setup_ui_shortcut

setup_ui_shortcut(
    label: str,
    widget: QWidget,
    default: QKeySequence | None = None,
    hide_reset: bool = False,
) -> None
Source code
172
173
174
175
176
177
178
179
180
181
182
183
def setup_ui_shortcut(
    self, label: str, widget: QWidget, default: QKeySequence | None = None, hide_reset: bool = False
) -> None:
    button = ResetPushButton("Reset", self.parent)

    if not isinstance(widget, ShortCutLineEdit) or hide_reset or default is None:
        button.make_hidden()
    else:
        widget.setText(default.toString())
        button.clicked.connect(lambda: widget.setText(default.toString()))

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

Modifier

Bases: Flag

Attributes:

ALT class-attribute instance-attribute

ALT = value

CTRL class-attribute instance-attribute

CTRL = value

META class-attribute instance-attribute

META = value

SHIFT class-attribute instance-attribute

SHIFT = value

modifier property

modifier: Modifier

ModifierModel

ModifierModel(init_seq: Sequence[T], to_title: bool = True)

Bases: GeneralModel[Modifier]

Methods:

Attributes:

Source code
35
36
37
38
def __init__(self, init_seq: Sequence[T], to_title: bool = True) -> None:
    super().__init__()
    self.items = list(init_seq)
    self.to_title = to_title

content_type instance-attribute

content_type: type[T]

items instance-attribute

items = list(init_seq)

to_title instance-attribute

to_title: bool = to_title

data

data(index: QModelIndex, role: int = UserRole) -> Any
Source code
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.UserRole) -> Any:
    if (not index.isValid() or index.row() >= len(self.items)):
        return None

    if role == Qt.ItemDataRole.DisplayRole:
        value = self.items[index.row()]

        str_value = self._displayValue(value)

        if self.content_type is str and self.to_title:
            return str_value.title()

        return str_value

    if role == Qt.ItemDataRole.UserRole:
        return self.items[index.row()]

    return None

index_of

index_of(item: T) -> int
Source code
49
50
def index_of(self, item: T) -> int:
    return self.items.index(item)

rowCount

rowCount(parent: QModelIndex = QModelIndex()) -> int
Source code
71
72
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
    return len(self.items)

ResetPushButton

ResetPushButton(
    name: str = "Reset",
    *args: QWidget | QBoxLayout | Stretch,
    tooltip: str | None = None,
    **kwargs: Any
)

Bases: PushButton

Methods:

Source code
122
123
124
125
126
def __init__(
    self, name: str = "Reset", *args: QWidget | QBoxLayout | Stretch, tooltip: str | None = None, **kwargs: Any
) -> None:
    super().__init__(name, *args, tooltip=tooltip, **kwargs)
    self.setMaximumWidth(55)

make_hidden

make_hidden() -> None
Source code
128
129
130
131
def make_hidden(self) -> None:
    self.setText(None)
    self.setFlat(True)
    self.setEnabled(False)

ShortCutLineEdit

ShortCutLineEdit(
    *args: QWidget | QBoxLayout | Stretch,
    placeholder: str = "",
    tooltip: str | None = None,
    allow_modifiers: bool = True,
    conflictable: bool = True,
    **kwargs: Any
)

Bases: LineEdit

Methods:

Attributes:

Source code
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def __init__(
    self,
    *args: QWidget | QBoxLayout | Stretch,
    placeholder: str = "",
    tooltip: str | None = None,
    allow_modifiers: bool = True,
    conflictable: bool = True,
    **kwargs: Any,
) -> None:
    super().__init__(placeholder, *args, tooltip=tooltip, **kwargs)

    self.allow_modifiers = allow_modifiers
    self._conflictable = conflictable

    self.keyPressed.connect(self.setText)
    self.textChanged.connect(self.highlight_conflits)

    self.setMaximumWidth(MAX_WIDTH_LINE_EDIT)

    self._old_text = self.text()

allow_modifiers instance-attribute

allow_modifiers = allow_modifiers

keyPressed class-attribute instance-attribute

keyPressed = pyqtSignal(str)

highlight_conflits

highlight_conflits(text: str | None) -> None
Source code
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def highlight_conflits(self, text: str | None) -> None:
    if text is None:
        return

    if text and self._conflictable:
        self.setProperty("conflictShortcut", False)
        self.repolish()

        self._shortcuts[self._old_text].discard(self)

        if len(shorcuts := self._shortcuts[self._old_text]) <= 1:
            for sc in shorcuts:
                sc.setProperty("conflictShortcut", False)
                sc.repolish()

        self._shortcuts[text].add(self)

        if len(conflicts := self._shortcuts[text]) > 1:
            for c in conflicts:
                c.setProperty("conflictShortcut", True)
                c.repolish()

    self._old_text = text

keyPressEvent

keyPressEvent(a0: QKeyEvent | None) -> None
Source code
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
def keyPressEvent(self, a0: QKeyEvent | None) -> None:
    if not a0:
        return None

    key = Qt.Key(a0.key())
    modifiers = a0.modifiers()

    if key in MODIFIERS_KEYS:
        keyname = self.text()
    elif self.allow_modifiers:
        keyname = QKeySequence(QKeyCombination(modifiers, key).toCombined()).toString()
    else:
        keyname = QKeySequence(key).toString()

    self.keyPressed.emit(keyname)

mouseDoubleClickEvent

mouseDoubleClickEvent(a0: QMouseEvent | None) -> None
Source code
109
110
111
112
113
def mouseDoubleClickEvent(self, a0: QMouseEvent | None) -> None:
    if not a0:
        return None

    self.setText(None)

repolish

repolish() -> None
Source code
115
116
117
118
def repolish(self) -> None:
    if style := self.style():
        style.unpolish(self)
        style.polish(self)

TitleLabel

TitleLabel(text: str, md_header: str = '##')

Bases: QLabel

Source code
135
136
137
138
139
def __init__(self, text: str, md_header: str = "##") -> None:
    super().__init__()
    self.setTextFormat(Qt.TextFormat.MarkdownText)
    self.setText(f"{md_header} {text}")
    self.updateGeometry()