From d08c7cb5e42c422d36ff6875a48b49c9dce5c87f Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Sep 08 2017 09:55:52 +0000 Subject: Enable shortcut command while renaming cell (#1451) * enable command while renaming cell * open left side of the cell for drag handle * make OT command shortcuts optional * escape key for clear focus --- diff --git a/stuff/config/loc/日本語/toonz.qm b/stuff/config/loc/日本語/toonz.qm index 023d322..7bd214a 100644 Binary files a/stuff/config/loc/日本語/toonz.qm and b/stuff/config/loc/日本語/toonz.qm differ diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index f3c5de6..5eb760f 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 f5aa372..7d0b645 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 0100623..77e6372 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 b607b68..c67ace3 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 b31188e..8933f59 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( 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( 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 f683a56..6de661e 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 1a47031..a0549e0 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? Matte Channel - アルファチャンネル + アルファチャンネル Red Channel Greyscale @@ -4607,6 +4607,38 @@ Do you want to create it? SnapSensitivity スナップ感度 + + &New Vector Level + 新規ベクターレベル (&N) + + + New Vector Level + 新規ベクターレベル + + + &New Toonz Raster Level + 新規Toonzラスターレベル (&N) + + + New Toonz Raster Level + 新規Toonzラスターレベル + + + &New Raster Level + 新規ラスターレベル (&N) + + + New Raster Level + 新規ラスターレベル + + + Alpha Channel + アルファチャンネル + + + &Command Bar + コマンドバー (&C) + MatchlinesDialog @@ -5563,7 +5595,7 @@ WARNING : Image size mismatch. The size of level with the same path is %1 x %2.< WARNING : Image size mismatch. The saved image size is %1 x %2. - + 警告: 画像サイズの不一致。保存されている画像のサイズは %1 x %2 ピクセルです。 @@ -5702,11 +5734,11 @@ WARNING : Image size mismatch. The saved image size is %1 x %2. Full Matte - 不透明化 + 不透明化 Zero Matte - 透明化 + 透明化 Scale (%) @@ -5730,12 +5762,24 @@ WARNING : Image size mismatch. The saved image size is %1 x %2. Matte - アルファチャンネル + アルファチャンネル Color + + Full Alpha + 不透明化 + + + Zero Alpha + 透明化 + + + Alpha + アルファチャンネル + PreferencesPopup @@ -6466,6 +6510,14 @@ Is it OK to release these shortcuts? Vector Snapping: ベクターのスナップ: + + New Levels Default to the Current Camera Size + 新しく作るレベルのサイズ・DPIの既定値を現在のカメラに合わせる + + + Enable OpenToonz Commands' Shortcut Keys While Renaming Cell + タイムシートのコマ入力時にOpenToonzコマンドのショートカットキーを有効にする + PreferencesPopup::FormatProperties @@ -8179,6 +8231,10 @@ Are you sure? Layer name レイヤー名 + + Command Bar + コマンドバー + RenameAsToonzPopup @@ -10837,15 +10893,15 @@ Please refer to the user guide for details. XsheetGUI::Toolbar New Vector Level - 新規ベクターレベル + 新規ベクターレベル New Toonz Raster Level - 新規Toonzラスターレベル + 新規Toonzラスターレベル New Raster Level - 新規ラスターレベル + 新規ラスターレベル