Call Piece Options and Delete Piece from the piece list context menu.
This commit is contained in:
parent
f1ecc80e03
commit
6d1b7a9212
|
@ -39,6 +39,7 @@
|
|||
- [#984] Issue with up to date list of unique names.
|
||||
- Tracking changes/prevent "OK" recalculation after "Apply".
|
||||
- Change behavior for menu Pattern piece -> Show main path. Now it has an influence on export as well.
|
||||
- Call Piece Options and Delete Piece from the piece list context menu.
|
||||
|
||||
# Version 0.6.2 (unreleased)
|
||||
- [#903] Bug in tool Cut Spline path.
|
||||
|
|
|
@ -263,12 +263,44 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
|
|||
QAction *actionSelectAll = menu->addAction(tr("Select all"));
|
||||
QAction *actionSelectNone = menu->addAction(tr("Select none"));
|
||||
|
||||
QAction *actionSeparator = new QAction(this);
|
||||
actionSeparator->setSeparator(true);
|
||||
menu->addAction(actionSeparator);
|
||||
menu->addSeparator();
|
||||
|
||||
QAction *actionInvertSelection = menu->addAction(tr("Invert selection"));
|
||||
|
||||
bool pieceMode = false;
|
||||
QAction *actionPieceOptions = nullptr;
|
||||
QAction *actionDeletePiece = nullptr;
|
||||
VToolSeamAllowance *toolPiece = nullptr;
|
||||
|
||||
QTableWidgetItem *selectedItem = ui->tableWidget->itemAt(pos);
|
||||
if (selectedItem)
|
||||
{
|
||||
QTableWidgetItem *item = ui->tableWidget->item(selectedItem->row(), PieceColumn::InLayout);
|
||||
const quint32 id = item->data(Qt::UserRole).toUInt();
|
||||
|
||||
try
|
||||
{
|
||||
toolPiece = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(id));
|
||||
if (toolPiece)
|
||||
{
|
||||
pieceMode = true;
|
||||
menu->addSeparator();
|
||||
|
||||
actionPieceOptions = menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")),
|
||||
tr("Piece options"));
|
||||
|
||||
actionDeletePiece = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")),
|
||||
tr("Delete piece"));
|
||||
actionDeletePiece->setDisabled(toolPiece->referens() > 0);
|
||||
}
|
||||
}
|
||||
catch (const VExceptionBadId &)
|
||||
{
|
||||
const QString errorMsg = tr("Cannot find piece by id '%1'").arg(id);
|
||||
qWarning() << VAbstractApplication::patternMessageSignature + errorMsg;
|
||||
}
|
||||
}
|
||||
|
||||
const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
|
||||
if (allDetails->count() == 0)
|
||||
{
|
||||
|
@ -333,6 +365,23 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
|
|||
|
||||
qApp->getUndoStack()->endMacro();
|
||||
}
|
||||
else if (pieceMode && selectedAction == actionPieceOptions)
|
||||
{
|
||||
toolPiece->ShowOptions();
|
||||
}
|
||||
else if (pieceMode && selectedAction == actionDeletePiece)
|
||||
{
|
||||
try
|
||||
{
|
||||
toolPiece->DeleteFromMenu();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
//Leave this method immediately after call!!!
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -133,6 +133,8 @@ public slots:
|
|||
void Highlight(quint32 id);
|
||||
void UpdateDetailLabel();
|
||||
void UpdatePatternInfo();
|
||||
void ShowOptions();
|
||||
void DeleteFromMenu();
|
||||
protected slots:
|
||||
void UpdateGrainline();
|
||||
void SaveMoveDetail(const QPointF &ptPos);
|
||||
|
@ -161,11 +163,9 @@ protected:
|
|||
virtual void SaveDialogChange(const QString &undoText = QString()) final;
|
||||
|
||||
private slots:
|
||||
void ShowOptions();
|
||||
void ToggleInLayout(bool checked);
|
||||
void ToggleForbidFlipping(bool checked);
|
||||
void ToggleForceFlipping(bool checked);
|
||||
void DeleteFromMenu();
|
||||
void ToggleExcludeState(quint32 id);
|
||||
void ToggleNodePointAngleType(quint32 id, PieceNodeAngle type);
|
||||
void ToggleNodePointPassmark(quint32 id, bool toggle);
|
||||
|
|
Loading…
Reference in New Issue
Block a user