Skip to content

toolbar

Classes:

MainToolbar

MainToolbar(main_window: MainWindow)

Bases: AbstractToolbar

Methods:

Attributes:

Source code
39
40
41
42
43
44
45
def __init__(self, main_window: MainWindow) -> None:
    super().__init__(main_window, main_window.settings)
    self.setup_ui()

    self.outputs = None

    self.set_qobject_names()

class_storable_attrs class-attribute instance-attribute

class_storable_attrs = tuple[str, ...](('settings', 'visibility'))

hlayout instance-attribute

hlayout: HBoxLayout

is_notches_visible property

is_notches_visible: bool

main instance-attribute

main: MainWindow = main

name instance-attribute

name: str = __name__[:-7]

notches_changed class-attribute instance-attribute

notches_changed = pyqtSignal(ExtendedWidget)

num_keys class-attribute instance-attribute

num_keys = [
    Key_1,
    Key_2,
    Key_3,
    Key_4,
    Key_5,
    Key_6,
    Key_7,
    Key_8,
    Key_9,
    Key_0,
]

outputs instance-attribute

outputs: VideoOutputs | None = None

settings instance-attribute

settings: MainSettings

storable_attrs class-attribute instance-attribute

storable_attrs = ('outputs',)

toggle_button instance-attribute

toggle_button = PushButton(name, self, checkable=True, clicked=on_toggle)

visibility instance-attribute

visibility = False

vlayout instance-attribute

vlayout: VBoxLayout

get_notches

get_notches() -> Notches
Source code
405
406
407
def get_notches(self) -> Notches:
    from .custom import Notches
    return Notches()

get_separator

get_separator(horizontal: bool = False) -> QFrame
Source code
318
319
320
321
322
def get_separator(self, horizontal: bool = False) -> QFrame:
    separator = QFrame(self)
    separator.setFrameShape(QFrame.Shape.HLine if horizontal else QFrame.Shape.VLine)
    separator.setFrameShadow(QFrame.Shadow.Sunken)
    return separator

init_notches

init_notches(main: MainWindow = ...) -> None
Source code
402
403
def init_notches(self, main: MainWindow = ...) -> None:
    self.notches_changed.connect(main.timeline.update_notches)

on_copy_frame_button_clicked

on_copy_frame_button_clicked(checked: bool | None = None) -> None
Source code
130
131
132
def on_copy_frame_button_clicked(self, checked: bool | None = None) -> None:
    self.main.clipboard.setText(str(self.main.current_output.last_showed_frame))
    self.main.show_message('Current frame number copied to clipboard')

on_copy_timestamp_button_clicked

on_copy_timestamp_button_clicked(checked: bool | None = None) -> None
Source code
134
135
136
def on_copy_timestamp_button_clicked(self, checked: bool | None = None) -> None:
    self.main.clipboard.setText(self.time_control.text())
    self.main.show_message('Current timestamp copied to clipboard')

on_current_frame_changed

on_current_frame_changed(frame: Frame) -> None
Source code
113
114
115
116
117
118
def on_current_frame_changed(self, frame: Frame) -> None:
    qt_silent_call(self.frame_control.setValue, frame)
    qt_silent_call(self.time_control.setValue, Time(frame))

    if self.outputs and len(self.outputs) > 1 and self.sync_outputs_checkbox.isChecked():
        self.on_sync_outputs_clicked(True, force_frame=frame)

on_current_output_changed

on_current_output_changed(index: int, prev_index: int) -> None
Source code
120
121
122
123
def on_current_output_changed(self, index: int, prev_index: int) -> None:
    qt_silent_call(self.outputs_combobox.setCurrentIndex, index)
    qt_silent_call(self.frame_control.setMaximum, self.main.current_output.total_frames - 1)
    qt_silent_call(self.time_control.setMaximum, self.main.current_output.total_time)

on_switch_timeline_mode_clicked

on_switch_timeline_mode_clicked(checked: bool | None = None) -> None
Source code
138
139
140
141
142
def on_switch_timeline_mode_clicked(self, checked: bool | None = None) -> None:
    if self.main.timeline.mode == self.main.timeline.Mode.TIME:
        self.main.timeline.mode = self.main.timeline.Mode.FRAME
    elif self.main.timeline.mode == self.main.timeline.Mode.FRAME:
        self.main.timeline.mode = self.main.timeline.Mode.TIME

on_sync_outputs_clicked

