Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

feat(ui): optional toggle panels with shortcut

Ahl76c28db8874e52
diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.h
index c50927bc1..353592d66 100644
--- a/toonz/sources/include/toonz/preferencesitemids.h
+++ b/toonz/sources/include/toonz/preferencesitemids.h
@@ -45,6 +45,7 @@ enum PreferencesItemId {
displayIn30bit,
viewerIndicatorEnabled,
restoreViewerViewFromLastSession,
+ togglePanelWithShortcut,
//----------
// Visualization
diff --git a/toonz/sources/toonz/floatingpanelcommand.cpp b/toonz/sources/toonz/floatingpanelcommand.cpp
index 943669929..0dbd37aa1 100644
--- a/toonz/sources/toonz/floatingpanelcommand.cpp
+++ b/toonz/sources/toonz/floatingpanelcommand.cpp
@@ -7,6 +7,8 @@
#include "pane.h"
+#include "toonz/preferences.h"
+#include "toonz/preferencesitemids.h"
#include "toonzqt/styleeditor.h"
#include <QMainWindow>
@@ -45,6 +47,21 @@ void OpenFloatingPanel::execute() {
return;
}
+ if (Preferences::instance()->getBoolValue(togglePanelWithShortcut)) {
+ TMainWindow *currentRoom = TApp::instance()->getCurrentRoom();
+ if (currentRoom) {
+ bool closedAny = false;
+ const QList<TPanel *> panels = currentRoom->findChildren<TPanel *>();
+ for (TPanel *panel : panels) {
+ if (panel->getPanelType() == m_panelType && !panel->isHidden()) {
+ panel->close();
+ closedAny = true;
+ }
+ }
+ if (closedAny) return;
+ }
+ }
+
getOrOpenFloatingPanel(m_panelType);
/*
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index 3815ec251..2407c355d 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -1319,6 +1319,7 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
{viewerIndicatorEnabled, tr("Show Viewer Indicators")},
{restoreViewerViewFromLastSession,
tr("Restore Viewer Zoom and Pan from Last Session")},
+ {togglePanelWithShortcut, tr("Toggle Panels with Shortcut")},
// Visualization
{show0ThickLines, tr("Show Lines with Thickness 0")},
@@ -1950,6 +1951,7 @@ QWidget* PreferencesPopup::createInterfacePage() {
->setToolTip(
tr("Leave blank to use the local OpenToonz documentation index. "
"To open a PDF at a specific page, append #page=12."));
+ insertUI(togglePanelWithShortcut, lay);
lay->setRowStretch(lay->rowCount(), 1);
insertFootNote(lay);
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index 8d4d2e2cf..bf4a9e5c2 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -465,6 +465,8 @@ void Preferences::definePreferenceItems() {
true);
define(restoreViewerViewFromLastSession, "restoreViewerViewFromLastSession",
QMetaType::Bool, false);
+ define(togglePanelWithShortcut, "togglePanelWithShortcut", QMetaType::Bool,
+ false);
// Visualization
define(show0ThickLines, "show0ThickLines", QMetaType::Bool, true);