OpenToonz - An open-source full-featured 2D animation creation software
C
Allow Shortcut to Cycle Dropdown Options (#1420)
Jeremy Bullock3a06bdc56965
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.hindex 170787cf1..d0b2f76b9 100644--- a/toonz/sources/include/toonz/preferences.h+++ b/toonz/sources/include/toonz/preferences.h@@ -342,6 +342,13 @@ public:void setVectorSnappingTarget(int target);int getVectorSnappingTarget() { return m_vectorSnappingTarget; }+ // Tools Tab++ void setDropdownShortcutsCycleOptions(bool on);+ bool getDropdownShortcutsCycleOptions() {+ return m_dropdownShortcutsCycleOptions;+ }+// Xsheet tabvoid setXsheetStep(int step); //!< Sets the step used for the <I>next/prev//! step</I> commands.@@ -553,6 +560,7 @@ private:m_chessboardColor2;bool m_showRasterImagesDarkenBlendedInViewer,m_actualPixelViewOnSceneEditingMode;+ bool m_dropdownShortcutsCycleOptions;int m_viewerZoomCenter; // MOUSE_CURSOR = 0, VIEWER_CENTER = 1// used in the load level popup. ON_DEMAND = 0, ALL_ICONS = 1,// ALL_ICONS_AND_IMAGES = 2diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cppindex c62dbed42..3cc409c8b 100644--- a/toonz/sources/tnztools/tooloptionscontrols.cpp+++ b/toonz/sources/tnztools/tooloptionscontrols.cpp@@ -15,6 +15,7 @@#include "toonz/stage2.h"#include "toonz/stageobjectutil.h"#include "toonz/doubleparamcmd.h"+#include "toonz/preferences.h"// TnzQt includes#include "toonzqt/gutil.h"@@ -613,7 +614,14 @@ void ToolOptionCombo::onActivated(int index) {//-----------------------------------------------------------------------------void ToolOptionCombo::doShowPopup() {- if (isVisible()) showPopup();+ if (Preferences::instance()->getDropdownShortcutsCycleOptions()) {+ const TEnumProperty::Range &range = m_property->getRange();+ int theIndex = currentIndex() + 1;+ if (theIndex >= (int)range.size()) theIndex = 0;+ doOnActivated(theIndex);+ } else {+ if (isVisible()) showPopup();+ }}//-----------------------------------------------------------------------------@@ -622,7 +630,8 @@ void ToolOptionCombo::doOnActivated(int index) {if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;// active only if the belonging combo-viewer is visibleif (!isInVisibleViewer(this)) return;-+ bool cycleOptions =+ Preferences::instance()->getDropdownShortcutsCycleOptions();// Just move the index if the first item is not "Normal"if (itemText(0) != "Normal") {onActivated(index);diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex d9e96e2e7..594a59789 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -340,6 +340,12 @@ void PreferencesPopup::onRoomChoiceChanged(int index) {//-----------------------------------------------------------------------------+void PreferencesPopup::onDropdownShortcutsCycleOptionsChanged(int index) {+ m_pref->setDropdownShortcutsCycleOptions(index);+}++ //-----------------------------------------------------------------------------+void PreferencesPopup::onInterfaceFontChanged(int index) {QString font = m_interfaceFont->currentText();m_pref->setInterfaceFont(font.toStdString());@@ -1278,6 +1284,11 @@ PreferencesPopup::PreferencesPopup()m_useNumpadForSwitchingStyles =new CheckBox(tr("Use Numpad and Tab keys for Switching Styles"), this);+ //--- Tools -------------------------------+ categoryList->addItem(tr("Tools"));++ m_dropdownShortcutsCycleOptionsCB = new QComboBox(this);+//--- Xsheet ------------------------------categoryList->addItem(tr("Xsheet"));@@ -1604,6 +1615,15 @@ PreferencesPopup::PreferencesPopup()m_vectorSnappingTargetCB->addItems(vectorSnappingTargets);m_vectorSnappingTargetCB->setCurrentIndex(m_pref->getVectorSnappingTarget());+ //--- Tools -------------------------------++ QStringList dropdownBehaviorTypes;+ dropdownBehaviorTypes << tr("Open the dropdown to display all options")+ << tr("Cycle through the available options");+ m_dropdownShortcutsCycleOptionsCB->addItems(dropdownBehaviorTypes);+ m_dropdownShortcutsCycleOptionsCB->setCurrentIndex(+ m_pref->getDropdownShortcutsCycleOptions() ? 1 : 0);+//--- Xsheet ------------------------------xsheetAutopanDuringPlaybackCB->setChecked(m_pref->isXsheetAutopanEnabled());m_cellsDragBehaviour->addItem(tr("Cells Only"));@@ -2070,6 +2090,26 @@ PreferencesPopup::PreferencesPopup()m_defLevelHeight->setDecimals(0);}+ //--- Tools ---------------------------+ QWidget *toolsBox = new QWidget(this);+ QGridLayout *toolsFrameLay = new QGridLayout();+ toolsFrameLay->setMargin(15);+ toolsFrameLay->setHorizontalSpacing(15);+ toolsFrameLay->setVerticalSpacing(10);+ {+ toolsFrameLay->addWidget(new QLabel(tr("Dropdown Shortcuts:")), 0, 0,+ Qt::AlignRight | Qt::AlignVCenter);+ toolsFrameLay->addWidget(m_dropdownShortcutsCycleOptionsCB, 0, 1);+ }+ toolsFrameLay->setColumnStretch(0, 0);+ toolsFrameLay->setColumnStretch(1, 0);+ toolsFrameLay->setColumnStretch(2, 1);+ toolsFrameLay->setRowStretch(0, 0);+ toolsFrameLay->setRowStretch(1, 0);+ toolsFrameLay->setRowStretch(2, 1);+ toolsBox->setLayout(toolsFrameLay);+ stackedWidget->addWidget(toolsBox);+//--- Xsheet --------------------------QWidget *xsheetBox = new QWidget(this);QVBoxLayout *xsheetBoxFrameLay = new QVBoxLayout();@@ -2472,6 +2512,12 @@ PreferencesPopup::PreferencesPopup()ret = ret && connect(m_newLevelToCameraSizeCB, SIGNAL(clicked(bool)),SLOT(onNewLevelToCameraSizeChanged(bool)));+ //--- Tools -----------------------++ ret = ret && connect(m_dropdownShortcutsCycleOptionsCB,+ SIGNAL(currentIndexChanged(int)),+ SLOT(onDropdownShortcutsCycleOptionsChanged(int)));+//--- Xsheet ----------------------ret = ret && connect(xsheetAutopanDuringPlaybackCB, SIGNAL(stateChanged(int)),this, SLOT(onXsheetAutopanChanged(int)));diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.hindex cd33233a6..31182eb42 100644--- a/toonz/sources/toonz/preferencespopup.h+++ b/toonz/sources/toonz/preferencespopup.h@@ -54,8 +54,9 @@ private:QComboBox *m_keyframeType, *m_cellsDragBehaviour, *m_defScanLevelType,*m_defLevelType, *m_autocreationType, *m_levelFormatNames,*m_columnIconOm, *m_unitOm, *m_cameraUnitOm, *m_importPolicy,- *m_interfaceFont, *m_interfaceFontWeight, *m_vectorSnappingTargetCB,- *m_guidedDrawingStyle;+ *m_vectorSnappingTargetCB, *m_dropdownShortcutsCycleOptionsCB,+ *m_interfaceFont, *m_interfaceFontWeight, *m_guidedDrawingStyle;+DVGui::MeasuredDoubleLineEdit *m_defLevelWidth, *m_defLevelHeight;@@ -139,6 +140,7 @@ private slots:void onDefLevelParameterChanged();void onGetFillOnlySavebox(int index);void onFitToFlipbook(int);+ void onDropdownShortcutsCycleOptionsChanged(int);void onAddLevelFormat();void onRemoveLevelFormat();void onEditLevelFormat();diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cppindex b0f1e5beb..745920302 100644--- a/toonz/sources/toonzlib/preferences.cpp+++ b/toonz/sources/toonzlib/preferences.cpp@@ -305,6 +305,7 @@ Preferences::Preferences(), m_moveCurrentFrameByClickCellArea(true), m_onionSkinEnabled(true), m_onionSkinDuringPlayback(false)+ , m_dropdownShortcutsCycleOptions(false), m_multiLayerStylePickerEnabled(false), m_paletteTypeOnLoadRasterImageAsColorModel(0), m_showKeyframesOnXsheetCellArea(true)@@ -379,6 +380,8 @@ Preferences::Preferences()getValue(*m_settings, "autosaveOtherFilesEnabled",m_autosaveOtherFilesEnabled);getValue(*m_settings, "startupPopupEnabled", m_startupPopupEnabled);+ getValue(*m_settings, "dropdownShortcutsCycleOptions",+ m_dropdownShortcutsCycleOptions);getValue(*m_settings, "defaultViewerEnabled", m_defaultViewerEnabled);getValue(*m_settings, "rasterOptimizedMemory", m_rasterOptimizedMemory);getValue(*m_settings, "saveUnpaintedInCleanup", m_saveUnpaintedInCleanup);@@ -1324,6 +1327,13 @@ void Preferences::enableSceneNumbering(bool enabled) {//-----------------------------------------------------------------+void Preferences::setDropdownShortcutsCycleOptions(bool on) {+ m_dropdownShortcutsCycleOptions = on;+ m_settings->setValue("dropdownShortcutsCycleOptions", on ? "1" : "0");+}++//-----------------------------------------------------------------+void Preferences::setDefLevelType(int levelType) {m_defLevelType = levelType;m_settings->setValue("DefLevelType", levelType);