OpenToonz - An open-source full-featured 2D animation creation software
C
selection aware command name by Contrail Co.,ltd.
shun-iwasawaafe084fe07b0
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 42053092a..67d8eeb29 100644Binary 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" differdiff --git a/toonz/sources/include/toonzqt/selection.h b/toonz/sources/include/toonzqt/selection.hindex 57e72436a..90e76c293 100644--- a/toonz/sources/include/toonzqt/selection.h+++ b/toonz/sources/include/toonzqt/selection.h@@ -19,6 +19,8 @@class QMenu;class QWidget;+#include <QMap>+//=============================================================================// TSelection//-----------------------------------------------------------------------------@@ -74,8 +76,17 @@ public:void notifyView();+ // specify alternative command name when the selection is current.+ // the commands must be "Edit" category.+ const QMap<CommandId, QString> &alternativeCommandNames() {+ return m_alternativeCommandNames;+ }+private:View *m_view;++protected:+ QMap<CommandId, QString> m_alternativeCommandNames;};#endif // TSELECTION_Hdiff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cppindex 3b55ed1fe..2f34c58ea 100644--- a/toonz/sources/toonz/cellselection.cpp+++ b/toonz/sources/toonz/cellselection.cpp@@ -1444,7 +1444,9 @@ int TCellSelection::Range::getColCount() const { return m_c1 - m_c0 + 1; }// TCellSelection//------------------------------------------------------------------------------TCellSelection::TCellSelection() : m_timeStretchPopup(0), m_reframePopup(0) {}+TCellSelection::TCellSelection() : m_timeStretchPopup(0), m_reframePopup(0) {+ setAlternativeCommandNames();+}//-----------------------------------------------------------------------------@@ -1512,6 +1514,19 @@ void TCellSelection::enableCommands() {enableCommand(this, MI_Duplicate, &TCellSelection::duplicateFrames);enableCommand(this, MI_PasteDuplicate, &TCellSelection::pasteDuplicateCells);}++//-----------------------------------------------------------------------------++void TCellSelection::setAlternativeCommandNames() {+ m_alternativeCommandNames = {+ {MI_Copy, QObject::tr("Copy Cells", "TCellSelection")},+ {MI_Paste, QObject::tr("Paste Cells", "TCellSelection")},+ {MI_PasteInto, QObject::tr("Overwrite Paste Cells", "TCellSelection")},+ {MI_Cut, QObject::tr("Cut Cells", "TCellSelection")},+ {MI_Clear, QObject::tr("Delete Cells", "TCellSelection")},+ {MI_Insert, QObject::tr("Insert Cells", "TCellSelection")}};+}+//-----------------------------------------------------------------------------// Used in RenameCellField::eventFilter()diff --git a/toonz/sources/toonz/cellselection.h b/toonz/sources/toonz/cellselection.hindex 13d8bc394..e1a04bd57 100644--- a/toonz/sources/toonz/cellselection.h+++ b/toonz/sources/toonz/cellselection.h@@ -40,6 +40,7 @@ public:~TCellSelection();void enableCommands() override;+ void setAlternativeCommandNames();bool isEmpty() const override;diff --git a/toonz/sources/toonz/columnselection.cpp b/toonz/sources/toonz/columnselection.cppindex 03780d609..d1d208f02 100644--- a/toonz/sources/toonz/columnselection.cpp+++ b/toonz/sources/toonz/columnselection.cpp@@ -67,7 +67,9 @@ void getLevelSetFromColumnIndices(const std::set<int>& indices,// TColumnSelection//------------------------------------------------------------------------------TColumnSelection::TColumnSelection() : m_reframePopup(0) {}+TColumnSelection::TColumnSelection() : m_reframePopup(0) {+ setAlternativeCommandNames();+}//-----------------------------------------------------------------------------@@ -95,6 +97,16 @@ void TColumnSelection::enableCommands() {enableCommand(this, MI_ReframeWithEmptyInbetweens,&TColumnSelection::reframeWithEmptyInbetweens);}+//-----------------------------------------------------------------------------++void TColumnSelection::setAlternativeCommandNames() {+ m_alternativeCommandNames = {+ {MI_Copy, QObject::tr("Copy Columns", "TColumnSelection")},+ {MI_Paste, QObject::tr("Paste Columns", "TColumnSelection")},+ {MI_Cut, QObject::tr("Cut Columns", "TColumnSelection")},+ {MI_Clear, QObject::tr("Delete Columns", "TColumnSelection")},+ {MI_Insert, QObject::tr("Insert Columns", "TColumnSelection")}};+}//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/columnselection.h b/toonz/sources/toonz/columnselection.hindex fad22531e..323751bf6 100644--- a/toonz/sources/toonz/columnselection.h+++ b/toonz/sources/toonz/columnselection.h@@ -30,6 +30,7 @@ public:const std::set<int> &getIndices() const { return m_indices; }void enableCommands() override;+ void setAlternativeCommandNames();void copyColumns();void pasteColumns();diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex 938b6921f..ba0f88ee3 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -1393,6 +1393,14 @@ QAction *MainWindow::createAction(const char *id, const char *name,CommandType type, const char *iconSVGName) {QAction *action = new DVAction(tr(name), this);+ // For "edit" category menu commands may behave various function+ // according to the current selection.+ // Now the command name can be adjusted on switching the selection.+ // Here we explicitly register the default text in order to recover the+ // command name if the selection does not specify the alternative command+ // name.+ if (type == MenuEditCommandType) action->setIconText(tr(name));+#if !defined(_WIN32)bool visible = Preferences::instance()->getBoolValue(showIconsInMenu);action->setIconVisibleInMenu(visible);diff --git a/toonz/sources/toonzqt/tselectionhandle.cpp b/toonz/sources/toonzqt/tselectionhandle.cppindex 232a3b8df..69b9b1ed1 100644--- a/toonz/sources/toonzqt/tselectionhandle.cpp+++ b/toonz/sources/toonzqt/tselectionhandle.cpp@@ -23,18 +23,35 @@ TSelection *TSelectionHandle::getSelection() const {void TSelectionHandle::setSelection(TSelection *selection) {if (getSelection() == selection) return;- TSelection *oldSelection = getSelection();+ TSelection *oldSelection = getSelection();+ CommandManager *commandManager = CommandManager::instance();if (oldSelection) {oldSelection->selectNone();// disable selection related commands- CommandManager *commandManager = CommandManager::instance();int i;for (i = 0; i < (int)m_enabledCommandIds.size(); i++)commandManager->setHandler(m_enabledCommandIds[i].c_str(), 0);m_enabledCommandIds.clear();++ // revert alternative command names to original ones kept in the icon texts+ for (auto commandId : oldSelection->alternativeCommandNames().keys()) {+ QAction *action = commandManager->getAction(commandId);+ action->setText(action->iconText());+ }}m_selectionStack.back() = selection;- if (selection) selection->enableCommands();+ if (selection) {+ selection->enableCommands();++ // set alternative command names+ QMap<CommandId, QString>::const_iterator i =+ selection->alternativeCommandNames().constBegin();+ while (i != selection->alternativeCommandNames().constEnd()) {+ QAction *action = commandManager->getAction(i.key());+ action->setText(i.value());+ ++i;+ }+ }emit selectionSwitched(oldSelection, selection);}diff --git a/toonz/sources/translations/japanese/toonz.ts b/toonz/sources/translations/japanese/toonz.tsindex b0af63525..31415a8bd 100644--- a/toonz/sources/translations/japanese/toonz.ts+++ b/toonz/sources/translations/japanese/toonz.ts@@ -11680,7 +11680,7 @@ Are you sure to </source></message><message><source>Paste Column : </source>- <translation>列を貼り付け : </translation>+ <translation>列の貼り付け : </translation></message><message><source>Delete Column : </source>@@ -11800,7 +11800,7 @@ Are you sure to </source></message><message><source>Cut Cells</source>- <translation>コマのカット</translation>+ <translation>コマの切り取り</translation></message><message><source>Insert Cells</source>@@ -12946,6 +12946,61 @@ Do you wish to continue loading the last good save or stop and try to salvage th<source>Preproduction Board</source><translation type="unfinished"></translation></message>+ <message>+ <source>Copy Columns</source>+ <comment>TColumnSelection</comment>+ <translation>列のコピー</translation>+ </message>+ <message>+ <source>Paste Columns</source>+ <comment>TColumnSelection</comment>+ <translation>列の貼り付け</translation>+ </message>+ <message>+ <source>Cut Columns</source>+ <comment>TColumnSelection</comment>+ <translation>列の切り取り</translation>+ </message>+ <message>+ <source>Delete Columns</source>+ <comment>TColumnSelection</comment>+ <translation>列の削除</translation>+ </message>+ <message>+ <source>Insert Columns</source>+ <comment>TColumnSelection</comment>+ <translation>列を挿入</translation>+ </message>+ <message>+ <source>Copy Cells</source>+ <comment>TCellSelection</comment>+ <translation>コマのコピー</translation>+ </message>+ <message>+ <source>Paste Cells</source>+ <comment>TCellSelection</comment>+ <translation>コマの貼り付け</translation>+ </message>+ <message>+ <source>Overwrite Paste Cells</source>+ <comment>TCellSelection</comment>+ <translation>コマを上書きして貼り付け</translation>+ </message>+ <message>+ <source>Cut Cells</source>+ <comment>TCellSelection</comment>+ <translation>コマの切り取り</translation>+ </message>+ <message>+ <source>Delete Cells</source>+ <comment>TCellSelection</comment>+ <translation>コマの削除</translation>+ </message>+ <message>+ <source>Insert Cells</source>+ <comment>TCellSelection</comment>+ <translation>空白コマの挿入</translation>+ </message><message><source>Pasting external image from clipboard.