From b6b5e67fad064e20c8031064c164d0e5eac0b536 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sat, 19 Oct 2019 10:01:27 +0930 Subject: [PATCH] Change key H behaviour Before: only toggle hovered part's visibility After: when there is no part been hovered, all nodes will be toggled --- src/document.cpp | 14 ++++++++++++++ src/document.h | 1 + src/documentwindow.cpp | 2 ++ src/parttreewidget.h | 1 + src/skeletongraphicswidget.cpp | 14 +++++++++----- src/skeletongraphicswidget.h | 1 + 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index ee0dbed6..20105ad8 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -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) { diff --git a/src/document.h b/src/document.h index a0768dbf..ca571602 100644 --- a/src/document.h +++ b/src/document.h @@ -640,6 +640,7 @@ public slots: void lockOtherComponents(QUuid componentId); void hideAllComponents(); void showAllComponents(); + void showOrHideAllComponents(); void collapseAllComponents(); void expandAllComponents(); void lockAllComponents(); diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index 689c902c..6b7f7475 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -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); diff --git a/src/parttreewidget.h b/src/parttreewidget.h index 3c144f9e..e35d0b56 100644 --- a/src/parttreewidget.h +++ b/src/parttreewidget.h @@ -29,6 +29,7 @@ signals: void lockOtherComponents(QUuid componentId); void hideAllComponents(); void showAllComponents(); + void showOrHideAllComponents(); void collapseAllComponents(); void expandAllComponents(); void lockAllComponents(); diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index 77430029..ed2d4f37 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -1704,11 +1704,15 @@ void SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected() void SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); - bool partVisible = part && part->visible; - emit setPartVisibleState(m_lastCheckedPart, !partVisible); - emit groupOperationAdded(); + 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(); + } } } diff --git a/src/skeletongraphicswidget.h b/src/skeletongraphicswidget.h index 9fb2535e..92edb176 100644 --- a/src/skeletongraphicswidget.h +++ b/src/skeletongraphicswidget.h @@ -415,6 +415,7 @@ signals: void disableAllPositionRelatedLocks(); void shortcutToggleWireframe(); void partComponentChecked(QUuid partId); + void showOrHideAllComponents(); public: SkeletonGraphicsWidget(const SkeletonDocument *document); std::map> nodeItemMap;