From bfd3fc72684ce196b350a893ea022f2d5e449a8c Mon Sep 17 00:00:00 2001 From: Ryan Kembrey Date: Sun, 23 Nov 2025 18:29:16 +1100 Subject: [PATCH] TechDraw: Implemented View Frame Mode preference --- .../TechDraw/Gui/DlgPrefsTechDrawGeneral.ui | 66 ++++++++++++++----- .../Gui/DlgPrefsTechDrawGeneralImp.cpp | 2 + src/Mod/TechDraw/Gui/QGIView.cpp | 58 ++++++++++++---- src/Mod/TechDraw/Gui/QGIView.h | 1 + 4 files changed, 99 insertions(+), 28 deletions(-) diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui index bd530379d5..8ac2fc573e 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui @@ -189,10 +189,10 @@ for ProjectionGroups - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Preferred + QSizePolicy::Policy::Preferred @@ -220,7 +220,7 @@ for ProjectionGroups Font for labels - QComboBox::AdjustToContents + QComboBox::SizeAdjustPolicy::AdjustToContents @@ -243,7 +243,7 @@ for ProjectionGroups - Qt::Horizontal + Qt::Orientation::Horizontal @@ -303,7 +303,7 @@ for ProjectionGroups - Qt::Horizontal + Qt::Orientation::Horizontal @@ -332,7 +332,7 @@ for ProjectionGroups Use first or third-angle multiview projection convention - QComboBox::AdjustToContents + QComboBox::SizeAdjustPolicy::AdjustToContents ProjectionAngle @@ -423,7 +423,7 @@ for ProjectionGroups - Qt::Horizontal + Qt::Orientation::Horizontal @@ -643,7 +643,7 @@ for ProjectionGroups Diamond - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter NamePattern @@ -693,7 +693,7 @@ for ProjectionGroups - Qt::Horizontal + Qt::Orientation::Horizontal @@ -815,8 +815,8 @@ for ProjectionGroups View Defaults - - + + @@ -868,6 +868,41 @@ for ProjectionGroups + + + + <html><head/><body><p>Control when the view boundary frames and labels are displayed.</p><p>Auto: Show on hover, On: Always show, Off: Never show.</p></body></html> + + + ViewFrameMode + + + Mod/TechDraw/View + + + + Auto + + + + + On + + + + + Off + + + + + + + + View frames mode + + + @@ -884,7 +919,7 @@ for ProjectionGroups - + @@ -929,7 +964,7 @@ for ProjectionGroups When dragging a view, if it is within this fraction of view size of the correct alignment, it will snap into alignment. - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter 0.050000000000000 @@ -945,7 +980,7 @@ for ProjectionGroups - Qt::Horizontal + Qt::Orientation::Horizontal @@ -975,7 +1010,7 @@ for ProjectionGroups Controls the snap radius for highlights. Vertex must be within this factor times the highlight size to be a snap target. - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter 0.600000000000000 @@ -986,7 +1021,6 @@ for ProjectionGroups /Mod/TechDraw/General - diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp index 330b56a251..a734f6a4db 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp @@ -80,6 +80,7 @@ void DlgPrefsTechDrawGeneralImp::saveSettings() ui->cbMultiSelection->onSave(); + ui->cb_viewFramesVisibility->onSave(); ui->cb_useCameraDirection->onSave(); ui->cb_alwaysShowLabel->onSave(); ui->cb_SnapViews->onSave(); @@ -128,6 +129,7 @@ void DlgPrefsTechDrawGeneralImp::loadSettings() ui->cbMultiSelection->setChecked(multiSelectionDefault); ui->cbMultiSelection->onRestore(); + ui->cb_viewFramesVisibility->onRestore(); ui->cb_useCameraDirection->onRestore(); ui->cb_alwaysShowLabel->onRestore(); diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index 19b0574b6d..667904da75 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -112,8 +112,7 @@ QGIView::QGIView() m_lockHeight = (double) sizeLock.height(); m_lock->hide(); - m_border->hide(); - m_label->hide(); + updateFrameVisibility(); } void QGIView::isVisible(bool state) @@ -198,21 +197,18 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) if (change == ItemSelectedHasChanged && scene()) { if (isSelected() || hasSelectedChildren(this)) { m_colCurrent = getSelectColor(); - m_border->show(); - m_label->show(); m_lock->setVisible(getViewObject()->isLocked() && getViewObject()->showLock()); } else { dragFinished(); if (!m_isHovered) { m_colCurrent = PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor()); - m_border->hide(); - m_label->hide(); m_lock->hide(); } else { m_colCurrent = getPreColor(); } } + updateFrameVisibility(); drawBorder(); } @@ -524,8 +520,7 @@ void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event) m_colCurrent = getPreColor(); } - m_border->show(); - m_label->show(); + updateFrameVisibility(); m_lock->setVisible(getViewObject()->isLocked() && getViewObject()->showLock()); @@ -541,16 +536,13 @@ void QGIView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) if (isSelected()) { m_colCurrent = getSelectColor(); - m_border->show(); - m_label->show(); m_lock->setVisible(getViewObject()->isLocked() && getViewObject()->showLock()); } else { m_colCurrent = PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor()); - m_border->hide(); - m_label->hide(); m_lock->hide(); } + updateFrameVisibility(); drawBorder(); } @@ -603,6 +595,7 @@ void QGIView::updateView(bool forceUpdate) rotateView(); } + updateFrameVisibility(); drawBorder(); QGIView::draw(); @@ -1074,6 +1067,47 @@ void QGIView::makeMark(QPointF pos, QColor color) makeMark(pos.x(), pos.y(), color); } +void QGIView::updateFrameVisibility() +{ + // Get the preference group + auto hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/View"); + + // 0 = Auto (Default), 1 = Always On, 2 = Always Off + int frameMode = hGrp->GetInt("ViewFrameMode", 0); + + bool shouldShow = false; + + if (isSelected()) { + shouldShow = true; + } + else { + if (frameMode == 1) { + // Always On + shouldShow = true; + } + else if (frameMode == 2) { + // Always Off + shouldShow = false; + } + else { + // Auto (Default) + shouldShow = m_isHovered; + } + } + + if (shouldShow) { + m_border->show(); + m_label->show(); + if (m_lock && getViewObject()) { + m_lock->setVisible(getViewObject()->isLocked() && getViewObject()->showLock()); + } + } else { + m_border->hide(); + m_label->hide(); + if (m_lock) m_lock->hide(); + } +} //! Retrieves objects of type T with given indexes template diff --git a/src/Mod/TechDraw/Gui/QGIView.h b/src/Mod/TechDraw/Gui/QGIView.h index 0a77c5f88b..7156d9a217 100644 --- a/src/Mod/TechDraw/Gui/QGIView.h +++ b/src/Mod/TechDraw/Gui/QGIView.h @@ -190,6 +190,7 @@ protected: void dumpRect(const char* text, QRectF rect); bool m_isHovered; + void updateFrameVisibility(); Base::Reference getParmGroupCol();