The measure information pannel adaptives font size

This commit is contained in:
dreamsourcelabTAI 2024-04-02 10:16:27 +08:00
parent 35ccb21ae6
commit e19138b50f
4 changed files with 39 additions and 6 deletions

View File

@ -705,7 +705,7 @@ void MeasureDock::update_probe_selector(QComboBox *selector)
void MeasureDock::adjusLabelSize()
{
ui::adjust_form_size(this);
this->adjust_form_size(this);
}
void MeasureDock::cursor_moving()
@ -850,5 +850,37 @@ void MeasureDock::update_font()
adjusLabelSize();
}
void MeasureDock::adjust_form_size(QWidget *wid)
{
assert(wid);
QGroupBox *mainGroup = _dist_groupBox;
QString str = "+12345678999ms/12345678999";
QFont font = this->font();
font.setPointSizeF(AppConfig::Instance().appOptions.fontSize);
QFontMetrics fm(font);
int max_label_width = fm.horizontalAdvance(str) + 100;
auto labels = wid->findChildren<QLabel*>();
for(auto o : labels)
{
QRect rc = fm.boundingRect(o->text());
QSize size(rc.width() + 10, rc.height());
o->setFixedSize(size);
}
auto groups = wid->findChildren<QGroupBox*>();
for(auto o : groups)
{
o->setFixedWidth(max_label_width + 10);
}
QWidget *pannel = dynamic_cast<QWidget*>(mainGroup->parent());
if (pannel != NULL){
pannel->setFixedWidth(max_label_width + 20);
}
}
} // namespace dock
} // namespace pv

View File

@ -101,6 +101,7 @@ private:
QComboBox* create_probe_selector(QWidget *parent);
void update_probe_selector(QComboBox *selector);
void adjusLabelSize();
void adjust_form_size(QWidget *wid);
private slots:
void goto_cursor();

View File

@ -156,7 +156,7 @@ namespace ui
{
QSize size = o->sizeHint();
size.setWidth(size.width() + 5);
o->setFixedSize(size);
o->setFixedWidth(size.width());
}
int groupMaxWith = 0;

View File

@ -413,19 +413,19 @@
},
{
"id": "IDS_DLG_W",
"text": "W: "
"text": "宽度: "
},
{
"id": "IDS_DLG_P",
"text": "P: "
"text": "周期: "
},
{
"id": "IDS_DLG_F",
"text": "F: "
"text": "频率: "
},
{
"id": "IDS_DLG_D",
"text": "D: "
"text": "占空比: "
},
{
"id": "IDS_DLG_SEARCH",