From 198f40e0df4cad58eadc9861278f20fc04cb7cf0 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Fri, 29 Mar 2024 20:25:53 +0800 Subject: [PATCH] fix: When using font sizes, the cursor information on the measurement panel may not be fully displayed --- DSView/pv/dock/measuredock.cpp | 12 +++++++++++ DSView/pv/dock/measuredock.h | 1 + DSView/pv/ui/fn.cpp | 37 ++++++++++++++++++++++++++++++++++ DSView/pv/ui/fn.h | 2 ++ 4 files changed, 52 insertions(+) diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/pv/dock/measuredock.cpp index e1b2841c..66e330fc 100644 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/pv/dock/measuredock.cpp @@ -235,6 +235,7 @@ void MeasureDock::measure_updated() _period_label->setText(_view.get_measure("period")); _freq_label->setText(_view.get_measure("frequency")); _duty_label->setText(_view.get_measure("duty")); + adjusLabelSize(); } void MeasureDock::build_dist_pannel() @@ -702,6 +703,11 @@ void MeasureDock::update_probe_selector(QComboBox *selector) } } +void MeasureDock::adjusLabelSize() +{ + ui::adjust_form_size(this); +} + void MeasureDock::cursor_moving() { if (_view.cursors_shown()) { @@ -729,6 +735,8 @@ void MeasureDock::reCalc() cursor_update(); update_dist(); update_edge(); + + adjusLabelSize(); } void MeasureDock::goto_cursor() @@ -802,6 +810,8 @@ void MeasureDock::cursor_update() index++; cursor_dex++; } + + adjusLabelSize(); } void MeasureDock::del_cursor() @@ -836,6 +846,8 @@ void MeasureDock::update_font() ui::set_form_font(this, font); font.setPointSizeF(font.pointSizeF() + 1); this->parentWidget()->setFont(font); + + adjusLabelSize(); } } // namespace dock diff --git a/DSView/pv/dock/measuredock.h b/DSView/pv/dock/measuredock.h index 55d559f4..139044a8 100644 --- a/DSView/pv/dock/measuredock.h +++ b/DSView/pv/dock/measuredock.h @@ -100,6 +100,7 @@ private: private: QComboBox* create_probe_selector(QWidget *parent); void update_probe_selector(QComboBox *selector); + void adjusLabelSize(); private slots: void goto_cursor(); diff --git a/DSView/pv/ui/fn.cpp b/DSView/pv/ui/fn.cpp index 66fdc207..1748d776 100644 --- a/DSView/pv/ui/fn.cpp +++ b/DSView/pv/ui/fn.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "../config/appconfig.h" #include "../ui/xtoolbutton.h" @@ -146,4 +147,40 @@ namespace ui } } + void adjust_form_size(QWidget *wid) + { + assert(wid); + + auto labels = wid->findChildren(); + for(auto o : labels) + { + QSize size = o->sizeHint(); + size.setWidth(size.width() + 5); + o->setFixedSize(size); + } + + int groupMaxWith = 0; + + auto groups = wid->findChildren(); + for(auto o : groups) + { + QSize size = o->sizeHint(); + int w = size.width() + 5; + if (w > groupMaxWith){ + groupMaxWith = w; + } + } + + auto groups2 = wid->findChildren(); + for(auto o : groups2) + { + o->setFixedWidth(groupMaxWith); + + QWidget *parent = dynamic_cast(o->parent()); + if (parent != NULL){ + parent->setFixedWidth(groupMaxWith + 10); + } + } + } + } // namespace ui \ No newline at end of file diff --git a/DSView/pv/ui/fn.h b/DSView/pv/ui/fn.h index 68458902..dc936604 100644 --- a/DSView/pv/ui/fn.h +++ b/DSView/pv/ui/fn.h @@ -37,6 +37,8 @@ namespace ui void set_form_font(QWidget *wid, QFont font); + void adjust_form_size(QWidget *wid); + } // namespace ui #endif \ No newline at end of file