Skip to content

Commit

Permalink
Add selection profile switch.
Browse files Browse the repository at this point in the history
Tab key press switch the profile of selection, this makes the item more easy to be selected on the other profile and then switch to this profile to edit, while the item is very hard to be selected in this profile.
  • Loading branch information
huxingyi committed Apr 18, 2018
1 parent fe11e09 commit 402ee09
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/skeletongraphicswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,10 @@ bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event)
scaleSelected(1);
emit groupOperationAdded();
}
} else if (event->key() == Qt::Key_Tab) {
if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) {
switchProfileOnRangeSelection();
}
}
return false;
}
Expand Down Expand Up @@ -1661,3 +1665,35 @@ void SkeletonGraphicsWidget::hoverPart(QUuid partId)
if (!m_lastCheckedPart.isNull())
emit partChecked(m_lastCheckedPart);
}

void SkeletonGraphicsWidget::switchProfileOnRangeSelection()
{
auto copiedSet = m_rangeSelectionSet;
for (const auto &item: copiedSet) {
if (item->data(0) == "node") {
SkeletonGraphicsNodeItem *nodeItem = (SkeletonGraphicsNodeItem *)item;
const auto &find = nodeItemMap.find(nodeItem->id());
if (find == nodeItemMap.end()) {
qDebug() << "Node item map key not found:" << nodeItem->id();
return;
}
checkSkeletonItem(nodeItem, false);
m_rangeSelectionSet.erase(nodeItem);
SkeletonGraphicsNodeItem *altNodeItem = nodeItem == find->second.first ? find->second.second : find->second.first;
if (checkSkeletonItem(altNodeItem, true))
m_rangeSelectionSet.insert(altNodeItem);
} else if (item->data(0) == "edge") {
SkeletonGraphicsEdgeItem *edgeItem = (SkeletonGraphicsEdgeItem *)item;
const auto &find = edgeItemMap.find(edgeItem->id());
if (find == edgeItemMap.end()) {
qDebug() << "Edge item map key not found:" << edgeItem->id();
return;
}
checkSkeletonItem(edgeItem, false);
m_rangeSelectionSet.erase(edgeItem);
SkeletonGraphicsEdgeItem *altEdgeItem = edgeItem == find->second.first ? find->second.second : find->second.first;
if (checkSkeletonItem(altEdgeItem, true))
m_rangeSelectionSet.insert(altEdgeItem);
}
}
}
1 change: 1 addition & 0 deletions src/skeletongraphicswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ private slots:
void addItemToRangeSelection(QGraphicsItem *item);
void removeItemFromRangeSelection(QGraphicsItem *item);
void hoverPart(QUuid partId);
void switchProfileOnRangeSelection();
private: //need initalize
const SkeletonDocument *m_document;
QGraphicsPixmapItem *m_backgroundItem;
Expand Down

0 comments on commit 402ee09

Please sign in to comment.