Skip to content

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

C

Enable shortcut command while renaming cell (#1451)

shun-iwasawad08c7cb5e42c
diff --git "a/stuff/config/loc/\346\227\245\346\234\254\350\252\236/toonz.qm" "b/stuff/config/loc/\346\227\245\346\234\254\350\252\236/toonz.qm"
index 023d3229b..7bd214ad7 100644
Binary files "a/stuff/config/loc/\346\227\245\346\234\254\350\252\236/toonz.qm" and "b/stuff/config/loc/\346\227\245\346\234\254\350\252\236/toonz.qm" differ
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h
index f3c5de68c..5eb760ff2 100644
--- a/toonz/sources/include/toonz/preferences.h
+++ b/toonz/sources/include/toonz/preferences.h
@@ -379,6 +379,11 @@ public:
void enableShowColumnNumbers(bool on);
bool isShowColumnNumbersEnabled() const { return m_showColumnNumbers; }
+ void enableShortcutCommandsWhileRenamingCell(bool on);
+ bool isShortcutCommandsWhileRenamingCellEnabled() const {
+ return m_shortcutCommandsWhileRenamingCellEnabled;
+ }
+
// Animation tab
void setKeyframeType(int s);
@@ -581,6 +586,9 @@ private:
// enable to watch file system in order to update file browser automatically
bool m_watchFileSystem;
+ // enable OT command shortcut keys while renaming xsheet cell
+ bool m_shortcutCommandsWhileRenamingCellEnabled;
+
private:
Preferences();
~Preferences();
diff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cpp
index f5aa37293..7d0b6451d 100644
--- a/toonz/sources/toonz/cellselection.cpp
+++ b/toonz/sources/toonz/cellselection.cpp
@@ -1218,7 +1218,7 @@ bool TCellSelection::isEnabledCommand(
MI_TimeStretch, MI_CloneLevel, MI_SetKeyframes, MI_Copy,
MI_Paste, MI_PasteInto, MI_Cut, MI_Clear,
MI_Insert, MI_PasteInto, MI_Reframe1, MI_Reframe2,
- MI_Reframe3, MI_Reframe4};
+ MI_Reframe3, MI_Reframe4, MI_Undo, MI_Redo};
return commands.contains(commandId);
}
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index 010062352..77e6372e0 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -1041,6 +1041,12 @@ void PreferencesPopup::onInputCellsWithoutDoubleClickingClicked(int on) {
//-----------------------------------------------------------------------------
+void PreferencesPopup::onShortcutCommandsWhileRenamingCellClicked(int on) {
+ m_pref->enableShortcutCommandsWhileRenamingCell(on);
+}
+
+//-----------------------------------------------------------------------------
+
void PreferencesPopup::onWatchFileSystemClicked(int on) {
m_pref->enableWatchFileSystem(on);
// emit signal to update behavior of the File browser
@@ -1249,6 +1255,8 @@ PreferencesPopup::PreferencesPopup()
new CheckBox(tr("Use Arrow Key to Shift Cell Selection"), this);
CheckBox *inputCellsWithoutDoubleClickingCB =
new CheckBox(tr("Enable to Input Cells without Double Clicking"), this);
+ CheckBox *shortcutCommandsWhileRenamingCellCB = new CheckBox(
+ tr("Enable OpenToonz Commands' Shortcut Keys While Renaming Cell"), this);
m_showXSheetToolbar = new QGroupBox(tr("Show Toolbar in the XSheet "), this);
m_showXSheetToolbar->setCheckable(true);
m_expandFunctionHeader = new CheckBox(
@@ -1531,6 +1539,8 @@ PreferencesPopup::PreferencesPopup()
m_pref->isUseArrowKeyToShiftCellSelectionEnabled());
inputCellsWithoutDoubleClickingCB->setChecked(
m_pref->isInputCellsWithoutDoubleClickingEnabled());
+ shortcutCommandsWhileRenamingCellCB->setChecked(
+ m_pref->isShortcutCommandsWhileRenamingCellEnabled());
m_showXSheetToolbar->setChecked(m_pref->isShowXSheetToolbarEnabled());
m_expandFunctionHeader->setChecked(m_pref->isExpandFunctionHeaderEnabled());
showColumnNumbersCB->setChecked(m_pref->isShowColumnNumbersEnabled());
@@ -1992,6 +2002,8 @@ PreferencesPopup::PreferencesPopup()
xsheetFrameLay->addWidget(showKeyframesOnCellAreaCB, 4, 0, 1, 2);
xsheetFrameLay->addWidget(useArrowKeyToShiftCellSelectionCB, 5, 0, 1, 2);
xsheetFrameLay->addWidget(inputCellsWithoutDoubleClickingCB, 6, 0, 1, 2);
+ xsheetFrameLay->addWidget(shortcutCommandsWhileRenamingCellCB, 7, 0, 1,
+ 2);
QVBoxLayout *xSheetToolbarLay = new QVBoxLayout();
xSheetToolbarLay->setMargin(10);
@@ -2001,13 +2013,13 @@ PreferencesPopup::PreferencesPopup()
}
m_showXSheetToolbar->setLayout(xSheetToolbarLay);
- xsheetFrameLay->addWidget(m_showXSheetToolbar, 7, 0, 3, 3);
- xsheetFrameLay->addWidget(showColumnNumbersCB, 10, 0, 1, 2);
+ xsheetFrameLay->addWidget(m_showXSheetToolbar, 8, 0, 3, 3);
+ xsheetFrameLay->addWidget(showColumnNumbersCB, 11, 0, 1, 2);
}
xsheetFrameLay->setColumnStretch(0, 0);
xsheetFrameLay->setColumnStretch(1, 0);
xsheetFrameLay->setColumnStretch(2, 1);
- xsheetFrameLay->setRowStretch(11, 1);
+ xsheetFrameLay->setRowStretch(12, 1);
xsheetBox->setLayout(xsheetFrameLay);
stackedWidget->addWidget(xsheetBox);
@@ -2357,6 +2369,9 @@ PreferencesPopup::PreferencesPopup()
ret = ret &&
connect(inputCellsWithoutDoubleClickingCB, SIGNAL(stateChanged(int)),
SLOT(onInputCellsWithoutDoubleClickingClicked(int)));
+ ret = ret &&
+ connect(shortcutCommandsWhileRenamingCellCB, SIGNAL(stateChanged(int)),
+ SLOT(onShortcutCommandsWhileRenamingCellClicked(int)));
ret = ret && connect(m_showXSheetToolbar, SIGNAL(clicked(bool)),
SLOT(onShowXSheetToolbarClicked(bool)));
ret = ret && connect(m_expandFunctionHeader, SIGNAL(clicked(bool)),
diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h
index b607b68ba..c67ace3c1 100644
--- a/toonz/sources/toonz/preferencespopup.h
+++ b/toonz/sources/toonz/preferencespopup.h
@@ -182,6 +182,7 @@ private slots:
void onShowColumnNumbersChanged(int);
void onUseArrowKeyToShiftCellSelectionClicked(int);
void onInputCellsWithoutDoubleClickingClicked(int);
+ void onShortcutCommandsWhileRenamingCellClicked(int);
void onWatchFileSystemClicked(int);
};
diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp
index b31188eed..8933f5949 100644
--- a/toonz/sources/toonz/xshcellviewer.cpp
+++ b/toonz/sources/toonz/xshcellviewer.cpp
@@ -549,8 +549,16 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {
TXshCell cell = xsh->getCell(row, col);
QPoint xy = m_viewer->positionToXY(CellPosition(row, col)) - QPoint(1, 2);
if (!cell.isEmpty()) {
- setFixedSize(o->cellWidth(), o->cellHeight() + 2);
- move(xy + QPoint(1, 1));
+ // Do not cover left side of the cell in order to enable grabbing the drag
+ // handle
+ if (o->isVerticalTimeline()) {
+ int dragHandleWidth = o->rect(PredefinedRect::DRAG_HANDLE_CORNER).width();
+ setFixedSize(o->cellWidth() - dragHandleWidth, o->cellHeight() + 2);
+ move(xy + QPoint(1 + dragHandleWidth, 1));
+ } else {
+ setFixedSize(o->cellWidth(), o->cellHeight() + 2);
+ move(xy + QPoint(1, 1));
+ }
TFrameId fid = cell.getFrameId();
std::wstring levelName = cell.m_level->getName();
@@ -730,39 +738,45 @@ void RenameCellField::focusOutEvent(QFocusEvent *e) {
// Override shortcut keys for cell selection commands
bool RenameCellField::eventFilter(QObject *obj, QEvent *e) {
- // We really shouldn't allow OT defined shortcuts to be checked and used while
- // renaming a cell
- // but if we must, we should only return true or false if we're executing our
- // OT action;
- // otherwise pass event forward in case another object is interested in it.
if (e->type() != QEvent::ShortcutOverride)
- return QObject::eventFilter(obj, e); // return false;
+ return QLineEdit::eventFilter(obj, e); // return false;
TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
TApp::instance()->getCurrentSelection()->getSelection());
- if (!cellSelection) return QObject::eventFilter(obj, e); // return false;
+ if (!cellSelection) return QLineEdit::eventFilter(obj, e);
QKeyEvent *ke = (QKeyEvent *)e;
std::string keyStr =
QKeySequence(ke->key() + ke->modifiers()).toString().toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
- if (!action) return QObject::eventFilter(obj, e); // return false;
+ if (!action) return QLineEdit::eventFilter(obj, e);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
// These are usally standard ctrl/command strokes for text editing.
// Default to standard behavior and don't execute OT's action while renaming
- // cell.
- if (actionId == "MI_Undo" || actionId == "MI_Redo" ||
- actionId == "MI_Clear" || actionId == "MI_Copy" ||
- actionId == "MI_Paste" || actionId == "MI_Cut")
- return QObject::eventFilter(obj, e); // return true;
+ // cell if users prefer to do so.
+ // Or, always invoke OT's commands when renaming cell even the standard
+ // command strokes for text editing.
+ // The latter option is demanded by Japanese animation industry in order to
+ // gain efficiency for inputting xsheet.
+ if (!Preferences::instance()->isShortcutCommandsWhileRenamingCellEnabled() &&
+ (actionId == "MI_Undo" || actionId == "MI_Redo" ||
+ actionId == "MI_Clear" || actionId == "MI_Copy" ||
+ actionId == "MI_Paste" || actionId == "MI_Cut"))
+ return QLineEdit::eventFilter(obj, e);
+
return TCellSelection::isEnabledCommand(actionId);
}
//-----------------------------------------------------------------------------
void RenameCellField::keyPressEvent(QKeyEvent *event) {
+ if (event->key() == Qt::Key_Escape) {
+ clearFocus();
+ return;
+ }
+
// move the cell selection
TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
TApp::instance()->getCurrentSelection()->getSelection());
@@ -780,8 +794,16 @@ void RenameCellField::keyPressEvent(QKeyEvent *event) {
switch (int key = event->key()) {
case Qt::Key_Up:
case Qt::Key_Down:
+ offset = m_viewer->orientation()->arrowShift(key);
+ break;
case Qt::Key_Left:
case Qt::Key_Right:
+ // ctrl+left/right arrow for moving cursor to the end in the field
+ if (isCtrlPressed &&
+ !Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled()) {
+ QLineEdit::keyPressEvent(event);
+ return;
+ }
offset = m_viewer->orientation()->arrowShift(key);
break;
default:
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index f683a56fb..6de661e84 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -317,7 +317,8 @@ Preferences::Preferences()
, m_inputCellsWithoutDoubleClickingEnabled(false)
, m_importPolicy(0)
, m_ignoreImageDpi(false)
- , m_watchFileSystem(true) {
+ , m_watchFileSystem(true)
+ , m_shortcutCommandsWhileRenamingCellEnabled(false) {
TCamera camera;
m_defLevelType = PLI_XSHLEVEL;
m_defLevelWidth = camera.getSize().lx;
@@ -612,6 +613,8 @@ Preferences::Preferences()
m_inputCellsWithoutDoubleClickingEnabled);
getValue(*m_settings, "importPolicy", m_importPolicy);
getValue(*m_settings, "watchFileSystemEnabled", m_watchFileSystem);
+ getValue(*m_settings, "shortcutCommandsWhileRenamingCellEnabled",
+ m_shortcutCommandsWhileRenamingCellEnabled);
}
//-----------------------------------------------------------------
@@ -1467,4 +1470,12 @@ void Preferences::enableInputCellsWithoutDoubleClicking(bool on) {
void Preferences::enableWatchFileSystem(bool on) {
m_watchFileSystem = on;
m_settings->setValue("watchFileSystemEnabled", on ? "1" : "0");
+}
+
+//-----------------------------------------------------------------
+
+void Preferences::enableShortcutCommandsWhileRenamingCell(bool on) {
+ m_shortcutCommandsWhileRenamingCellEnabled = on;
+ m_settings->setValue("shortcutCommandsWhileRenamingCellEnabled",
+ on ? "1" : "0");
}
\ No newline at end of file
diff --git a/toonz/sources/translations/japanese/toonz.ts b/toonz/sources/translations/japanese/toonz.ts
index 1a47031f8..a0549e0bc 100644
--- a/toonz/sources/translations/japanese/toonz.ts
+++ b/toonz/sources/translations/japanese/toonz.ts
@@ -3465,7 +3465,7 @@ Do you want to create it?</source>
</message>
<message>
<source>Matte Channel</source>
- <translation>アルファチャンネル</translation>
+ <translation type="vanished">アルファチャンネル</translation>
</message>
<message>
<source>Red Channel Greyscale</source>
@@ -4607,6 +4607,38 @@ Do you want to create it?</source>
<source>SnapSensitivity</source>
<translation>スナップ感度</translation>
</message>
+ <message>
+ <source>&amp;New Vector Level</source>
+ <translation>新規ベクターレベル (&amp;N)</translation>
+ </message>
+ <message>
+ <source>New Vector Level</source>
+ <translation>新規ベクターレベル</translation>
+ </message>
+ <message>
+ <source>&amp;New Toonz Raster Level</source>
+ <translation>新規Toonzラスターレベル (&amp;N)</translation>
+ </message>
+ <message>
+ <source>New Toonz Raster Level</source>
+ <translation>新規Toonzラスターレベル</translation>
+ </message>
+ <message>
+ <source>&amp;New Raster Level</source>
+ <translation>新規ラスターレベル (&amp;N)</translation>
+ </message>
+ <message>
+ <source>New Raster Level</source>
+ <translation>新規ラスターレベル</translation>
+ </message>
+ <message>
+ <source>Alpha Channel</source>
+ <translation>アルファチャンネル</translation>
+ </message>
+ <message>
+ <source>&amp;Command Bar</source>
+ <translation>コマンドバー (&amp;C)</translation>
+ </message>
</context>
<context>
<name>MatchlinesDialog</name>
@@ -5563,7 +5595,7 @@ WARNING : Image size mismatch. The size of level with the same path is %1 x %2.<
<message>
<source>
WARNING : Image size mismatch. The saved image size is %1 x %2.</source>
- <translation type="unfinished">
+ <translation>
警告: 画像サイズの不一致。保存されている画像のサイズは %1 x %2 ピクセルです。</translation>
</message>
</context>
@@ -5702,11 +5734,11 @@ WARNING : Image size mismatch. The saved image size is %1 x %2.</source>
</message>
<message>
<source>Full Matte</source>
- <translation>不透明化</translation>
+ <translation type="vanished">不透明化</translation>
</message>
<message>
<source>Zero Matte</source>
- <translation>透明化</translation>
+ <translation type="vanished">透明化</translation>
</message>
<message>
<source>Scale (%)</source>
@@ -5730,12 +5762,24 @@ WARNING : Image size mismatch. The saved image size is %1 x %2.</source>
</message>
<message>
<source>Matte</source>
- <translation>アルファチャンネル</translation>
+ <translation type="vanished">アルファチャンネル</translation>
</message>
<message>
<source>Color</source>
<translation>色</translation>
</message>
+ <message>
+ <source>Full Alpha</source>
+ <translation>不透明化</translation>
+ </message>
+ <message>
+ <source>Zero Alpha</source>
+ <translation>透明化</translation>
+ </message>
+ <message>
+ <source>Alpha</source>
+ <translation>アルファチャンネル</translation>
+ </message>
</context>
<context>
<name>PreferencesPopup</name>
@@ -6466,6 +6510,14 @@ Is it OK to release these shortcuts?</source>
<source>Vector Snapping:</source>
<translation>ベクターのスナップ:</translation>
</message>
+ <message>
+ <source>New Levels Default to the Current Camera Size</source>
+ <translation>新しく作るレベルのサイズ・DPIの既定値を現在のカメラに合わせる</translation>
+ </message>
+ <message>
+ <source>Enable OpenToonz Commands&apos; Shortcut Keys While Renaming Cell</source>
+ <translation>タイムシートのコマ入力時にOpenToonzコマンドのショートカットキーを有効にする</translation>
+ </message>
</context>
<context>
<name>PreferencesPopup::FormatProperties</name>
@@ -8179,6 +8231,10 @@ Are you sure?</source>
<source>Layer name</source>
<translation>レイヤー名</translation>
</message>
+ <message>
+ <source>Command Bar</source>
+ <translation>コマンドバー</translation>
+ </message>
</context>
<context>
<name>RenameAsToonzPopup</name>
@@ -10837,15 +10893,15 @@ Please refer to the user guide for details.</source>
<name>XsheetGUI::Toolbar</name>
<message>
<source>New Vector Level</source>
- <translation>新規ベクターレベル</translation>
+ <translation type="vanished">新規ベクターレベル</translation>
</message>
<message>
<source>New Toonz Raster Level</source>
- <translation>新規Toonzラスターレベル</translation>
+ <translation type="vanished">新規Toonzラスターレベル</translation>
</message>
<message>
<source>New Raster Level</source>
- <translation>新規ラスターレベル</translation>
+ <translation type="vanished">新規ラスターレベル</translation>
</message>
</context>
<context>