- in Preferences, added a control in the General -> GUI Settings to control the font size for the entire application; require an app restart

This commit is contained in:
Marius Stanciu
2023-06-05 18:46:06 +03:00
parent bc1fa4ca94
commit 5708791acc
4 changed files with 51 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ CHANGELOG for FlatCAM Evo beta
- updated the FCButton and FCLabel custom widgets
- Paint Plugin: fixed issues caused by the latest changes in the Shapely module
- NCC Plugin: some changes in the method used by the Tcl Command
- in Preferences, added a control in the General -> GUI Settings to control the font size for the entire application; require an app restart
31.05.2023

View File

@@ -3,8 +3,9 @@ from PyQt6 import QtWidgets, QtCore, QtGui
from PyQt6.QtCore import QSettings
from appGUI.GUIElements import RadioSet, FCCheckBox, FCComboBox, FCSliderWithSpinner, FCColorEntry, FCLabel, \
GLay, FCFrame, FCComboBox2
GLay, FCFrame, FCComboBox2, FCButton, FCSpinner
from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
from appTranslation import restart_program
import gettext
import appTranslation as fcTranslate
@@ -159,6 +160,24 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
grid0.addWidget(self.ui_lay_lbl, 14, 0)
grid0.addWidget(self.gui_lay_combo, 14, 1, 1, 2)
# Font Size
self.font_size_lbl = FCLabel('%s:' % _("Font Size"))
self.font_size_lbl.setToolTip(
_("Setting the Font Size for the entire application.")
)
self.app_font_size_entry = FCSpinner()
self.app_font_size_entry.set_range(9, 18)
grid0.addWidget(self.font_size_lbl, 16, 0)
grid0.addWidget(self.app_font_size_entry, 16, 1)
# Apply UI parameters
self.apply_app_font_size_btn = FCButton(_("Apply and Restart"), bold=True)
self.apply_app_font_size_btn.setToolTip(
_("Setting the Font Size for the entire application.")
)
grid0.addWidget(self.apply_app_font_size_btn, 18, 0, 1, 2)
# #############################################################################################################
# Grid1 Frame
# #############################################################################################################
@@ -391,6 +410,24 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
self.layout_combo.activated.connect(self.app.on_layout)
self.apply_app_font_size_btn.clicked.connect(
lambda: self.handle_font_size(self.app, self.app_font_size_entry.get_value()))
# Set UI
qsettings = QSettings("Open Source", "FlatCAM_EVO")
if qsettings.contains("font_size"):
font_size = int(qsettings.value("font_size", type=str)) # noqa
self.app_font_size_entry.set_value(font_size)
@staticmethod
def handle_font_size(app, val):
settings = QSettings("Open Source", "FlatCAM_EVO")
settings.setValue('font_size', str(val))
# This will write the setting to the platform specific storage.
del settings
restart_program(app=app)
@staticmethod
def handle_style(style):
# set current style

View File

@@ -5,7 +5,8 @@
# MIT Licence #
# ##########################################################
import os, ctypes
import os
import ctypes
import sys
import logging
from pathlib import Path
@@ -152,8 +153,7 @@ def apply_language(domain, lang=None):
# This will write the setting to the platform specific storage.
del settings
else:
# TODO if lang is None we make a string from it?
name = str(lang)
name = str(lang) # we make it a string: "None"
for lang_code, lang_usable in load_languages().items():
if lang_usable == name:
@@ -239,10 +239,10 @@ def restart_program(app, ask=None):
try:
python = sys.executable
os.execl(python, python, *sys.argv)
except Exception as err:
except Exception:
# app_run_as_admin = isAdmin()
msgbox = FCMessageBox(parent=app.ui)
title = _("The language will be applied at the next application start.")
title = _("The setting will be applied at the next application start.")
txt = _("The user does not have admin rights or UAC issues.")
msgbox.setWindowTitle('%s ...' % _("Quit")) # taskbar still shows it
msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/app128.png'))
@@ -256,7 +256,7 @@ def restart_program(app, ask=None):
msgbox.exec()
# TODO Due of some circular imports issues which I currently can't fix I readd this class here
# TODO Due of some circular imports issues which I currently can't fix I re-add this class here
# (mainly is located in appGUI.GUIElements) - required for a consistent look
class FCMessageBox(QtWidgets.QMessageBox):
"""

View File

@@ -167,6 +167,12 @@ if __name__ == '__main__':
else:
app.setStyle('windowsvista')
if settings.contains("font_size"):
font_size = int(settings.value("font_size", type=str)) # noqa
font = QtGui.QFont()
font.setPointSize(font_size)
app.setFont(font)
fc = App(qapp=app)
# interrupt the Qt loop such that Python events have a chance to be responsive