Skip to content

Commit

Permalink
Add button to pop out plugins panel v3 (#214)
Browse files Browse the repository at this point in the history
* Add button to pop out plugins panel

The draggable plugins panel is impossible to discover for new users.
The added button pops out the plugins panel without opening it fully,
so that users can realize that the panel exists and is draggable.

* Add Ctrl+P shortcut to pop plugins in/out
  • Loading branch information
arch1t3cht authored Nov 18, 2024
1 parent 78308a0 commit 51b980a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion vspreview/main/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from ..core import (
PRELOADED_MODULES, AbstractQItem, ArInfo, CroppingInfo, DragNavigator, ExtendedWidget, Frame, GraphicsImageItem,
GraphicsView, HBoxLayout, MainVideoOutputGraphicsView, QAbstractYAMLObjectSingleton, StatusBar, Time, Timer,
GraphicsView, HBoxLayout, MainVideoOutputGraphicsView, PushButton, QAbstractYAMLObjectSingleton, StatusBar, Time, Timer,
VBoxLayout, VideoOutput, _monkey_runpy_dicts, apply_plotting_style, dispose_environment, get_current_environment,
make_environment
)
Expand Down Expand Up @@ -187,6 +187,8 @@ def __init__(self, config_dir: SPath, no_exit: bool, reload_enabled: bool, force

Plugins(self)

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

self.app_settings.tab_widget.setUsesScrollButtons(False)
self.app_settings.setMinimumWidth(
int(len(self.toolbars) * 1.05 * self.app_settings.tab_widget.geometry().width() / 2)
Expand Down Expand Up @@ -248,12 +250,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 51b980a

Please sign in to comment.