Skip to content

Commit

Permalink
Merge pull request #1051 from FashionFreedom/add-notch-subtype-to-con…
Browse files Browse the repository at this point in the history
…text-menu

feat: add notch subtype to context menu
  • Loading branch information
slspencer committed Dec 15, 2023
2 parents fd05e62 + 6f27e4f commit 9891812
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 20 deletions.
84 changes: 65 additions & 19 deletions src/libs/vtools/dialogs/tools/piece/pattern_piece_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,46 +630,64 @@ bool PatternPieceDialog::eventFilter(QObject *object, QEvent *event)
}
else if (keyEvent->modifiers() & Qt::ShiftModifier)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
NotchType notchType = rowNode.getNotchType();
NotchSubType notchSubType = rowNode.getNotchSubType();
switch (keyEvent->key())
{
case Qt::Key_X:
case Qt::Key_N:
{
setNotch(rowItem, false, NotchType::Slit);
setNotch(rowItem, false, NotchType::Slit, notchSubType);
return true;
}
case Qt::Key_S:
{
setNotch(rowItem, true, NotchType::Slit);
setNotch(rowItem, true, NotchType::Slit, notchSubType);
return true;
}
case Qt::Key_T:
{
setNotch(rowItem, true, NotchType::TNotch);
setNotch(rowItem, true, NotchType::TNotch, notchSubType);
return true;
}
case Qt::Key_U:
{
setNotch(rowItem, true, NotchType::UNotch);
setNotch(rowItem, true, NotchType::UNotch, notchSubType);
return true;
}
case Qt::Key_I:
{
setNotch(rowItem, true, NotchType::VInternal);
setNotch(rowItem, true, NotchType::VInternal, notchSubType);
return true;
}
case Qt::Key_E:
{
setNotch(rowItem, true, NotchType::VExternal);
setNotch(rowItem, true, NotchType::VExternal, notchSubType);
return true;
}
case Qt::Key_C:
{
setNotch(rowItem, true, NotchType::Castle);
setNotch(rowItem, true, NotchType::Castle, notchSubType);
return true;
}
case Qt::Key_D:
{
setNotch(rowItem, true, NotchType::Diamond);
setNotch(rowItem, true, NotchType::Diamond, notchSubType);
return true;
}
case Qt::Key_F:
{
setNotch(rowItem, true, notchType, NotchSubType::Straightforward);
return true;
}
case Qt::Key_B:
{
setNotch(rowItem, true, notchType, NotchSubType::Bisector);
return true;
}
case Qt::Key_X:
{
setNotch(rowItem, true, notchType, NotchSubType::Intersection);
return true;
}
}
Expand Down Expand Up @@ -772,6 +790,7 @@ void PatternPieceDialog::showMainPathContextMenu(const QPoint &pos)
QScopedPointer<QMenu> menu(new QMenu(ui->mainPath_ListWidget));
NodeInfo info;
NotchType notchType = NotchType::Slit;
NotchSubType notchSubType = NotchSubType::Straightforward;
bool isNotch = false;
QListWidgetItem *rowItem = ui->mainPath_ListWidget->item(row);
SCASSERT(rowItem != nullptr);
Expand All @@ -787,6 +806,10 @@ void PatternPieceDialog::showMainPathContextMenu(const QPoint &pos)
QAction *actionCastle = nullptr;
QAction *actionDiamond = nullptr;

QAction *actionStraightforward = nullptr;
QAction *actionBisector = nullptr;
QAction *actionIntersection = nullptr;

QAction *actionReverse = nullptr;
QAction *actionDuplicate = nullptr;

Expand All @@ -805,14 +828,20 @@ void PatternPieceDialog::showMainPathContextMenu(const QPoint &pos)
actionNotch->setCheckable(true);
actionNotch->setChecked(rowNode.isNotch());

