OpenToonz - An open-source full-featured 2D animation creation software
C
fix cell input feature
shun_iwasawae69dc07ca92e
diff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cppindex 6408a957c..81342c2a9 100644--- a/toonz/sources/toonz/cellselection.cpp+++ b/toonz/sources/toonz/cellselection.cpp@@ -1591,7 +1591,12 @@ void TCellSelection::deleteCells() {new DeleteCellsUndo(new TCellSelection(m_range), data);deleteCellsWithoutUndo(r0, c0, r1, c1);- selectNone();+ // emit selectionChanged() signal so that the rename field will update+ // accordingly+ if (Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled())+ TApp::instance()->getCurrentSelection()->notifySelectionChanged();+ else+ selectNone();TUndoManager::manager()->add(undo);TApp::instance()->getCurrentScene()->setDirtyFlag(true);@@ -1616,7 +1621,12 @@ void TCellSelection::cutCells(bool withoutCopy) {cutCellsWithoutUndo(r0, c0, r1, c1);TUndoManager::manager()->add(undo);- selectNone();+ // cutCellsWithoutUndo will clear the selection, so select cells again+ if (Preferences::instance()->isUseArrowKeyToShiftCellSelectionEnabled()) {+ selectCells(r0, c0, r1, c1);+ TApp::instance()->getCurrentSelection()->notifySelectionChanged();+ } else+ selectNone();TApp::instance()->getCurrentScene()->setDirtyFlag(true);}diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex ea09d773c..a3415904f 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -1652,7 +1652,7 @@ void MainWindow::defineActions() {tr("Toggle Link to Studio Palette"), "");createRightClickMenuAction(MI_RemoveReferenceToStudioPalette,tr("Remove Reference to Studio Palette"), "");- createMenuEditAction(MI_Clear, tr("&Delete"), "Delete");+ createMenuEditAction(MI_Clear, tr("&Delete"), "Del");createMenuEditAction(MI_Insert, tr("&Insert"), "Ins");createMenuEditAction(MI_Group, tr("&Group"), "Ctrl+G");createMenuEditAction(MI_Ungroup, tr("&Ungroup"), "Ctrl+Shift+G");diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cppindex e7db7d557..68e644a6a 100644--- a/toonz/sources/toonz/xshcellviewer.cpp+++ b/toonz/sources/toonz/xshcellviewer.cpp@@ -496,7 +496,6 @@ namespace XsheetGUI {RenameCellField::RenameCellField(QWidget *parent, XsheetViewer *viewer): QLineEdit(parent), m_viewer(viewer), m_row(-1), m_col(-1) {- setFixedSize(XsheetGUI::ColumnWidth + 3, XsheetGUI::RowHeight + 4);connect(this, SIGNAL(returnPressed()), SLOT(onReturnPressed()));setContextMenuPolicy(Qt::PreventContextMenu);setObjectName("RenameCellField");@@ -512,7 +511,6 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {m_row = row;m_col = col;- move(QPoint(m_viewer->columnToX(col) - 1, m_viewer->rowToY(row) - 2));#ifdef _WIN32static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal);#else@@ -546,6 +544,9 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {TXshCell cell = xsh->getCell(row, col);if (!cell.isEmpty()) {+ setFixedSize(XsheetGUI::ColumnWidth - 5, XsheetGUI::RowHeight + 4);+ move(QPoint(m_viewer->columnToX(col) + 7, m_viewer->rowToY(row) - 2));+TFrameId fid = cell.getFrameId();std::wstring levelName = cell.m_level->getName();@@ -574,6 +575,9 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) {}// clear the field if the empty cell is clickedelse {+ setFixedSize(XsheetGUI::ColumnWidth + 3, XsheetGUI::RowHeight + 4);+ move(QPoint(m_viewer->columnToX(col) - 1, m_viewer->rowToY(row) - 2));+setText("");}show();@@ -733,8 +737,10 @@ bool RenameCellField::eventFilter(QObject *obj, QEvent *e) {QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);if (!action) return false;- return TCellSelection::isEnabledCommand(- CommandManager::instance()->getIdFromAction(action));+ std::string actionId = CommandManager::instance()->getIdFromAction(action);++ if (actionId == "MI_Undo" || actionId == "MI_Redo") return true;+ return TCellSelection::isEnabledCommand(actionId);}//-----------------------------------------------------------------------------@@ -791,6 +797,34 @@ void RenameCellField::keyPressEvent(QKeyEvent *event) {TApp::instance()->getCurrentSelection()->notifySelectionChanged();}+//-----------------------------------------------------------------------------++void RenameCellField::showEvent(QShowEvent *) {+ bool ret = connect(TApp::instance()->getCurrentXsheet(),+ SIGNAL(xsheetChanged()), this, SLOT(onXsheetChanged()));+ assert(ret);+}++//-----------------------------------------------------------------------------++void RenameCellField::hideEvent(QHideEvent *) {+ disconnect(TApp::instance()->getCurrentXsheet(), SIGNAL(xsheetChanged()),+ this, SLOT(onXsheetChanged()));+}++//-----------------------------------------------------------------------------++void RenameCellField::onXsheetChanged() {+ TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(+ TApp::instance()->getCurrentSelection()->getSelection());+ if (!cellSelection) {+ hide();+ return;+ }+ TCellSelection::Range range = cellSelection->getSelectedCells();+ showInRowCol(m_row, m_col, range.getColCount() > 1);+}+//=============================================================================// CellArea//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/xshcellviewer.h b/toonz/sources/toonz/xshcellviewer.hindex c033fc81c..2bd47629c 100644--- a/toonz/sources/toonz/xshcellviewer.h+++ b/toonz/sources/toonz/xshcellviewer.h@@ -36,10 +36,14 @@ protected:void keyPressEvent(QKeyEvent *event) override;bool eventFilter(QObject *, QEvent *) override;+ void showEvent(QShowEvent *) override;+ void hideEvent(QHideEvent *) override;+void renameCell();protected slots:void onReturnPressed();+ void onXsheetChanged();};//=============================================================================@@ -98,6 +102,7 @@ public:void showRenameField(int row, int col, bool multiColumnSelected = false) {m_renameCell->showInRowCol(row, col, multiColumnSelected);}+ void hideRenameField() { m_renameCell->hide(); }protected:void paintEvent(QPaintEvent *) override;diff --git a/toonz/sources/toonz/xsheetviewer.cpp b/toonz/sources/toonz/xsheetviewer.cppindex 7ca63c891..5a440a7f2 100644--- a/toonz/sources/toonz/xsheetviewer.cpp+++ b/toonz/sources/toonz/xsheetviewer.cpp@@ -1034,7 +1034,9 @@ void XsheetViewer::onSelectionChanged(TSelection *selection) {changeWindowTitle();if (Preferences::instance()->isInputCellsWithoutDoubleClickingEnabled()) {TCellSelection *cellSel = getCellSelection();- if (!cellSel->isEmpty())+ if (cellSel->isEmpty())+ m_cellArea->hideRenameField();+ elsem_cellArea->showRenameField(cellSel->getSelectedCells().m_r0, cellSel->getSelectedCells().m_c0,cellSel->getSelectedCells().getColCount() > 1);