Skip to content

Commit

Permalink
Add Ctrl+P shortcut to pop plugins in/out
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Sep 25, 2024
1 parent 594a231 commit 0b61f6e
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions vspreview/main/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,7 @@ def __init__(self, config_dir: SPath, no_exit: bool, reload_enabled: bool, force

Plugins(self)

def pop_out_plugins():
left, right = self.main_split.sizes()
if right:
new_sizes = [left + right, 0]
else:
min_right = int((left + right) * 0.2)
new_sizes = [min(left, left + right - min_right), max(right, min_right)]
self.main_split.setSizes(new_sizes)
self.plugins.update()

self.toolbars.main.layout().addWidget(PushButton("Plugins", clicked=pop_out_plugins))
self.toolbars.main.layout().addWidget(PushButton("Plugins", clicked=self.pop_out_plugins))

self.app_settings.tab_widget.setUsesScrollButtons(False)
self.app_settings.setMinimumWidth(
Expand Down Expand Up @@ -265,12 +255,27 @@ def setup_ui(self) -> None:
self, activated=self.auto_fit_keyswitch
)

QShortcut(
QKeySequence(QKeyCombination(Qt.Modifier.CTRL, Qt.Key.Key_P).toCombined()),
self, activated=self.pop_out_plugins
)

def auto_fit_keyswitch(self) -> None:
for view in self.graphics_views:
if view.underMouse():
view.autofit = not view.autofit
break

def pop_out_plugins(self):
left, right = self.main_split.sizes()
if right:
new_sizes = [left + right, 0]
else:
min_right = int((left + right) * 0.2)
new_sizes = [min(left, left + right - min_right), max(right, min_right)]
self.main_split.setSizes(new_sizes)
self.plugins.update()

def apply_stylesheet(self) -> None:
try:
from qdarkstyle import DarkPalette, LightPalette, _load_stylesheet # type: ignore[import]
Expand Down

0 comments on commit 0b61f6e

Please sign in to comment.