Skip to content

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

C

Fix auto commit cell number when nothing typed (#6214)

Abel_Youb1c4330ce4a3
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h
index 1ffd0b4d5..f2a2a65f2 100644
--- a/toonz/sources/include/toonz/preferences.h
+++ b/toonz/sources/include/toonz/preferences.h
@@ -244,7 +244,9 @@ public:
// Visualization tab
bool getShow0ThickLines() const { return getBoolValue(show0ThickLines); }
bool getRegionAntialias() const { return getBoolValue(regionAntialias); }
- bool getRasterizeAntialias() const { return getBoolValue(rasterizeAntialias); }
+ bool getRasterizeAntialias() const {
+ return getBoolValue(rasterizeAntialias);
+ }
// Loading tab
int getDefaultImportPolicy() { return getIntValue(importPolicy); }
@@ -349,11 +351,9 @@ public:
bool isCursorOutlineEnabled() const {
return getBoolValue(cursorOutlineEnabled);
}
- bool isUseStrokeEndCursor() const {
- return getBoolValue(useStrokeEndCursor);
- }
+ bool isUseStrokeEndCursor() const { return getBoolValue(useStrokeEndCursor); }
bool isClickTwiceToCreateArcs() {
- return getBoolValue(clickTwiceToCreateArcs);
+ return getBoolValue(clickTwiceToCreateArcs);
}
int getLevelBasedToolsDisplay() const {
return getIntValue(levelBasedToolsDisplay);
@@ -378,7 +378,9 @@ public:
bool isXsheetAutopanEnabled() const {
return getBoolValue(xsheetAutopanEnabled);
} //!< Returns whether xsheet pans during playback.
- int isAlwaysDragFrameCell() const { return getBoolValue(alwaysDragFrameCell); }
+ int isAlwaysDragFrameCell() const {
+ return getBoolValue(alwaysDragFrameCell);
+ }
int getDragCellsBehaviour() const { return getIntValue(DragCellsBehaviour); }
int getDeleteCommandBehaviour() const {
return getIntValue(deleteCommandBehavior);
@@ -396,8 +398,11 @@ public:
bool isUseArrowKeyToShiftCellSelectionEnabled() const {
return getBoolValue(useArrowKeyToShiftCellSelection);
}
+ bool isInputCellsUsingNumpad() const {
+ return getIntValue(cellInputMethod) == 1;
+ }
bool isInputCellsWithoutDoubleClickingEnabled() const {
- return getBoolValue(inputCellsWithoutDoubleClickingEnabled);
+ return getIntValue(cellInputMethod) == 2;
}
bool isShortcutCommandsWhileRenamingCellEnabled() const {
return getBoolValue(shortcutCommandsWhileRenamingCellEnabled);
diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.h
index 6cc8ff112..0b3102de6 100644
--- a/toonz/sources/include/toonz/preferencesitemids.h
+++ b/toonz/sources/include/toonz/preferencesitemids.h
@@ -136,7 +136,7 @@ enum PreferencesItemId {
showKeyframesOnXsheetCellArea,
showXsheetCameraColumn,
useArrowKeyToShiftCellSelection,
- inputCellsWithoutDoubleClickingEnabled,
+ cellInputMethod,
shortcutCommandsWhileRenamingCellEnabled,
showXSheetToolbar,
showXsheetBreadcrumbs,
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index af1eb196d..85e72fb0d 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -966,9 +966,9 @@ void PreferencesPopup::onRenamePolicyExternallyChanged(int policy) {
//-----------------------------------------------------------------------------
void PreferencesPopup::onConvertPolicyExternallyChanged(int policy) {
- QComboBox* convertPolicyCombo = getUI<QComboBox*>(importPolicy);
- // update preferences data accordingly
- convertPolicyCombo->setCurrentIndex(policy);
+ QComboBox* convertPolicyCombo = getUI<QComboBox*>(importPolicy);
+ // update preferences data accordingly
+ convertPolicyCombo->setCurrentIndex(policy);
}
//-----------------------------------------------------------------------------
@@ -1319,7 +1319,8 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
{FillOnlysavebox, tr("Use the TLV Savebox to Limit Filling Operations")},
{DefRegionWithPaint,
tr("Define Filling Region Using both Lines and Areas")},
- { ReferFillPrevailing, tr("Paint Under Lines in Refer Fill and Gap Close") },
+ {ReferFillPrevailing,
+ tr("Paint Under Lines in Refer Fill and Gap Close")},
{multiLayerStylePickerEnabled,
tr("Multi Layer Style Picker: Switch Levels by Picking")},
{cursorBrushType, tr("Basic Cursor Type:")},
@@ -1328,7 +1329,7 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
{levelBasedToolsDisplay, tr("Toolbar Display Behaviour:")},
{useCtrlAltToResizeBrush, tr("Use %1 to Resize Brush").arg(CtrlAltStr())},
{useStrokeEndCursor, tr("Draw Cursor at End of Stroke")},
- {clickTwiceToCreateArcs, tr("Click Twice to Create Arcs") },
+ {clickTwiceToCreateArcs, tr("Click Twice to Create Arcs")},
{tempToolSwitchTimer,
tr("Switch Tool Temporarily Keypress Length (ms):")},
@@ -1346,8 +1347,7 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
{showXsheetCameraColumn, tr("Show Camera Column")},
{useArrowKeyToShiftCellSelection,
tr("Use Arrow Key to Shift Cell Selection")},
- {inputCellsWithoutDoubleClickingEnabled,
- tr("Enable to Input Cells without Double Clicking")},
+ {cellInputMethod, tr("Cell Input Method:")},
{shortcutCommandsWhileRenamingCellEnabled,
tr("Enable OpenToonz Commands' Shortcut Keys While Renaming Cell")},
{showXSheetToolbar, tr("Show Toolbar in the Xsheet")},
@@ -1443,10 +1443,8 @@ QList<ComboBoxItem> PreferencesPopup::getComboItemList(
Preferences::ProjectFolderAliases},
{tr("Scene Folder Alias ($scenefolder)"),
Preferences::SceneFolderAlias},
- {tr("Use Project Folder Aliases Only"),
- Preferences::ProjectFolderOnly},
- {tr("Automatic by Scene"),
- Preferences::AutoByScene}}},
+ {tr("Use Project Folder Aliases Only"), Preferences::ProjectFolderOnly},
+ {tr("Automatic by Scene"), Preferences::AutoByScene}}},
{linearUnits, // cameraUnits shares items with linearUnits
{{tr("cm"), "cm"},
{tr("mm"), "mm"},
@@ -1469,8 +1467,8 @@ QList<ComboBoxItem> PreferencesPopup::getComboItemList(
{{tr("Always ask before renaming"), 0},
{tr("Normalize sequence names automatically"), 1},
{tr("Keep original filenames"), 2}}},
- {convertPolicy,
- {{tr("Always ask before converting"), 0},
+ {convertPolicy,
+ {{tr("Always ask before converting"), 0},
{tr("Convert raster level automatically"), 1},
{tr("Do not convert"), 2}}},
{rasterLevelCachingBehavior,
@@ -1533,6 +1531,10 @@ QList<ComboBoxItem> PreferencesPopup::getComboItemList(
{pasteCellsBehavior,
{{tr("Insert Paste Whole Data"), 0},
{tr("Overwrite Paste Cell Numbers"), 1}}},
+ {cellInputMethod,
+ {{tr("Input by Double Click Only"), 0},
+ {tr("Input by Numpad"), 1},
+ {tr("Input by Single Click"), 2}}},
{keyframeType, // note that the value starts from 1, not 0
{{tr("Constant"), 1},
{tr("Linear"), 2},
@@ -1691,11 +1693,10 @@ QWidget* PreferencesPopup::createGeneralPage() {
pathAliasPriorityCB->setItemData(2, QString(" "), Qt::ToolTipRole);
QString autoBySceneToolTip =
tr("Automatically sets folder based on scene type:\n"
- "Standalone -> $scenefolder\n"
- "Project -> project folder aliases (+drawing...)");
+ "Standalone -> $scenefolder\n"
+ "Project -> project folder aliases (+drawing...)");
pathAliasPriorityCB->setItemData(3, autoBySceneToolTip, Qt::ToolTipRole);
-
m_onEditedFuncMap.insert(autosaveEnabled,
&PreferencesPopup::onAutoSaveChanged);
m_onEditedFuncMap.insert(autosaveSceneEnabled,
@@ -1704,17 +1705,17 @@ QWidget* PreferencesPopup::createGeneralPage() {
&PreferencesPopup::onAutoSaveOptionsChanged);
m_onEditedFuncMap.insert(watchFileSystemEnabled,
&PreferencesPopup::onWatchFileSystemClicked);
- m_onEditedFuncMap.insert(pathAliasPriority,
+ m_onEditedFuncMap.insert(pathAliasPriority,
&PreferencesPopup::onPathAliasPriorityChanged);
bool ret = true;
- ret = ret && connect(m_pref, SIGNAL(stopAutoSave()), this,
- SLOT(onAutoSaveExternallyChanged()));
- ret = ret && connect(m_pref, SIGNAL(startAutoSave()), this,
- SLOT(onAutoSaveExternallyChanged()));
- ret = ret && connect(m_pref, SIGNAL(autoSavePeriodChanged()), this,
- SLOT(onAutoSavePeriodExternallyChanged()));
+ ret = ret && connect(m_pref, SIGNAL(stopAutoSave()), this,
+ SLOT(onAutoSaveExternallyChanged()));
+ ret = ret && connect(m_pref, SIGNAL(startAutoSave()), this,
+ SLOT(onAutoSaveExternallyChanged()));
+ ret = ret && connect(m_pref, SIGNAL(autoSavePeriodChanged()), this,
+ SLOT(onAutoSavePeriodExternallyChanged()));
ret = ret && connect(m_projectRootDocuments, SIGNAL(stateChanged(int)),
SLOT(onProjectRootChanged()));
@@ -2127,6 +2128,7 @@ QWidget* PreferencesPopup::createXsheetPage() {
insertUI(DragCellsBehaviour, lay, getComboItemList(DragCellsBehaviour));
insertUI(deleteCommandBehavior, lay, getComboItemList(deleteCommandBehavior));
insertUI(pasteCellsBehavior, lay, getComboItemList(pasteCellsBehavior));
+ insertUI(cellInputMethod, lay, getComboItemList(cellInputMethod));
insertUI(ignoreAlphaonColumn1Enabled, lay);
QGridLayout* showKeyLay =
insertGroupBoxUI(showKeyframesOnXsheetCellArea, lay);
@@ -2134,7 +2136,6 @@ QWidget* PreferencesPopup::createXsheetPage() {
insertUI(showXsheetCameraColumn, showKeyLay);
}
insertUI(useArrowKeyToShiftCellSelection, lay);
- insertUI(inputCellsWithoutDoubleClickingEnabled, lay);
insertUI(shortcutCommandsWhileRenamingCellEnabled, lay);
QGridLayout* xshToolbarLay = insertGroupBox(tr("Xsheet Tools"), lay);
{
diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp
index 1de9db79c..2ef2164ed 100644
--- a/toonz/sources/toonz/xshcellviewer.cpp
+++ b/toonz/sources/toonz/xshcellviewer.cpp
@@ -979,19 +979,18 @@ void RenameCellField::renameCell() {
cellSelection->renameCells(cells[0]);
} else
cellSelection->renameMultiCells(cells);
-
- cellSelection->fillEmptyCell();
}
//-----------------------------------------------------------------------------
void RenameCellField::onReturnPressed() {
renameCell();
-
// move the cell selection
TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
TApp::instance()->getCurrentSelection()->getSelection());
if (!cellSelection) return;
+ if (m_isCtrlPrssed) cellSelection->fillEmptyCell();
+
TCellSelection::Range range = cellSelection->getSelectedCells();
int offset = range.m_r1 - range.m_r0 + 1;
cellSelection->selectCells(range.m_r0 + offset, range.m_c0,
@@ -1006,11 +1005,14 @@ void RenameCellField::onReturnPressed() {
void RenameCellField::focusOutEvent(QFocusEvent *e) {
hide();
- if (escapePressed) {
- escapePressed = false;
- } else {
+ // Lost focus because of Mouse movement, rename the cell
+ if (e->reason() == Qt::MouseFocusReason && !text().isEmpty()) {
renameCell();
+ TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
+ TApp::instance()->getCurrentSelection()->getSelection());
+ if (cellSelection) cellSelection->fillEmptyCell();
}
+
QLineEdit::focusOutEvent(e);
}
@@ -1053,11 +1055,11 @@ bool RenameCellField::eventFilter(QObject *obj, QEvent *e) {
void RenameCellField::keyPressEvent(QKeyEvent *event) {
if (event->key() == Qt::Key_Escape) {
- escapePressed = true;
clearFocus();
return;
}
+ m_isCtrlPrssed = (event->modifiers() & Qt::ControlModifier);
// move the cell selection
TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
TApp::instance()->getCurrentSelection()->getSelection());
diff --git a/toonz/sources/toonz/xshcellviewer.h b/toonz/sources/toonz/xshcellviewer.h
index 0cf54af42..ce99539ab 100644
--- a/toonz/sources/toonz/xshcellviewer.h
+++ b/toonz/sources/toonz/xshcellviewer.h
@@ -40,8 +40,8 @@ class RenameCellField final : public QLineEdit {
int m_row;
int m_col;
- bool escapePressed = false;
XsheetViewer *m_viewer;
+ bool m_isCtrlPrssed = false;
public:
RenameCellField(QWidget *parent, XsheetViewer *viewer);
diff --git a/toonz/sources/toonz/xsheetviewer.cpp b/toonz/sources/toonz/xsheetviewer.cpp
index bcb2f28f7..cf59f81a0 100644
--- a/toonz/sources/toonz/xsheetviewer.cpp
+++ b/toonz/sources/toonz/xsheetviewer.cpp
@@ -163,57 +163,57 @@ void XsheetViewer::getButton(const int &btype, QColor &bgColor,
switch (btype) {
case PREVIEW_ON_XSHBUTTON:
bgColor = (isTimeline) ? getTimelinePreviewButtonBgOnColor()
- : getXsheetPreviewButtonBgOnColor();
+ : getXsheetPreviewButtonBgOnColor();
svgIconPath = (isTimeline) ? getTimelinePreviewButtonOnImage()
- : getXsheetPreviewButtonOnImage();
+ : getXsheetPreviewButtonOnImage();
break;
case PREVIEW_OFF_XSHBUTTON:
bgColor = (isTimeline) ? getTimelinePreviewButtonBgOffColor()
- : getXsheetPreviewButtonBgOffColor();
+ : getXsheetPreviewButtonBgOffColor();
svgIconPath = (isTimeline) ? getTimelinePreviewButtonOffImage()
- : getXsheetPreviewButtonOffImage();
+ : getXsheetPreviewButtonOffImage();
break;
case CAMSTAND_ON_XSHBUTTON:
bgColor = (isTimeline) ? getTimelineCamstandButtonBgOnColor()
- : getXsheetCamstandButtonBgOnColor();
+ : getXsheetCamstandButtonBgOnColor();
svgIconPath = (isTimeline) ? getTimelineCamstandButtonOnImage()
- : getXsheetCamstandButtonOnImage();
+ : getXsheetCamstandButtonOnImage();
break;
case CAMSTAND_TRANSP_XSHBUTTON:
bgColor = (isTimeline) ? getTimelineCamstandButtonBgOnColor()
- : getXsheetCamstandButtonBgOnColor();
+ : getXsheetCamstandButtonBgOnColor();
svgIconPath = (isTimeline) ? getTimelineCamstandButtonTranspImage()
- : getXsheetCamstandButtonTranspImage();
+ : getXsheetCamstandButtonTranspImage();
break;
case CAMSTAND_OFF_XSHBUTTON:
bgColor = (isTimeline) ? getTimelineCamstandButtonBgOffColor()
- : getXsheetCamstandButtonBgOffColor();
+ : getXsheetCamstandButtonBgOffColor();
svgIconPath = (isTimeline) ? getTimelineCamstandButtonOffImage()
- : getXsheetCamstandButtonOffImage();
+ : getXsheetCamstandButtonOffImage();
break;
case LOCK_ON_XSHBUTTON:
bgColor = (isTimeline) ? getTimelineLockButtonBgOnColor()
- : getXsheetLockButtonBgOnColor();
+ : getXsheetLockButtonBgOnColor();
svgIconPath = (isTimeline) ? getTimelineLockButtonOnImage()
- : getXsheetLockButtonOnImage();
+ : getXsheetLockButtonOnImage();
break;
case LOCK_OFF_XSHBUTTON:
bgColor = (isTimeline) ? getTimelineLockButtonBgOffColor()
- : getXsheetLockButtonBgOffColor();
+ : getXsheetLockButtonBgOffColor();
svgIconPath = (isTimeline) ? getTimelineLockButtonOffImage()
- : getXsheetLockButtonOffImage();
+ : getXsheetLockButtonOffImage();
break;
case CONFIG_XSHBUTTON:
bgColor = (isTimeline) ? getTimelineConfigButtonBgColor()
- : getXsheetConfigButtonBgColor();
+ : getXsheetConfigButtonBgColor();
svgIconPath = (isTimeline) ? getTimelineConfigButtonImage()
- : getXsheetConfigButtonImage();
+ : getXsheetConfigButtonImage();
break;
case UNIFIED_TRANSP_XSHBUTTON:
bgColor = (isTimeline) ? getTimelinePreviewButtonBgOnColor()
- : getXsheetPreviewButtonBgOnColor();
+ : getXsheetPreviewButtonBgOnColor();
svgIconPath = (isTimeline) ? getTimelineUnifiedButtonTranspImage()
- : getXsheetUnifiedButtonTranspImage();
+ : getXsheetUnifiedButtonTranspImage();
break;
default:
bgColor = grey210;
@@ -1398,14 +1398,15 @@ void XsheetViewer::keyPressEvent(QKeyEvent *event) {
}
break;
default:
- if ((key >= Qt::Key_1 && key <= Qt::Key_9)) {
- int number = key - Qt::Key_1 + 1;
+ if (Preferences::instance()->isInputCellsUsingNumpad() &&
+ key >= Qt::Key_0 && key <= Qt::Key_9) {
+ int number = key - Qt::Key_0;
m_cellArea->onNumberPressed(number);
}
break;
}
- break;
- }
+ break;
+ }
}
}
@@ -1781,7 +1782,7 @@ void XsheetViewer::changeWindowTitle() {
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
if (!scene || !app->getCurrentFrame()->isEditingScene()) return;
- auto project = scene->getProject();
+ auto project = scene->getProject();
QString sceneName = QString::fromStdWString(scene->getSceneName());
if (sceneName.isEmpty()) sceneName = tr("Untitled");
if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString("*");
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index 588978451..e0c1d86eb 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -457,9 +457,9 @@ void Preferences::definePreferenceItems() {
define(rasterizeAntialias, "rasterizeAntialias", QMetaType::Bool, false);
// Loading
- define(importPolicy, "importPolicy", QMetaType::Int, 0); // Always ask
- define(renamePolicy, "renamePolicy", QMetaType::Int, 0); // Always ask
- define(convertPolicy, "convertPolicy", QMetaType::Int, 0); // Always ask
+ define(importPolicy, "importPolicy", QMetaType::Int, 0); // Always ask
+ define(renamePolicy, "renamePolicy", QMetaType::Int, 0); // Always ask
+ define(convertPolicy, "convertPolicy", QMetaType::Int, 0); // Always ask
define(autoExposeEnabled, "autoExposeEnabled", QMetaType::Bool, true);
define(subsceneFolderEnabled, "subsceneFolderEnabled", QMetaType::Bool, true);
define(removeSceneNumberFromLoadedLevelName,
@@ -583,8 +583,9 @@ void Preferences::definePreferenceItems() {
true);
define(useArrowKeyToShiftCellSelection, "useArrowKeyToShiftCellSelection",
QMetaType::Bool, true);
- define(inputCellsWithoutDoubleClickingEnabled,
- "inputCellsWithoutDoubleClickingEnabled", QMetaType::Bool, false);
+ define(
+ cellInputMethod, "cellInputMethod", QMetaType::Int,
+ 1); // Input by Double click only; Input by numpad; Input by Single Click
define(shortcutCommandsWhileRenamingCellEnabled,
"shortcutCommandsWhileRenamingCellEnabled", QMetaType::Bool, false);
define(showXSheetToolbar, "showXSheetToolbar", QMetaType::Bool, true);