From ac8c0e417574e4a540c4466186d3bb86f6806db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sat, 19 Dec 2020 15:04:48 +0100 Subject: [PATCH] Add Setting for Minimum Font Size in Graphs (#2524) --- src/common/Configuration.h | 10 +++++++ .../preferences/GraphOptionsWidget.cpp | 11 ++++++- src/dialogs/preferences/GraphOptionsWidget.h | 1 + src/dialogs/preferences/GraphOptionsWidget.ui | 29 +++++++++++++++++-- src/widgets/DisassemblerGraphView.cpp | 2 +- src/widgets/SimpleTextGraphView.cpp | 2 +- 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/common/Configuration.h b/src/common/Configuration.h index ef2ca66a..513533a3 100644 --- a/src/common/Configuration.h +++ b/src/common/Configuration.h @@ -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. */ diff --git a/src/dialogs/preferences/GraphOptionsWidget.cpp b/src/dialogs/preferences/GraphOptionsWidget.cpp index d239bfba..9d07a845 100644 --- a/src/dialogs/preferences/GraphOptionsWidget.cpp +++ b/src/dialogs/preferences/GraphOptionsWidget.cpp @@ -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); @@ -95,4 +104,4 @@ void GraphOptionsWidget::checkGraphBlockEntryOffsetChanged(bool checked) { Config()->setGraphBlockEntryOffset(checked); triggerOptionsChanged(); -} \ No newline at end of file +} diff --git a/src/dialogs/preferences/GraphOptionsWidget.h b/src/dialogs/preferences/GraphOptionsWidget.h index f7b069d5..300f915e 100644 --- a/src/dialogs/preferences/GraphOptionsWidget.h +++ b/src/dialogs/preferences/GraphOptionsWidget.h @@ -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); diff --git a/src/dialogs/preferences/GraphOptionsWidget.ui b/src/dialogs/preferences/GraphOptionsWidget.ui index 5fb50977..d4fbca05 100644 --- a/src/dialogs/preferences/GraphOptionsWidget.ui +++ b/src/dialogs/preferences/GraphOptionsWidget.ui @@ -43,15 +43,15 @@ - - + + Maximum Line Length: - + 25 @@ -64,6 +64,29 @@ + + + + Hide text when zooming out and it is smaller than the given value. Higher values can increase Performance. + + + Minimum Font Size + + + + + + + Hide text when zooming out and it is smaller than the given value. Higher values can increase Performance. + + + 8 + + + 4 + + + diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index b923609c..9c40a601 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -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; } diff --git a/src/widgets/SimpleTextGraphView.cpp b/src/widgets/SimpleTextGraphView.cpp index 11f95515..955e7e29 100644 --- a/src/widgets/SimpleTextGraphView.cpp +++ b/src/widgets/SimpleTextGraphView.cpp @@ -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; }