Context-menu on a piece in the carrousel should be the same as the context menu of a piece in the sheet
This commit is contained in:
parent
72a2300bef
commit
05b884a632
|
@ -176,8 +176,39 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
auto *pieceItem = static_cast<VPCarrouselPiece *> (_item);
|
auto *pieceItem = static_cast<VPCarrouselPiece *> (_item);
|
||||||
|
|
||||||
|
VPPiecePtr piece = pieceItem->GetPiece();
|
||||||
|
VPLayoutPtr layout = piece->Layout();
|
||||||
|
|
||||||
|
if (piece.isNull() || layout.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
|
QVector<QAction*> moveToActions;
|
||||||
|
|
||||||
|
if (not piece->Sheet().isNull())
|
||||||
|
{
|
||||||
|
QList<VPSheetPtr> sheets = layout->GetSheets();
|
||||||
|
sheets.removeAll(piece->Sheet());
|
||||||
|
|
||||||
|
if (not sheets.isEmpty())
|
||||||
|
{
|
||||||
|
QMenu *moveMenu = menu.addMenu(tr("Move to"));
|
||||||
|
|
||||||
|
for (const auto &sheet : sheets)
|
||||||
|
{
|
||||||
|
if (not sheet.isNull())
|
||||||
|
{
|
||||||
|
QAction* moveToSheet = moveMenu->addAction(sheet->GetName());
|
||||||
|
moveToSheet->setData(QVariant::fromValue(sheet));
|
||||||
|
moveToActions.append(moveToSheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QAction *moveAction = menu.addAction(tr("Move to Sheet"));
|
QAction *moveAction = menu.addAction(tr("Move to Sheet"));
|
||||||
moveAction->setVisible(false);
|
moveAction->setVisible(false);
|
||||||
|
|
||||||
|
@ -200,14 +231,6 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
|
||||||
QAction *selectedAction = menu.exec(event->globalPos());
|
QAction *selectedAction = menu.exec(event->globalPos());
|
||||||
|
|
||||||
VPPiecePtr piece = pieceItem->GetPiece();
|
|
||||||
VPLayoutPtr layout = piece->Layout();
|
|
||||||
|
|
||||||
if (piece.isNull() || layout.isNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedAction == moveAction)
|
if (selectedAction == moveAction)
|
||||||
{
|
{
|
||||||
VPSheetPtr sheet = layout->GetFocusedSheet();
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
@ -230,6 +253,11 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
|
||||||
auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece);
|
auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece);
|
||||||
layout->UndoStack()->push(command);
|
layout->UndoStack()->push(command);
|
||||||
}
|
}
|
||||||
|
else if (moveToActions.contains(selectedAction))
|
||||||
|
{
|
||||||
|
auto *command = new VPUndoMovePieceOnSheet(qvariant_cast<VPSheetPtr>(selectedAction->data()), piece);
|
||||||
|
layout->UndoStack()->push(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user