Skip to content

Commit

Permalink
Allow configuration of fractional font sizes (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl authored Jan 28, 2023
1 parent 8673a1e commit ba0b981
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 32 deletions.
12 changes: 3 additions & 9 deletions data/ui/options.ui
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,12 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxFontSize">
<widget class="QDoubleSpinBox" name="doubleSpinBoxFontSize">
<property name="suffix">
<string>pt</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>120</number>
</property>
<property name="value">
<number>10</number>
<double>1.000000000000000</double>
</property>
</widget>
</item>
Expand Down Expand Up @@ -282,7 +276,7 @@
<x>0</x>
<y>0</y>
<width>762</width>
<height>397</height>
<height>466</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
Expand Down
8 changes: 4 additions & 4 deletions src/urh/controller/dialogs/OptionsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __init__(self, installed_plugins, highlighted_plugins=None, parent=None):
completer.setModel(QDirModel(completer))
self.ui.lineEditGRPythonInterpreter.setCompleter(completer)

self.ui.spinBoxFontSize.setValue(qApp.font().pointSize())
self.ui.doubleSpinBoxFontSize.setValue(qApp.font().pointSizeF())

self.refresh_device_tab()

Expand Down Expand Up @@ -242,7 +242,7 @@ def create_connects(self):
self.ui.checkBoxMultipleModulations.clicked.connect(self.on_checkbox_multiple_modulations_clicked)
self.ui.btnViewBuildLog.clicked.connect(self.on_btn_view_build_log_clicked)
self.ui.labelDeviceMissingInfo.linkActivated.connect(self.on_label_device_missing_info_link_activated)
self.ui.spinBoxFontSize.editingFinished.connect(self.on_spin_box_font_size_editing_finished)
self.ui.doubleSpinBoxFontSize.editingFinished.connect(self.on_spin_box_font_size_editing_finished)

def show_gnuradio_infos(self):
self.ui.lineEditGRPythonInterpreter.setText(self.backend_handler.gr_python_interpreter)
Expand Down Expand Up @@ -468,9 +468,9 @@ def on_label_device_missing_info_link_activated(self, link: str):

@pyqtSlot()
def on_spin_box_font_size_editing_finished(self):
settings.write("font_size", self.ui.spinBoxFontSize.value())
settings.write("font_size", self.ui.doubleSpinBoxFontSize.value())
font = qApp.font()
font.setPointSize(self.ui.spinBoxFontSize.value())
font.setPointSizeF(self.ui.doubleSpinBoxFontSize.value())
qApp.setFont(font)

@pyqtSlot(bool)
Expand Down
4 changes: 2 additions & 2 deletions src/urh/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def main():

util.set_icon_theme()

font_size = settings.read("font_size", 0, int)
font_size = settings.read("font_size", 0, float)
if font_size > 0:
font = app.font()
font.setPointSize(font_size)
font.setPointSizeF(font_size)
app.setFont(font)

settings.write("default_theme", app.style().objectName())
Expand Down
2 changes: 1 addition & 1 deletion src/urh/ui/painting/GridScene.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def draw_frequency_marker(self, x_pos, frequency):
self.frequency_marker[1].setBrush(QBrush(settings.LINECOLOR))
font = QFont()
font.setBold(True)
font.setPointSize(int(font.pointSize() * 1.25)+1)
font.setPointSizeF(font.pointSizeF() * 1.25 + 1)
self.frequency_marker[1].setFont(font)

self.frequency_marker[0].setLine(x_pos, y1, x_pos, y2)
Expand Down
17 changes: 8 additions & 9 deletions src/urh/ui/ui_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
Expand Down Expand Up @@ -94,12 +95,10 @@ def setupUi(self, DialogOptions):
self.labelFontSize = QtWidgets.QLabel(self.tabView)
self.labelFontSize.setObjectName("labelFontSize")
self.horizontalLayout.addWidget(self.labelFontSize)
self.spinBoxFontSize = QtWidgets.QSpinBox(self.tabView)
self.spinBoxFontSize.setMinimum(1)
self.spinBoxFontSize.setMaximum(120)
self.spinBoxFontSize.setProperty("value", 10)
self.spinBoxFontSize.setObjectName("spinBoxFontSize")
self.horizontalLayout.addWidget(self.spinBoxFontSize)
self.doubleSpinBoxFontSize = QtWidgets.QDoubleSpinBox(self.tabView)
self.doubleSpinBoxFontSize.setMinimum(1.0)
self.doubleSpinBoxFontSize.setObjectName("doubleSpinBoxFontSize")
self.horizontalLayout.addWidget(self.doubleSpinBoxFontSize)
self.verticalLayout.addLayout(self.horizontalLayout)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
Expand Down Expand Up @@ -132,7 +131,7 @@ def setupUi(self, DialogOptions):
self.scrollAreaSpectrogramColormap.setWidgetResizable(True)
self.scrollAreaSpectrogramColormap.setObjectName("scrollAreaSpectrogramColormap")
self.scrollAreaWidgetSpectrogramColormapContents = QtWidgets.QWidget()
self.scrollAreaWidgetSpectrogramColormapContents.setGeometry(QtCore.QRect(0, 0, 762, 397))
self.scrollAreaWidgetSpectrogramColormapContents.setGeometry(QtCore.QRect(0, 0, 762, 466))
self.scrollAreaWidgetSpectrogramColormapContents.setObjectName("scrollAreaWidgetSpectrogramColormapContents")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetSpectrogramColormapContents)
self.verticalLayout_4.setObjectName("verticalLayout_4")
Expand Down Expand Up @@ -311,7 +310,7 @@ def retranslateUi(self, DialogOptions):
self.checkBoxPauseTime.setText(_translate("DialogOptions", "Show pauses as time"))
self.checkBoxAlignLabels.setText(_translate("DialogOptions", "Align on labels"))
self.labelFontSize.setText(_translate("DialogOptions", "<html><head/><body><p>Application font size (<span style=\" font-weight:600;\">restart</span> for full effect):</p></body></html>"))
self.spinBoxFontSize.setSuffix(_translate("DialogOptions", "pt"))
self.doubleSpinBoxFontSize.setSuffix(_translate("DialogOptions", "pt"))
self.label_9.setText(_translate("DialogOptions", "Choose application theme (requires restart):"))
self.comboBoxTheme.setItemText(0, _translate("DialogOptions", "native look (default)"))
self.comboBoxTheme.setItemText(1, _translate("DialogOptions", "fallback theme"))
Expand Down
12 changes: 6 additions & 6 deletions src/urh/ui/views/TableView.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ def _add_insert_column_menu(self, menu):
def selectionModel(self) -> QItemSelectionModel:
return super().selectionModel()

