Change key H behaviour

Before: only toggle hovered part's visibility
After: when there is no part been hovered, all nodes will be toggled
master
Jeremy Hu 2019-10-19 10:01:27 +09:30
parent c7ba9ef1a9
commit b6b5e67fad
6 changed files with 28 additions and 5 deletions

View File

@ -3058,6 +3058,20 @@ void Document::showAllComponents()
}
}
void Document::showOrHideAllComponents()
{
bool foundVisiblePart = false;
for (const auto &part: partMap) {
if (part.second.visible) {
foundVisiblePart = true;
}
}
if (foundVisiblePart)
hideAllComponents();
else
showAllComponents();
}
void Document::collapseAllComponents()
{
for (const auto &component: componentMap) {

View File

@ -640,6 +640,7 @@ public slots:
void lockOtherComponents(QUuid componentId);
void hideAllComponents();
void showAllComponents();
void showOrHideAllComponents();
void collapseAllComponents();
void expandAllComponents();
void lockAllComponents();

View File

@ -901,6 +901,8 @@ DocumentWindow::DocumentWindow() :
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &DocumentWindow::open);
connect(graphicsWidget, &SkeletonGraphicsWidget::showCutFaceSettingPopup, this, &DocumentWindow::showCutFaceSettingPopup);
connect(graphicsWidget, &SkeletonGraphicsWidget::showOrHideAllComponents, m_document, &Document::showOrHideAllComponents);
connect(m_document, &Document::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded);
connect(m_document, &Document::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved);
connect(m_document, &Document::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded);

View File

@ -29,6 +29,7 @@ signals:
void lockOtherComponents(QUuid componentId);
void hideAllComponents();
void showAllComponents();
void showOrHideAllComponents();
void collapseAllComponents();
void expandAllComponents();
void lockAllComponents();

View File

@ -1704,11 +1704,15 @@ void SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected()
void SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart()
{
if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) {
if (SkeletonDocumentEditMode::Select == m_document->editMode) {
if (!m_lastCheckedPart.isNull()) {
const SkeletonPart *part = m_document->findPart(m_lastCheckedPart);
bool partVisible = part && part->visible;
emit setPartVisibleState(m_lastCheckedPart, !partVisible);
emit groupOperationAdded();
} else {
emit showOrHideAllComponents();
}
}
}

View File

@ -415,6 +415,7 @@ signals:
void disableAllPositionRelatedLocks();
void shortcutToggleWireframe();
void partComponentChecked(QUuid partId);
void showOrHideAllComponents();
public:
SkeletonGraphicsWidget(const SkeletonDocument *document);
std::map<QUuid, std::pair<SkeletonGraphicsNodeItem *, SkeletonGraphicsNodeItem *>> nodeItemMap;