forked from Ivasoft/DSView
The measure information pannel adaptives font size
This commit is contained in:
@@ -705,7 +705,7 @@ void MeasureDock::update_probe_selector(QComboBox *selector)
|
|||||||
|
|
||||||
void MeasureDock::adjusLabelSize()
|
void MeasureDock::adjusLabelSize()
|
||||||
{
|
{
|
||||||
ui::adjust_form_size(this);
|
this->adjust_form_size(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeasureDock::cursor_moving()
|
void MeasureDock::cursor_moving()
|
||||||
@@ -850,5 +850,37 @@ void MeasureDock::update_font()
|
|||||||
adjusLabelSize();
|
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 dock
|
||||||
} // namespace pv
|
} // namespace pv
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ private:
|
|||||||
QComboBox* create_probe_selector(QWidget *parent);
|
QComboBox* create_probe_selector(QWidget *parent);
|
||||||
void update_probe_selector(QComboBox *selector);
|
void update_probe_selector(QComboBox *selector);
|
||||||
void adjusLabelSize();
|
void adjusLabelSize();
|
||||||
|
void adjust_form_size(QWidget *wid);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void goto_cursor();
|
void goto_cursor();
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace ui
|
|||||||
{
|
{
|
||||||
QSize size = o->sizeHint();
|
QSize size = o->sizeHint();
|
||||||
size.setWidth(size.width() + 5);
|
size.setWidth(size.width() + 5);
|
||||||
o->setFixedSize(size);
|
o->setFixedWidth(size.width());
|
||||||
}
|
}
|
||||||
|
|
||||||
int groupMaxWith = 0;
|
int groupMaxWith = 0;
|
||||||
|
|||||||
@@ -413,19 +413,19 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "IDS_DLG_W",
|
"id": "IDS_DLG_W",
|
||||||
"text": "W: "
|
"text": "宽度: "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "IDS_DLG_P",
|
"id": "IDS_DLG_P",
|
||||||
"text": "P: "
|
"text": "周期: "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "IDS_DLG_F",
|
"id": "IDS_DLG_F",
|
||||||
"text": "F: "
|
"text": "频率: "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "IDS_DLG_D",
|
"id": "IDS_DLG_D",
|
||||||
"text": "D: "
|
"text": "占空比: "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "IDS_DLG_SEARCH",
|
"id": "IDS_DLG_SEARCH",
|
||||||
|
|||||||
Reference in New Issue
Block a user