actionNone = notchMenu->addAction( tr("None") + QStringLiteral("\tShift + X"));
actionSlit = notchMenu->addAction(QIcon("://icon/24x24/slit_notch.png"), tr("Slit") + QStringLiteral("\tShift + S"));
actionTNotch = notchMenu->addAction(QIcon("://icon/24x24/t_notch.png"), tr("TNotch") + QStringLiteral("\tShift + T"));
actionUNotch = notchMenu->addAction(QIcon("://icon/24x24/u_notch.png"), tr("UNotch") + QStringLiteral("\tShift + U"));
actionVInternal = notchMenu->addAction(QIcon("://icon/24x24/internal_v_notch.png"), tr("VInternal") + QStringLiteral("\tShift + I"));
actionVExternal = notchMenu->addAction(QIcon("://icon/24x24/external_v_notch.png"), tr("VExternal") + QStringLiteral("\tShift + E"));
actionCastle = notchMenu->addAction(QIcon("://icon/24x24/castle_notch.png"), tr("Castle") + QStringLiteral("\tShift + C"));
actionDiamond = notchMenu->addAction(QIcon("://icon/24x24/diamond_notch.png"), tr("Diamond") + QStringLiteral("\tShift + D"));
QMenu *notchTypeMenu = notchMenu->addMenu(tr("Type"));
actionNone = notchTypeMenu->addAction( tr("None") + QStringLiteral("\tShift + N"));
actionSlit = notchTypeMenu->addAction(QIcon("://icon/24x24/slit_notch.png"), tr("Slit") + QStringLiteral("\tShift + S"));
actionTNotch = notchTypeMenu->addAction(QIcon("://icon/24x24/t_notch.png"), tr("TNotch") + QStringLiteral("\tShift + T"));
actionUNotch = notchTypeMenu->addAction(QIcon("://icon/24x24/u_notch.png"), tr("UNotch") + QStringLiteral("\tShift + U"));
actionVInternal = notchTypeMenu->addAction(QIcon("://icon/24x24/internal_v_notch.png"), tr("VInternal") + QStringLiteral("\tShift + I"));
actionVExternal = notchTypeMenu->addAction(QIcon("://icon/24x24/external_v_notch.png"), tr("VExternal") + QStringLiteral("\tShift + E"));
actionCastle = notchTypeMenu->addAction(QIcon("://icon/24x24/castle_notch.png"), tr("Castle") + QStringLiteral("\tShift + C"));
actionDiamond = notchTypeMenu->addAction(QIcon("://icon/24x24/diamond_notch.png"), tr("Diamond") + QStringLiteral("\tShift + D"));

QMenu *notchSubtypeMenu = notchMenu->addMenu(tr("Subtype"));
actionStraightforward = notchSubtypeMenu->addAction(QIcon(), tr("Straightforward") + QStringLiteral("\tShift + F"));
actionBisector = notchSubtypeMenu->addAction(QIcon(), tr("Bisector") + QStringLiteral("\tShift + B"));
actionIntersection = notchSubtypeMenu->addAction(QIcon(), tr("Intersection") + QStringLiteral("\tShift + X"));
}

QAction *actionExcluded = menu->addAction(tr("Excluded") + QStringLiteral("\tCtrl + E"));
Expand Down Expand Up @@ -880,8 +909,23 @@ void PatternPieceDialog::showMainPathContextMenu(const QPoint &pos)
isNotch = true;
notchType = NotchType::Diamond;
}
else if (selectedAction == actionStraightforward)
{
isNotch = true;
notchSubType = NotchSubType::Straightforward;
}
else if (selectedAction == actionBisector)
{
isNotch = true;
notchSubType = NotchSubType::Bisector;
}
else if (selectedAction == actionIntersection)
{
isNotch = true;
notchSubType = NotchSubType::Intersection;
}

setNotch(rowItem, isNotch, notchType);
setNotch(rowItem, isNotch, notchType, notchSubType);
}

validateObjects(isMainPathValid());
Expand Down Expand Up @@ -3487,13 +3531,15 @@ QString PatternPieceDialog::createPieceName() const
* @param rowItem list widget item of the selected row.
* @param notchType of the selected submenu item.
*/
void PatternPieceDialog::setNotch(QListWidgetItem *rowItem, bool isNotch, NotchType notchType)
void PatternPieceDialog::setNotch(QListWidgetItem *rowItem, bool isNotch, NotchType notchType,
NotchSubType notchSubType)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
if (rowNode.GetTypeTool() == Tool::NodePoint)
{
rowNode.setNotch(isNotch);
rowNode.setNotchType(notchType);
rowNode.setNotchSubType(notchSubType);
NodeInfo info;
info = getNodeInfo(rowNode, true);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
Expand Down
3 changes: 2 additions & 1 deletion src/libs/vtools/dialogs/tools/piece/pattern_piece_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ private slots:
void reverseNode(QListWidgetItem *rowItem);
void duplicateNode(QListWidgetItem *rowItem);
void excludeNode(QListWidgetItem *rowItem);
void setNotch(QListWidgetItem *rowItem, bool isNotch, NotchType notchType);
void setNotch(QListWidgetItem *rowItem, bool isNotch, NotchType notchType,
NotchSubType notchSubType);
void setCurrentText(QComboBox *box, const QString &text) const;
qreal getFormulaValue(QPlainTextEdit *text) const;
};
Expand Down

0 comments on commit 9891812

Please sign in to comment.