on_sync_outputs_clicked(
    checked: bool | None = None, force_frame: Frame | None = None
) -> None
Source code
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def on_sync_outputs_clicked(self, checked: bool | None = None, force_frame: Frame | None = None) -> None:
    if not self.outputs:
        return

    if checked:
        from ...main.timeline import Timeline

        if not force_frame:
            force_frame = self.main.current_output.last_showed_frame

        if self.main.timeline.mode == Timeline.Mode.TIME:
            for output in self.outputs:
                output.last_showed_frame = output.to_frame(
                    self.main.current_output.to_time(force_frame)
                )
        else:
            for output in self.outputs:
                output.last_showed_frame = force_frame

on_toggle

on_toggle(new_state: bool) -> None
Source code
461
462
463
464
465
466
467
468
469
def on_toggle(self, new_state: bool) -> None:
    if new_state == self.visibility:
        return

    # invoking order matters
    self.setVisible(new_state)
    self.visibility = new_state
    self.toggle_button.setChecked(new_state)
    self.resize_main_window(new_state)

rescan_outputs

rescan_outputs(outputs: VideoOutputs | None = None) -> None
Source code
125
126
127
128
def rescan_outputs(self, outputs: VideoOutputs | None = None) -> None:
    self.outputs = outputs if isinstance(outputs, VideoOutputs) else VideoOutputs(self.main)
    self.main.init_outputs()
    self.outputs_combobox.setModel(self.outputs)

resize_main_window

resize_main_window(expanding: bool) -> None
Source code
481
482
483
484
485
486
487
488
489
def resize_main_window(self, expanding: bool) -> None:
    if self.main.windowState() in {Qt.WindowState.WindowMaximized, Qt.WindowState.WindowFullScreen}:
        return

    if expanding:
        self.main.resize(self.main.width(), self.main.height() + self.height() + round(6 * self.main.display_scale))
    if not expanding:
        self.main.resize(self.main.width(), self.main.height() - self.height() - round(6 * self.main.display_scale))
        self.main.timeline.update()

set_qobject_names

set_qobject_names() -> None
Source code
279
280
281
282
283
284
285
286
287
288
289
290
291
292
def set_qobject_names(self) -> None:
    if not hasattr(self, '__slots__'):
        return

    slots = list(self.__slots__)

    if isinstance(self, AbstractToolbar) and 'main' in slots:
        slots.remove('main')

    for attr_name in slots:
        attr = getattr(self, attr_name)
        if not isinstance(attr, QObject):
            continue
        attr.setObjectName(type(self).__name__ + '.' + attr_name)

setup_ui

setup_ui() -> None
Source code
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def setup_ui(self) -> None:
    super().setup_ui()

    self.setVisible(True)

    self.outputs_combobox = ComboBox[VideoOutput](
        self, editable=True, insertPolicy=QComboBox.InsertPolicy.InsertAtCurrent,
        duplicatesEnabled=True, sizeAdjustPolicy=QComboBox.SizeAdjustPolicy.AdjustToContents
    )
    self.outputs_combobox.currentIndexChanged.connect(self.main.switch_output)
    self.outputs_combobox.view().setMinimumWidth(
        self.outputs_combobox.minimumSizeHint().width()
    )

    self.frame_control = FrameEdit(self, valueChanged=self.main.switch_frame)
    if not self.settings.INSTANT_FRAME_UPDATE:
        self.frame_control.setKeyboardTracking(False)

    self.copy_frame_button = PushButton('⎘', self, clicked=self.on_copy_frame_button_clicked)

    self.time_control = TimeEdit(self, valueChanged=self.main.switch_frame)

    self.copy_timestamp_button = PushButton('⎘', self, clicked=self.on_copy_timestamp_button_clicked)

    self.sync_outputs_checkbox = CheckBox(
        'Sync Outputs', self, checked=self.settings.SYNC_OUTPUTS, clicked=self.on_sync_outputs_clicked
    )

    self.switch_timeline_mode_button = PushButton(
        'Switch Timeline Mode', self, clicked=self.on_switch_timeline_mode_clicked
    )

    self.settings_button = PushButton('Settings', self, clicked=self.main.app_settings.show)

    self.hlayout.addWidgets([
        self.outputs_combobox,
        self.frame_control, self.copy_frame_button,
        self.time_control, self.copy_timestamp_button,
        self.sync_outputs_checkbox,
        self.get_separator(),
        self.main.graphics_view.controls,
        self.switch_timeline_mode_button,
        self.settings_button
    ])

    self.hlayout.addStretch()