diff --git a/sources/iwlayer.cpp b/sources/iwlayer.cpp index 96ed1b8..782c65d 100644 --- a/sources/iwlayer.cpp +++ b/sources/iwlayer.cpp @@ -17,6 +17,7 @@ #include "iwtimelinekeyselection.h" #include "iwtrianglecache.h" #include "keydragtool.h" +#include "menubarcommandids.h" #include #include @@ -862,6 +863,9 @@ void IwLayer::onRightClick(int row, QMenu& menu) { menu.addAction(parentChildAct); //---- + menu.addAction( + CommandManager::instance()->getAction(MI_PasteMatteInfo)); + return; } currentRow += shapePair->getRowCount(); diff --git a/sources/iwshapepairselection.cpp b/sources/iwshapepairselection.cpp index fde9c2f..8650b4e 100644 --- a/sources/iwshapepairselection.cpp +++ b/sources/iwshapepairselection.cpp @@ -120,6 +120,7 @@ void IwShapePairSelection::enableCommands() { enableCommand(this, MI_ToggleShapeLock, &IwShapePairSelection::toggleLocks); enableCommand(this, MI_ToggleVisibility, &IwShapePairSelection::toggleVisibility); + enableCommand(this, MI_PasteMatteInfo, &IwShapePairSelection::pasteMatteInfo); } bool IwShapePairSelection::isEmpty() const { return m_shapes.isEmpty(); } @@ -680,6 +681,44 @@ void IwShapePairSelection::setShapeTag(int tagId, bool on) { new SetShapeTagUndo(m_shapes, project, tagId, on)); } +//--------------------------------------------------- +// マット情報貼り付け +//--------------------------------------------------- +void IwShapePairSelection::pasteMatteInfo() { + // プロジェクト無ければreturn + IwProject* project = IwApp::instance()->getCurrentProject()->getProject(); + if (!project) return; + + // クリップボードからデータを取り、ShapePairDataかどうか確認 + QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* mimeData = clipboard->mimeData(); + const ShapePairData* shapePairData = + dynamic_cast(mimeData); + // データが違っていたらreturn + if (!shapePairData) return; + // とりあえず、コピーしたシェイプは1つだけである必要 + if (shapePairData->m_data.count() != 1) return; + + ShapePair::MatteInfo matteInfo = shapePairData->m_data[0]->matteInfo(); + + // 選択シェイプ取得 + QList::iterator i = m_shapes.begin(); + QList shapePairs; + while (i != m_shapes.end()) { + if ((*i).shapePairP && project->contains((*i).shapePairP) && + !shapePairs.contains((*i).shapePairP)) { + shapePairs.append((*i).shapePairP); + } + i++; + } + + if (shapePairs.isEmpty()) return; + + // Undoに登録 同時にredoが呼ばれる + IwUndoManager::instance()->push( + new PasteMatteInfoUndo(shapePairs, project, matteInfo)); +} + //--------------------------------------------------- // 以下、Undoコマンドを登録 //--------------------------------------------------- @@ -894,3 +933,40 @@ void SetShapeTagUndo::setTag(bool isUndo) { void SetShapeTagUndo::undo() { setTag(true); } void SetShapeTagUndo::redo() { setTag(false); } + +//--------------------------------------------------- +// マット情報貼り付けのUndo +//--------------------------------------------------- + +PasteMatteInfoUndo::PasteMatteInfoUndo(QList& shapePairs, + IwProject* project, + ShapePair::MatteInfo newInfo) + : m_project(project), m_newInfo(newInfo) { + for (auto shapePair : shapePairs) { + m_prevMatteInfos.append(QPair( + shapePair, shapePair->matteInfo())); + } +} + +void PasteMatteInfoUndo::undo() { + for (auto infoData : m_prevMatteInfos) { + ShapePair* shapePair = infoData.first; + ShapePair::MatteInfo info = infoData.second; + shapePair->setMatteLayerName(info.layerName); + shapePair->setMatteColors(info.colors); + shapePair->setMatteTolerance(info.tolerance); + } + if (m_project->isCurrent()) + IwApp::instance()->getCurrentProject()->notifyProjectChanged(); +} + +void PasteMatteInfoUndo::redo() { + for (auto infoData : m_prevMatteInfos) { + ShapePair* shapePair = infoData.first; + shapePair->setMatteLayerName(m_newInfo.layerName); + shapePair->setMatteColors(m_newInfo.colors); + shapePair->setMatteTolerance(m_newInfo.tolerance); + } + if (m_project->isCurrent()) + IwApp::instance()->getCurrentProject()->notifyProjectChanged(); +} \ No newline at end of file diff --git a/sources/iwshapepairselection.h b/sources/iwshapepairselection.h index 5fe1a86..e0079ac 100644 --- a/sources/iwshapepairselection.h +++ b/sources/iwshapepairselection.h @@ -127,6 +127,9 @@ class IwShapePairSelection : public IwSelection // singleton // シェイプタグ切り替え void setShapeTag(int tagId, bool on); + + // マット情報貼り付け + void pasteMatteInfo(); }; //--------------------------------------------------- @@ -245,4 +248,20 @@ class SetShapeTagUndo : public QUndoCommand { void undo(); void redo(); }; + +//--------------------------------------------------- +// マット情報貼り付けのUndo +//--------------------------------------------------- + +class PasteMatteInfoUndo : public QUndoCommand { + QList> m_prevMatteInfos; + IwProject* m_project; + ShapePair::MatteInfo m_newInfo; + +public: + PasteMatteInfoUndo(QList& shapePairs, IwProject* project, + ShapePair::MatteInfo newInfo); + void undo(); + void redo(); +}; #endif \ No newline at end of file diff --git a/sources/mainwindow.cpp b/sources/mainwindow.cpp index 5393856..769bd4f 100644 --- a/sources/mainwindow.cpp +++ b/sources/mainwindow.cpp @@ -420,6 +420,8 @@ void MainWindow::defineActions() { MenuShapeCommandType); createAction(MI_ToggleVisibility, tr("Toggle Visibility of Selected Shapes"), "", MenuShapeCommandType); + createAction(MI_PasteMatteInfo, tr("Paste Matte Info"), "Ctrl+Alt+V", + MenuShapeCommandType); } //--------------------------------------------------- diff --git a/sources/menubarcommandids.h b/sources/menubarcommandids.h index 98d0504..a7d03e9 100644 --- a/sources/menubarcommandids.h +++ b/sources/menubarcommandids.h @@ -51,6 +51,7 @@ #define MI_ToggleShapeLock "MI_ToggleShapeLock" #define MI_ToggleVisibility "MI_ToggleVisibility" #define MI_MatteInfo "MI_MatteInfo" +#define MI_PasteMatteInfo "MI_PasteMatteInfo" //---- 上側の表示コントロールツールバーのコマンド // #define VMI_MultiFrameMode "VMI_MultiFrameMode" diff --git a/sources/shapeoptionsdialog.cpp b/sources/shapeoptionsdialog.cpp index 0a7d982..1174271 100644 --- a/sources/shapeoptionsdialog.cpp +++ b/sources/shapeoptionsdialog.cpp @@ -267,6 +267,7 @@ void ShapeOptionsDialog::onSelectionChanged(IwSelection *selection) { m_depthEdit->setText(QString::number(minDepth)); else m_depthEdit->setText(QString("%1 - %2").arg(minDepth).arg(maxDepth)); + } else { m_depthSlider->setDisabled(true); m_depthEdit->setDisabled(true);