Add Setting for Minimum Font Size in Graphs (#2524)

This commit is contained in:
Florian Märkl 2020-12-19 15:04:48 +01:00 committed by GitHub
parent c985fdc1b1
commit ac8c0e4175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 6 deletions

View File

@ -173,6 +173,16 @@ public:
s.setValue("graph.maxcols", ch);
}
int getGraphMinFontSize() const
{
return s.value("graph.minfontsize", 4).toInt();
}
void setGraphMinFontSize(int sz)
{
s.setValue("graph.minfontsize", sz);
}
/**
* @brief Getters and setters for the transaparent option state and scale factor for bitmap graph exports.
*/

View File

@ -43,6 +43,9 @@ void GraphOptionsWidget::updateOptionsFromVars()
ui->maxColsSpinBox->blockSignals(true);
ui->maxColsSpinBox->setValue(Config()->getGraphBlockMaxChars());
ui->maxColsSpinBox->blockSignals(false);
ui->minFontSizeSpinBox->blockSignals(true);
ui->minFontSizeSpinBox->setValue(Config()->getGraphMinFontSize());
ui->minFontSizeSpinBox->blockSignals(false);
auto blockSpacing = Config()->getGraphBlockSpacing();
ui->horizontalBlockSpacing->setValue(blockSpacing.x());
ui->verticalBlockSpacing->setValue(blockSpacing.y());
@ -65,6 +68,12 @@ void GraphOptionsWidget::on_maxColsSpinBox_valueChanged(int value)
triggerOptionsChanged();
}
void GraphOptionsWidget::on_minFontSizeSpinBox_valueChanged(int value)
{
Config()->setGraphMinFontSize(value);
triggerOptionsChanged();
}
void GraphOptionsWidget::on_graphOffsetCheckBox_toggled(bool checked)
{
Config()->setConfig("graph.offset", checked);

View File

@ -30,6 +30,7 @@ private slots:
void updateOptionsFromVars();
void on_maxColsSpinBox_valueChanged(int value);
void on_minFontSizeSpinBox_valueChanged(int value);
void on_graphOffsetCheckBox_toggled(bool checked);
void checkTransparentStateChanged(int checked);

View File

@ -43,15 +43,15 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="maxColsLabel">
<property name="text">
<string>Maximum Line Length:</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QSpinBox" name="maxColsSpinBox">
<property name="minimum">
<number>25</number>
@ -64,6 +64,29 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="minFontSizeLabel">
<property name="toolTip">
<string>Hide text when zooming out and it is smaller than the given value. Higher values can increase Performance.</string>
</property>
<property name="text">
<string>Minimum Font Size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="minFontSizeSpinBox">
<property name="toolTip">
<string>Hide text when zooming out and it is smaller than the given value. Higher values can increase Performance.</string>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -413,7 +413,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block,
auto transform = p.combinedTransform();
QRect screenChar = transform.mapRect(QRect(0, 0, charWidth, charHeight));
if (screenChar.width() * qhelpers::devicePixelRatio(p.device()) < 4) {
if (screenChar.width() < Config()->getGraphMinFontSize()) {
return;
}

View File

@ -114,7 +114,7 @@ void SimpleTextGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block, b
auto transform = p.combinedTransform();
QRect screenChar = transform.mapRect(QRect(0, 0, charWidth, charHeight));
if (screenChar.width() * qhelpers::devicePixelRatio(p.device()) < 4) {
if (screenChar.width() < Config()->getGraphMinFontSize()) {
return;
}