Skip to content

Commit

Permalink
Paste cells command behavior option by Contrail Co.,Ltd.
Browse files Browse the repository at this point in the history
an option for increasing consistency with QuickChecker
  • Loading branch information
shun-iwasawa committed Mar 14, 2023
1 parent 50b142c commit 5592660
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion toonz/sources/include/toonz/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class DVAPI Preferences final : public QObject // singleton
int getDeleteCommandBehaviour() const {
return getIntValue(deleteCommandBehavior);
}

int getPasteCellsBehavior() const { return getIntValue(pasteCellsBehavior); }
bool isIgnoreAlphaonColumn1Enabled() const {
return getBoolValue(ignoreAlphaonColumn1Enabled);
}
Expand Down
1 change: 1 addition & 0 deletions toonz/sources/include/toonz/preferencesitemids.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ enum PreferencesItemId {
xsheetAutopanEnabled,
DragCellsBehaviour,
deleteCommandBehavior,
pasteCellsBehavior,
ignoreAlphaonColumn1Enabled,
showKeyframesOnXsheetCellArea,
showXsheetCameraColumn,
Expand Down
1 change: 1 addition & 0 deletions toonz/sources/include/toonzqt/selectioncommandids.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
#define MI_ExplodeChild "MI_ExplodeChild"
#define MI_ToggleEditInPlace "MI_ToggleEditInPlace"
#define MI_PasteNumbers "MI_PasteNumbers"
#define MI_PasteWholeCellData "MI_PasteWholeCellData"

#endif
16 changes: 15 additions & 1 deletion toonz/sources/toonz/cellselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,9 @@ void TCellSelection::enableCommands() {
enableCommand(this, MI_ShiftKeyframesUp, &TCellSelection::shiftKeyframesUp);

enableCommand(this, MI_Copy, &TCellSelection::copyCells);
enableCommand(this, MI_Paste, &TCellSelection::pasteCells);
enableCommand(this, MI_Paste,
&TCellSelection::doPaste); // choose pasting behavior by
// preference option

if (dynamic_cast<const TKeyframeData *>(
QApplication::clipboard()->mimeData()))
Expand All @@ -1507,6 +1509,7 @@ void TCellSelection::enableCommands() {
&TCellSelection::reframeWithEmptyInbetweens);

enableCommand(this, MI_PasteNumbers, &TCellSelection::overwritePasteNumbers);
enableCommand(this, MI_PasteWholeCellData, &TCellSelection::pasteCells);
enableCommand(this, MI_CreateBlankDrawing,
&TCellSelection::createBlankDrawings);
enableCommand(this, MI_Duplicate, &TCellSelection::duplicateFrames);
Expand Down Expand Up @@ -1552,6 +1555,7 @@ bool TCellSelection::isEnabledCommand(
MI_Undo,
MI_Redo,
MI_PasteNumbers,
MI_PasteWholeCellData,
MI_ConvertToToonzRaster,
MI_ConvertVectorToVector,
MI_CreateBlankDrawing,
Expand Down Expand Up @@ -1726,6 +1730,16 @@ static void pasteRasterImageInCell(int row, int col,
}
}

//-----------------------------------------------------------------------------
// choose pasting behavior by preference option
void TCellSelection::doPaste() {
if (Preferences::instance()->getPasteCellsBehavior() ==
0) // insert paste whole contents of copied cells
pasteCells();
else // overwrite paste numbers, consistent with QuickChecker
overwritePasteNumbers();
}

//-----------------------------------------------------------------------------

void TCellSelection::pasteCells() {
Expand Down
1 change: 1 addition & 0 deletions toonz/sources/toonz/cellselection.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TCellSelection final : public TSelection {

void copyCells();
void pasteCells();
void doPaste(); // choose pasting behavior by preference option
void pasteDuplicateCells();
void deleteCells();
void deleteCells(bool withShift);
Expand Down
2 changes: 2 additions & 0 deletions toonz/sources/toonz/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2299,6 +2299,8 @@ void MainWindow::defineActions() {
"", "shift_keys_up");
createRightClickMenuAction(MI_PasteNumbers, QT_TR_NOOP("&Paste Numbers"), "",
"paste_numbers");
createRightClickMenuAction(MI_PasteWholeCellData,
QT_TR_NOOP("&Paste Whole Cell Data"), "", "paste");

createRightClickMenuAction(MI_Histogram, QT_TR_NOOP("&Histogram"), "");
// MI_ViewerHistogram command is used as a proxy. It will be called when
Expand Down
5 changes: 5 additions & 0 deletions toonz/sources/toonz/preferencespopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
{xsheetAutopanEnabled, tr("Xsheet Autopan during Playback")},
{DragCellsBehaviour, tr("Cell-dragging Behaviour:")},
{deleteCommandBehavior, tr("Delete Command Behaviour:")},
{pasteCellsBehavior, tr("Paste Cells Behaviour:")},
{ignoreAlphaonColumn1Enabled,
tr("Ignore Alpha Channel on Levels in Column 1")},
{showKeyframesOnXsheetCellArea, tr("Show Keyframes on Cell Area")},
Expand Down Expand Up @@ -1431,6 +1432,9 @@ QList<ComboBoxItem> PreferencesPopup::getComboItemList(
{deleteCommandBehavior,
{{tr("Clear Cell / Frame"), 0},
{tr("Remove and Shift Cells / Frames Up"), 1}}},
{pasteCellsBehavior,
{{tr("Insert Paste Whole Data"), 0},
{tr("Overwrite Paste Cell Numbers"), 1}}},
{keyframeType, // note that the value starts from 1, not 0
{{tr("Constant"), 1},
{tr("Linear"), 2},
Expand Down Expand Up @@ -1992,6 +1996,7 @@ QWidget* PreferencesPopup::createXsheetPage() {
insertUI(xsheetAutopanEnabled, lay);
insertUI(DragCellsBehaviour, lay, getComboItemList(DragCellsBehaviour));
insertUI(deleteCommandBehavior, lay, getComboItemList(deleteCommandBehavior));
insertUI(pasteCellsBehavior, lay, getComboItemList(pasteCellsBehavior));
insertUI(ignoreAlphaonColumn1Enabled, lay);
QGridLayout* showKeyLay =
insertGroupBoxUI(showKeyframesOnXsheetCellArea, lay);
Expand Down
8 changes: 7 additions & 1 deletion toonz/sources/toonz/xshcellviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3861,7 +3861,13 @@ void CellArea::createCellMenu(QMenu &menu, bool isCellSelected, TXshCell cell,
QMenu *pasteSpecialMenu = new QMenu(tr("Paste Special"), this);
{
pasteSpecialMenu->addAction(cmdManager->getAction(MI_PasteInto));
pasteSpecialMenu->addAction(cmdManager->getAction(MI_PasteNumbers));
// the "standard" paste behavior for MI_Paste is specified in the
// preferences. here we display the alternative behavior.
if (Preferences::instance()->getPasteCellsBehavior() == 0)
pasteSpecialMenu->addAction(cmdManager->getAction(MI_PasteNumbers));
else
pasteSpecialMenu->addAction(
cmdManager->getAction(MI_PasteWholeCellData));
if (!soundTextCellsSelected) {
pasteSpecialMenu->addAction(cmdManager->getAction(MI_PasteDuplicate));
}
Expand Down
2 changes: 2 additions & 0 deletions toonz/sources/toonzlib/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ void Preferences::definePreferenceItems() {
1); // Cells and Column Data
define(deleteCommandBehavior, "deleteCommandBehavior", QMetaType::Int,
0); // Clear Cell / Frame
define(pasteCellsBehavior, "pasteCellsBehavior", QMetaType::Int,
0); // Insert paste whole cell data
define(ignoreAlphaonColumn1Enabled, "ignoreAlphaonColumn1Enabled",
QMetaType::Bool, false);
define(showKeyframesOnXsheetCellArea, "showKeyframesOnXsheetCellArea",
Expand Down

0 comments on commit 5592660

Please sign in to comment.