- multiple UI changes in Preferences

- UI changes in the Paint Plugin
This commit is contained in:
Marius Stanciu
2021-09-25 21:08:15 +03:00
committed by Marius
parent 0fa01e760a
commit 08d3a580ac
42 changed files with 762 additions and 628 deletions

View File

@@ -1,10 +1,9 @@
import sys
from PyQt6 import QtWidgets
from PyQt6.QtCore import QSettings
from appGUI.GUIElements import RadioSet, FCSpinner, FCCheckBox, FCComboBox, FCButton, OptionalInputSection, \
FCDoubleSpinner, FCLabel, FCGridLayout, RadioSetDefaults
FCDoubleSpinner, FCLabel, FCGridLayout, RadioSetDefaults, FCFrame
from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
@@ -16,6 +15,8 @@ if '_' not in builtins.__dict__:
_ = gettext.gettext
# https://www.w3schools.com/colors/colors_names.asp
# Colors names
class GeneralAppPrefGroupUI(OptionsGroupUI):
def __init__(self, defaults, decimals=4, parent=None):
super(GeneralAppPrefGroupUI, self).__init__(self, parent=parent)
@@ -24,21 +25,28 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
self.decimals = decimals
self.defaults = defaults
# Create a form layout for the Application general settings
grid0 = FCGridLayout(v_spacing=5, h_spacing=3)
self.layout.addLayout(grid0)
# Units for FlatCAM
self.unitslabel = FCLabel('<span style="color:red;"><b>%s:</b></span>' % _('Units'))
# #############################################################################################################
# Grid0 Frame
# #############################################################################################################
self.unitslabel = FCLabel('<span style="color:red;"><b>%s</b></span>' % _('Units'))
self.unitslabel.setToolTip(_("The default value for the application units.\n"
"Whatever is selected here is set every time\n"
"FlatCAM is started."))
self.layout.addWidget(self.unitslabel)
grid0_frame = FCFrame()
self.layout.addWidget(grid0_frame)
grid0 = FCGridLayout(v_spacing=5, h_spacing=3)
grid0_frame.setLayout(grid0)
# Units for FlatCAM
self.units_radio = RadioSetDefaults(
choices=[{'label': _('MM'), 'value': 'MM'}, {'label': _('IN'), 'value': 'IN'}]
choices=[{'label': _('mm'), 'value': 'MM'}, {'label': _('inch'), 'value': 'IN'}],
compact=True
)
grid0.addWidget(self.unitslabel, 0, 0)
grid0.addWidget(self.units_radio, 0, 1)
grid0.addWidget(self.units_radio, 0, 0, 1, 2)
# Precision Metric
self.precision_metric_label = FCLabel('%s:' % _('Precision MM'))
@@ -68,6 +76,18 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
grid0.addWidget(self.precision_inch_label, 4, 0)
grid0.addWidget(self.precision_inch_entry, 4, 1)
self.par_label = FCLabel('<span style="color:blue;"><b>%s</b></span>' % _("Parameters"))
self.layout.addWidget(self.par_label)
# #############################################################################################################
# Parameters
# #############################################################################################################
grid1_frame = FCFrame()
self.layout.addWidget(grid1_frame)
grid1 = FCGridLayout(v_spacing=5, h_spacing=3)
grid1_frame.setLayout(grid1)
# Graphic Engine for FlatCAM
self.ge_label = FCLabel('<b>%s:</b>' % _('Graphic Engine'))
self.ge_label.setToolTip(_("Choose what graphic engine to use in FlatCAM.\n"
@@ -76,141 +96,16 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
"Some graphic cards are too old and do not work in OpenGL(3D) mode, like:\n"
"Intel HD3000 or older. In this case the plot area will be black therefore\n"
"use the Legacy(2D) mode."))
self.ge_radio = RadioSet([{'label': _('Legacy(2D)'), 'value': '2D'},
{'label': _('OpenGL(3D)'), 'value': '3D'}],
orientation='vertical')
self.ge_radio = RadioSet([{'label': _('2D'), 'value': '2D'},
{'label': _('3D'), 'value': '3D'}], compact=True)
grid0.addWidget(self.ge_label, 6, 0)
grid0.addWidget(self.ge_radio, 6, 1)
grid1.addWidget(self.ge_label, 0, 0)
grid1.addWidget(self.ge_radio, 0, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 8, 0, 1, 2)
# Application Level for FlatCAM
self.app_level_label = FCLabel('<span style="color:red;"><b>%s:</b></span>' % _('APPLICATION LEVEL'))
self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
"BASIC level -> reduced functionality, best for beginner's.\n"
"ADVANCED level -> full functionality.\n\n"
"The choice here will influence the parameters in\n"
"the Selected Tab for all kinds of FlatCAM objects."))
grid0.addWidget(self.app_level_label, 10, 0, 1, 2)
self.app_level_radio = RadioSet([{'label': _('Beginner'), 'value': 'b'},
{'label': _('Advanced'), 'value': 'a'}])
grid0.addWidget(self.app_level_radio, 12, 0, 1, 2)
# Portability
self.portability_cb = FCCheckBox('%s' % _('Portable app'))
self.portability_cb.setToolTip(_("Choose if the application should run as portable.\n\n"
"If Checked the application will run portable,\n"
"which means that the preferences files will be saved\n"
"in the application folder, in the lib\\config subfolder."))
grid0.addWidget(self.portability_cb, 14, 0, 1, 2)
# Verbose Log
self.verbose_cb = FCCheckBox('%s' % _('Verbose log'))
self.verbose_cb.setToolTip(_("Enable log messages in the Tcl Shell.\n"
"Require restart."))
grid0.addWidget(self.verbose_cb, 16, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 18, 0, 1, 2)
# Languages for FlatCAM
self.languagelabel = FCLabel('<b>%s</b>' % _('Languages'))
self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
grid0.addWidget(self.languagelabel, 20, 0, 1, 2)
self.language_combo = FCComboBox()
grid0.addWidget(self.language_combo, 22, 0, 1, 2)
self.language_combo.addItems(self.defaults["global_languages"])
self.language_apply_btn = FCButton(_("Apply Language"))
self.language_apply_btn.setToolTip(_("Set the language used throughout FlatCAM.\n"
"The app will restart after click."))
grid0.addWidget(self.language_apply_btn, 24, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 26, 0, 1, 2)
# -----------------------------------------------------------
# ----------- APPLICATION STARTUP SETTINGS ------------------
# -----------------------------------------------------------
self.startup_label = FCLabel('<b>%s</b>' % _('Startup Settings'))
grid0.addWidget(self.startup_label, 28, 0, 1, 2)
# Splash Screen
self.splash_cb = FCCheckBox('%s' % _('Splash Screen'))
self.splash_cb.setToolTip(
_("Enable display of the splash screen at application startup.")
)
qsettings = QSettings("Open Source", "FlatCAM")
if qsettings.value("splash_screen"):
self.splash_cb.set_value(True)
else:
self.splash_cb.set_value(False)
grid0.addWidget(self.splash_cb, 30, 0, 1, 2)
# Sys Tray Icon
self.systray_cb = FCCheckBox('%s' % _('Sys Tray Icon'))
self.systray_cb.setToolTip(
_("Enable display of FlatCAM icon in Sys Tray.")
)
grid0.addWidget(self.systray_cb, 32, 0, 1, 2)
# Shell StartUp CB
self.shell_startup_cb = FCCheckBox(label='%s' % _('Show Shell'))
self.shell_startup_cb.setToolTip(
_("Check this box if you want the shell to\n"
"start automatically at startup.")
)
grid0.addWidget(self.shell_startup_cb, 34, 0, 1, 2)
# Project at StartUp CB
self.project_startup_cb = FCCheckBox(label='%s' % _('Show Project'))
self.project_startup_cb.setToolTip(
_("Check this box if you want the project/selected/tool tab area to\n"
"to be shown automatically at startup.")
)
grid0.addWidget(self.project_startup_cb, 36, 0, 1, 2)
# Version Check CB
self.version_check_cb = FCCheckBox(label='%s' % _('Version Check'))
self.version_check_cb.setToolTip(
_("Check this box if you want to check\n"
"for a new version automatically at startup.")
)
grid0.addWidget(self.version_check_cb, 38, 0, 1, 2)
# Send Stats CB
self.send_stats_cb = FCCheckBox(label='%s' % _('Send Statistics'))
self.send_stats_cb.setToolTip(
_("Check this box if you agree to send anonymous\n"
"stats automatically at startup, to help improve FlatCAM.")
)
grid0.addWidget(self.send_stats_cb, 40, 0, 1, 2)
self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 42, 0, 1, 2)
# separator_line = QtWidgets.QFrame()
# separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
# separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
# grid0.addWidget(separator_line, 8, 0, 1, 2)
# Worker Numbers
self.worker_number_label = FCLabel('%s:' % _('Workers number'))
@@ -225,8 +120,8 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
self.worker_number_sb = FCSpinner()
self.worker_number_sb.set_range(2, 16)
grid0.addWidget(self.worker_number_label, 44, 0)
grid0.addWidget(self.worker_number_sb, 44, 1)
grid1.addWidget(self.worker_number_label, 2, 0)
grid1.addWidget(self.worker_number_sb, 2, 1)
# Geometric tolerance
tol_label = FCLabel('%s:' % _("Geo Tolerance"))
@@ -242,17 +137,157 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
self.tol_entry.setSingleStep(0.001)
self.tol_entry.set_precision(6)
grid0.addWidget(tol_label, 46, 0)
grid0.addWidget(self.tol_entry, 46, 1)
grid1.addWidget(tol_label, 4, 0)
grid1.addWidget(self.tol_entry, 4, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 48, 0, 1, 2)
# Portability
self.portability_cb = FCCheckBox('%s' % _('Portable app'))
self.portability_cb.setToolTip(_("Choose if the application should run as portable.\n\n"
"If Checked the application will run portable,\n"
"which means that the preferences files will be saved\n"
"in the application folder, in the lib\\config subfolder."))
grid1.addWidget(self.portability_cb, 6, 0, 1, 2)
# Verbose Log
self.verbose_cb = FCCheckBox('%s' % _('Verbose log'))
self.verbose_cb.setToolTip(_("Enable log messages in the Tcl Shell.\n"
"Require restart."))
grid1.addWidget(self.verbose_cb, 8, 0, 1, 2)
# #############################################################################################################
# Grid0 Frame
# #############################################################################################################
self.app_level_label = FCLabel('<span style="color:red;"><b>%s</b></span>' % _('Application Level'))
self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
"BASIC level -> reduced functionality, best for beginner's.\n"
"ADVANCED level -> full functionality.\n\n"
"The choice here will influence the parameters in\n"
"the Selected Tab for all kinds of FlatCAM objects."))
self.layout.addWidget(self.app_level_label)
grid2_frame = FCFrame()
self.layout.addWidget(grid2_frame)
grid2 = FCGridLayout(v_spacing=5, h_spacing=3)
grid2_frame.setLayout(grid2)
# Application Level for FlatCAM
self.app_level_radio = RadioSet([{'label': _('Beginner'), 'value': 'b'},
{'label': _('Advanced'), 'value': 'a'}], compact=True)
grid2.addWidget(self.app_level_radio, 2, 0, 1, 2)
# #############################################################################################################
# Grid3 Frame
# #############################################################################################################
# Languages for FlatCAM
self.languagelabel = FCLabel('<span style="color:DarkCyan;"><b>%s</b></span>' % _('Languages'))
self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
self.layout.addWidget(self.languagelabel)
grid3_frame = FCFrame()
self.layout.addWidget(grid3_frame)
grid3 = FCGridLayout(v_spacing=5, h_spacing=3)
grid3_frame.setLayout(grid3)
self.language_combo = FCComboBox()
self.language_combo.addItems(self.defaults["global_languages"])
grid3.addWidget(self.language_combo, 0, 0, 1, 2)
self.language_apply_btn = FCButton(_("Apply Language"))
self.language_apply_btn.setToolTip(_("Set the language used throughout FlatCAM.\n"
"The app will restart after click."))
grid3.addWidget(self.language_apply_btn, 2, 0, 1, 2)
# -----------------------------------------------------------
# ----------- APPLICATION STARTUP SETTINGS ------------------
# -----------------------------------------------------------
self.startup_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _('Startup Settings'))
self.layout.addWidget(self.startup_label)
# #############################################################################################################
# Grid4 Frame
# #############################################################################################################
grid4_frame = FCFrame()
self.layout.addWidget(grid4_frame)
grid4 = FCGridLayout(v_spacing=5, h_spacing=3)
grid4_frame.setLayout(grid4)
# Splash Screen
self.splash_cb = FCCheckBox('%s' % _('Splash Screen'))
self.splash_cb.setToolTip(
_("Enable display of the splash screen at application startup.")
)
qsettings = QSettings("Open Source", "FlatCAM")
if qsettings.value("splash_screen"):
self.splash_cb.set_value(True)
else:
self.splash_cb.set_value(False)
grid4.addWidget(self.splash_cb, 0, 0, 1, 2)
# Sys Tray Icon
self.systray_cb = FCCheckBox('%s' % _('Sys Tray Icon'))
self.systray_cb.setToolTip(
_("Enable display of FlatCAM icon in Sys Tray.")
)
grid4.addWidget(self.systray_cb, 2, 0, 1, 2)
# Shell StartUp CB
self.shell_startup_cb = FCCheckBox(label='%s' % _('Show Shell'))
self.shell_startup_cb.setToolTip(
_("Check this box if you want the shell to\n"
"start automatically at startup.")
)
grid4.addWidget(self.shell_startup_cb, 4, 0, 1, 2)
# Project at StartUp CB
self.project_startup_cb = FCCheckBox(label='%s' % _('Show Project'))
self.project_startup_cb.setToolTip(
_("Check this box if you want the project/selected/tool tab area to\n"
"to be shown automatically at startup.")
)
grid4.addWidget(self.project_startup_cb, 6, 0, 1, 2)
# Version Check CB
self.version_check_cb = FCCheckBox(label='%s' % _('Version Check'))
self.version_check_cb.setToolTip(
_("Check this box if you want to check\n"
"for a new version automatically at startup.")
)
grid4.addWidget(self.version_check_cb, 8, 0, 1, 2)
# Send Stats CB
self.send_stats_cb = FCCheckBox(label='%s' % _('Send Statistics'))
self.send_stats_cb.setToolTip(
_("Check this box if you agree to send anonymous\n"
"stats automatically at startup, to help improve FlatCAM.")
)
grid4.addWidget(self.send_stats_cb, 10, 0, 1, 2)
self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
# Save Settings
self.save_label = FCLabel('<b>%s</b>' % _("Save Settings"))
grid0.addWidget(self.save_label, 50, 0, 1, 2)
self.save_label = FCLabel('<span style="color:purple;"><b>%s</b></span>' % _("Save Settings"))
self.layout.addWidget(self.save_label)
# #############################################################################################################
# Grid6 Frame
# #############################################################################################################
grid6_frame = FCFrame()
self.layout.addWidget(grid6_frame)
grid6 = FCGridLayout(v_spacing=5, h_spacing=3)
grid6_frame.setLayout(grid6)
# Save compressed project CB
self.save_type_cb = FCCheckBox(_('Save Compressed Project'))
@@ -261,7 +296,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
"When checked it will save a compressed FlatCAM project.")
)
grid0.addWidget(self.save_type_cb, 52, 0, 1, 2)
grid6.addWidget(self.save_type_cb, 0, 0, 1, 2)
# Project LZMA Comppression Level
self.compress_spinner = FCSpinner()
@@ -273,8 +308,8 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
"but require more RAM usage and more processing time.")
)
grid0.addWidget(self.compress_label, 54, 0)
grid0.addWidget(self.compress_spinner, 54, 1)
grid6.addWidget(self.compress_label, 2, 0)
grid6.addWidget(self.compress_spinner, 2, 1)
self.proj_ois = OptionalInputSection(self.save_type_cb, [self.compress_label, self.compress_spinner], True)
@@ -286,7 +321,7 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
"at the set interval.")
)
grid0.addWidget(self.autosave_cb, 56, 0, 1, 2)
grid6.addWidget(self.autosave_cb, 4, 0, 1, 2)
# Auto Save Timeout Interval
self.autosave_entry = FCSpinner()
@@ -299,21 +334,25 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
"While active, some operations may block this feature.")
)
grid0.addWidget(self.autosave_label, 58, 0)
grid0.addWidget(self.autosave_entry, 58, 1)
grid6.addWidget(self.autosave_label, 6, 0)
grid6.addWidget(self.autosave_entry, 6, 1)
# self.as_ois = OptionalInputSection(self.autosave_cb, [self.autosave_label, self.autosave_entry], True)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 60, 0, 1, 2)
self.pdf_param_label = FCLabel('<B>%s:</b>' % _("Text to PDF parameters"))
self.pdf_param_label = FCLabel('<span style="color:orange;"><b>%s</b></span>' % _("Text to PDF parameters"))
self.pdf_param_label.setToolTip(
_("Used when saving text in Code Editor or in FlatCAM Document objects.")
)
grid0.addWidget(self.pdf_param_label, 62, 0, 1, 2)
self.layout.addWidget(self.pdf_param_label)
# #############################################################################################################
# Grid7 Frame
# #############################################################################################################
grid7_frame = FCFrame()
self.layout.addWidget(grid7_frame)
grid7 = FCGridLayout(v_spacing=5, h_spacing=3)
grid7_frame.setLayout(grid7)
# Top Margin value
self.tmargin_entry = FCDoubleSpinner()
@@ -325,8 +364,8 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
_("Distance between text body and the top of the PDF file.")
)
grid0.addWidget(self.tmargin_label, 64, 0)
grid0.addWidget(self.tmargin_entry, 64, 1)
grid7.addWidget(self.tmargin_label, 0, 0)
grid7.addWidget(self.tmargin_entry, 0, 1)
# Bottom Margin value
self.bmargin_entry = FCDoubleSpinner()
@@ -338,8 +377,8 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
_("Distance between text body and the bottom of the PDF file.")
)
grid0.addWidget(self.bmargin_label, 66, 0)
grid0.addWidget(self.bmargin_entry, 66, 1)
grid7.addWidget(self.bmargin_label, 2, 0)
grid7.addWidget(self.bmargin_entry, 2, 1)
# Left Margin value
self.lmargin_entry = FCDoubleSpinner()
@@ -351,8 +390,8 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
_("Distance between text body and the left of the PDF file.")
)
grid0.addWidget(self.lmargin_label, 68, 0)
grid0.addWidget(self.lmargin_entry, 68, 1)
grid7.addWidget(self.lmargin_label, 4, 0)
grid7.addWidget(self.lmargin_entry, 4, 1)
# Right Margin value
self.rmargin_entry = FCDoubleSpinner()
@@ -364,11 +403,13 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
_("Distance between text body and the right of the PDF file.")
)
grid0.addWidget(self.rmargin_label, 70, 0)
grid0.addWidget(self.rmargin_entry, 70, 1)
grid7.addWidget(self.rmargin_label, 6, 0)
grid7.addWidget(self.rmargin_entry, 6, 1)
self.layout.addStretch()
FCGridLayout.set_common_column_size([grid0, grid1, grid6, grid7], 0)
if sys.platform != 'win32':
self.portability_cb.hide()