Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customizable shortcuts settings #180

Merged
merged 38 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a5a9a03
remove old non working azerty thing
Ichunjo Aug 29, 2024
06011ee
increase logging level for the time being
Ichunjo Aug 29, 2024
8c5580f
remvoe legacy add_shortcuts in MainToolbar
Ichunjo Aug 29, 2024
f456aa1
fix sync_outputs_checkbox not in `__slots__`
Ichunjo Aug 29, 2024
7ba325f
add Shortcut QObject
Ichunjo Aug 29, 2024
c95306e
implement ShortCutsSettings
Ichunjo Aug 29, 2024
5a059bd
ajust settings Width
Ichunjo Aug 29, 2024
9ed2de3
make the window scrollable
Ichunjo Aug 31, 2024
40dbcae
fix ui
Ichunjo Aug 31, 2024
c5a4381
add script error dialog section
Ichunjo Aug 31, 2024
12d5b1d
add graphics view section
Ichunjo Aug 31, 2024
5ca0bd2
fix save button not displaying any message in status bar
Ichunjo Aug 31, 2024
3f83a8a
set default when setting up ui
Ichunjo Aug 31, 2024
c2e0803
add ToolbarPlaybackSection
Ichunjo Aug 31, 2024
b82d6b0
🇫🇷
Ichunjo Sep 1, 2024
2afa614
don't make shortcuts for unassigned ones
Ichunjo Sep 1, 2024
3d9d678
actually remove the colons
Ichunjo Sep 1, 2024
76fd2f0
add ToolbarSceningSection
Ichunjo Sep 1, 2024
41feb78
add forgotten actions to customizable shortcuts
Ichunjo Sep 2, 2024
e881740
allow lineedit
Ichunjo Sep 2, 2024
86a9477
add new shortcuts
Ichunjo Sep 2, 2024
bb53885
add hint to user for conflicts
Ichunjo Sep 2, 2024
14ddc2c
trim trailing space
Ichunjo Sep 2, 2024
34d171a
add ToolbarMiscSection
Ichunjo Sep 3, 2024
04ce850
add ToolbarPipetteSection
Ichunjo Sep 3, 2024
2a2ba58
remove legacy add_shortcut system
Ichunjo Sep 3, 2024
ae6553e
add delete_scene shortcut
Ichunjo Sep 3, 2024
62b34da
update scening_list_dialog size when current list changed
Ichunjo Sep 3, 2024
4dd1490
format, flake8 and mypy
Ichunjo Sep 3, 2024
fa68579
fix scening_list_dialog size
Ichunjo Sep 4, 2024
9625aa9
make a distinction between singleton and non singleton
Ichunjo Sep 4, 2024
df75415
add PluginSection
Ichunjo Sep 4, 2024
c36e9c4
Revert "increase logging level for the time being"
Ichunjo Sep 5, 2024
7def9fd
fix delete_scene not being saved
Ichunjo Sep 5, 2024
369383f
fix yaml tag not allowed when using a tuple
Ichunjo Oct 10, 2024
d37bed6
allow Modifier to the yaml loader
Ichunjo Oct 19, 2024
01eb2dd
fix TYPE_CHECKING statements
Ichunjo Oct 19, 2024
f657a4c
fix objects imported but unused
Ichunjo Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/accessibility/keybinds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ Toolbars
- Description
* - Ctrl + Space
- Add current frame as single frame scene
* - Q (AZERTY layout: A)
* - Q
- Toggle whether current frame is first frame
* - W (AZERTY layout: Z)
* - W
- Toggle whether current frame is last frame
* - E
- Add current A-B selection to current scene list
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
count = True
ignore = W503
ignore = W503, E704
max-line-length = 120
exclude = stubs/*
show-source = True
Expand Down
57 changes: 47 additions & 10 deletions vspreview/core/abstracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from PyQt6.QtCore import QObject, Qt, QTimer, pyqtSignal
from PyQt6.QtGui import QKeySequence, QShortcut
from PyQt6.QtWidgets import (
QApplication, QBoxLayout, QCheckBox, QDialog, QDoubleSpinBox, QFrame, QHBoxLayout, QLineEdit, QProgressBar,
QPushButton, QSpacerItem, QSpinBox, QTableView, QVBoxLayout, QWidget
QApplication, QBoxLayout, QCheckBox, QDialog, QDoubleSpinBox, QFrame, QHBoxLayout, QLineEdit,
QProgressBar, QPushButton, QScrollArea, QSpacerItem, QSpinBox, QTableView, QVBoxLayout, QWidget
)

from .bases import QABC, QYAMLObjectSingleton, SafeYAMLObject
Expand All @@ -30,13 +30,15 @@

'SpinBox', 'PushButton', 'LineEdit', 'CheckBox', 'Timer', 'ProgressBar', 'DoubleSpinBox',

'Shortcut',

'AbstractQItem', 'AbstractYAMLObject',

'ExtendedWidgetBase', 'ExtendedWidget', 'ExtendedDialog', 'ExtendedTableView',
'ExtendedWidgetBase', 'ExtendedWidget', 'ExtendedDialog', 'ExtendedTableView', 'ExtendedScrollArea',

'NotchProvider',

'AbstractSettingsWidget',
'AbstractSettingsWidget', 'AbstractSettingsScrollArea',

'AbstractToolbar', 'AbstractToolbarSettings',

Expand Down Expand Up @@ -261,13 +263,19 @@ class DoubleSpinBox(ExtendedItemInit, QDoubleSpinBox):
...


class Shortcut(QShortcut):
def __init__(
self, key: QKeySequence | QKeySequence.StandardKey | str | int | None,
parent: QObject | None, handler: Callable[[], None]
) -> None:
super().__init__(key, parent)
self.activated.connect(handler)


class AbstractQItem:
__slots__: tuple[str, ...]
storable_attrs: ClassVar[tuple[str, ...]] = ()

def add_shortcut(self, key: int, handler: Callable[[], None]) -> None:
QShortcut(QKeySequence(key), self, activated=handler) # type: ignore

def set_qobject_names(self) -> None:
if not hasattr(self, '__slots__'):
return
Expand Down Expand Up @@ -307,9 +315,6 @@ def setup_ui(self) -> None:
self.vlayout = VBoxLayout(self)
self.hlayout = HBoxLayout(self.vlayout)

def add_shortcuts(self) -> None:
pass

def get_separator(self, horizontal: bool = False) -> QFrame:
separator = QFrame(self)
separator.setFrameShape(QFrame.Shape.HLine if horizontal else QFrame.Shape.VLine)
Expand All @@ -329,6 +334,21 @@ class ExtendedTableView(AbstractQItem, QTableView):
...


class ExtendedScrollArea(ExtendedWidgetBase, QScrollArea):
frame: QFrame

def setup_ui(self) -> None:
self.setWidgetResizable(True)

self.frame = QFrame(self)

super().setup_ui()

self.frame.setLayout(self.vlayout)

self.setWidget(self.frame)


class AbstractSettingsWidget(ExtendedWidget, QYAMLObjectSingleton):
__slots__ = ()

Expand All @@ -350,6 +370,23 @@ def __getstate__(self) -> dict[str, Any]:
return {}


class AbstractSettingsScrollArea(ExtendedScrollArea, QYAMLObjectSingleton):
def __init__(self) -> None:
super().__init__()

self.setup_ui()

self.set_defaults()

self.set_qobject_names()

def set_defaults(self) -> None:
pass

def __getstate__(self) -> dict[str, Any]:
return {}


class AbstractToolbarSettings(AbstractSettingsWidget):
_add_to_tab = True

Expand Down
9 changes: 1 addition & 8 deletions vspreview/main/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from typing import TYPE_CHECKING

from PyQt6.QtCore import QKeyCombination, Qt
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QCloseEvent
from PyQt6.QtWidgets import QLabel, QTabWidget, QWidget

Expand All @@ -30,7 +30,6 @@ def __init__(self, main_window: MainWindow) -> None:
self.setModal(True)

self.setup_ui()
self.setup_shortcuts()

self.set_qobject_names()

Expand All @@ -48,12 +47,6 @@ def setup_ui(self) -> None:
[self.reload_button, self.exit_button] if self.main.reload_enabled else [self.exit_button]
))

def setup_shortcuts(self) -> None:
if self.main.reload_enabled:
self.add_shortcut(QKeyCombination(Qt.Modifier.CTRL, Qt.Key.Key_R).toCombined(), self.reload_button.click)

self.add_shortcut(Qt.Key.Key_Escape, self.exit_button.click)

def on_reload_clicked(self, clicked: bool | None = None) -> None:
self.hide()
self.main.reload_script()
Expand Down
17 changes: 3 additions & 14 deletions vspreview/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MainSettings(AbstractToolbarSettings):
'png_compressing_spinbox', 'statusbar_timeout_control',
'timeline_notches_margin_spinbox', 'usable_cpus_spinbox',
'zoom_levels_combobox', 'zoom_levels_lineedit', 'zoom_level_default_combobox',
'azerty_keyboard_checkbox', 'dragnavigator_timeout_spinbox', 'dragtimeline_timeout_spinbox',
'dragnavigator_timeout_spinbox', 'dragtimeline_timeout_spinbox',
'color_management_checkbox', 'plugins_save_position_combobox'
)

Expand Down Expand Up @@ -61,8 +61,6 @@ def setup_ui(self) -> None:

self.usable_cpus_spinbox = SpinBox(self, 1, self.get_usable_cpus_count())

self.azerty_keyboard_checkbox = CheckBox('AZERTY Keyboard', self)

self.zoom_levels_combobox = ComboBox[int](editable=True, insertPolicy=QComboBox.InsertPolicy.NoInsert)
self.zoom_levels_lineedit = self.zoom_levels_combobox.lineEdit()

Expand Down Expand Up @@ -91,10 +89,8 @@ def setup_ui(self) -> None:

HBoxLayout(self.vlayout, [QLabel('Base PPI'), self.base_ppi_spinbox])

HBoxLayout(self.vlayout, [
VBoxLayout([self.dark_theme_checkbox, self.opengl_rendering_checkbox]),
VBoxLayout([self.force_old_storages_removal_checkbox, self.azerty_keyboard_checkbox])
])
HBoxLayout(self.vlayout, [self.dark_theme_checkbox, self.force_old_storages_removal_checkbox])
HBoxLayout(self.vlayout, [self.opengl_rendering_checkbox])

HBoxLayout(self.vlayout, [QLabel('Default output index'), self.output_index_spinbox])

Expand Down Expand Up @@ -141,7 +137,6 @@ def set_defaults(self) -> None:
self.statusbar_timeout_control.setValue(Time(seconds=2.5))
self.timeline_notches_margin_spinbox.setValue(20)
self.force_old_storages_removal_checkbox.setChecked(False)
self.azerty_keyboard_checkbox.setChecked(False)
self.usable_cpus_spinbox.setValue(self.get_usable_cpus_count())
self.dragnavigator_timeout_spinbox.setValue(250)
self.dragtimeline_timeout_spinbox.setValue(40)
Expand Down Expand Up @@ -187,10 +182,6 @@ def timeline_label_notches_margin(self) -> int:
def force_old_storages_removal(self) -> int:
return main_window().force_storage or self.force_old_storages_removal_checkbox.isChecked()

@property
def azerty_keybinds(self) -> bool:
return self.azerty_keyboard_checkbox.isChecked()

@property
def usable_cpus_count(self) -> int:
return self.usable_cpus_spinbox.value()
Expand Down Expand Up @@ -329,7 +320,6 @@ def __getstate__(self) -> dict[str, Any]:
'dragtimeline_timeout': self.dragtimeline_timeout,
'plugins_bar_save_behaviour_index': self.plugins_bar_save_behaviour,
'color_management': self.color_management,
'azerty_keybinds': self.azerty_keybinds,
}

def __setstate__(self, state: dict[str, Any]) -> None:
Expand All @@ -349,7 +339,6 @@ def __setstate__(self, state: dict[str, Any]) -> None:
try_load(state, 'output_primaries_index', int, self.primaries_combobox.setCurrentIndex)
try_load(state, 'plugins_bar_save_behaviour_index', int, self.plugins_save_position_combobox.setCurrentIndex)
try_load(state, 'color_management', bool, self.color_management_checkbox.setChecked)
try_load(state, 'azerty_keybinds', bool, self.azerty_keyboard_checkbox.setChecked)


class WindowSettings(QYAMLObjectSingleton):
Expand Down
Loading