def set_font_size(self, n: int):
def set_font_size(self, n: float):
if n < 1:
return
font = self.font()

if n <= self.original_font_size:
font.setPointSize(n)
font.setPointSizeF(n)
self.setFont(font)

if n <= self.original_header_font_sizes["horizontal"]:
hheader_font = self.horizontalHeader().font()
hheader_font.setPointSize(n)
hheader_font.setPointSizeF(n)
self.horizontalHeader().setFont(hheader_font)

if n <= self.original_header_font_sizes["vertical"]:
vheader_font = self.verticalHeader().font()
vheader_font.setPointSize(n)
vheader_font.setPointSizeF(n)
self.verticalHeader().setFont(vheader_font)

self.resize_columns()
Expand All @@ -95,11 +95,11 @@ def selected_rows(self):

@pyqtSlot()
def on_zoom_in_action_triggered(self):
self.set_font_size(self.font().pointSize() + 1)
self.set_font_size(self.font().pointSizeF() + 1)

@pyqtSlot()
def on_zoom_out_action_triggered(self):
self.set_font_size(self.font().pointSize() - 1)
self.set_font_size(self.font().pointSizeF() - 1)

@pyqtSlot()
def on_zoom_original_action_triggered(self):
Expand Down
2 changes: 1 addition & 1 deletion src/urh/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def write_xml_to_file(xml_tag: ET.Element, filename: str):

def get_monospace_font() -> QFont:
fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
fixed_font.setPointSize(QApplication.instance().font().pointSize())
fixed_font.setPointSizeF(QApplication.instance().font().pointSizeF())
return fixed_font


Expand Down

0 comments on commit ba0b981

Please sign in to comment.