Grouped the preferences UI files by tab (except for tools1/2 which I put together)
This commit is contained in:
469
flatcamGUI/preferences/general/GeneralAPPSetGroupUI.py
Normal file
469
flatcamGUI/preferences/general/GeneralAPPSetGroupUI.py
Normal file
@@ -0,0 +1,469 @@
|
||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||
from PyQt5.QtCore import QSettings
|
||||
|
||||
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, FCComboBox, RadioSet, OptionalInputSection, FCSpinner, \
|
||||
FCEntry
|
||||
from flatcamGUI.preferences import settings
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
|
||||
|
||||
class GeneralAPPSetGroupUI(OptionsGroupUI):
|
||||
def __init__(self, decimals=4, parent=None):
|
||||
super(GeneralAPPSetGroupUI, self).__init__(self)
|
||||
|
||||
self.setTitle(str(_("App Settings")))
|
||||
self.decimals = decimals
|
||||
|
||||
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
|
||||
if theme_settings.contains("theme"):
|
||||
theme = theme_settings.value('theme', type=str)
|
||||
else:
|
||||
theme = 'white'
|
||||
|
||||
if theme == 'white':
|
||||
self.resource_loc = 'assets/resources'
|
||||
else:
|
||||
self.resource_loc = 'assets/resources'
|
||||
|
||||
# Create a grid layout for the Application general settings
|
||||
grid0 = QtWidgets.QGridLayout()
|
||||
self.layout.addLayout(grid0)
|
||||
grid0.setColumnStretch(0, 0)
|
||||
grid0.setColumnStretch(1, 1)
|
||||
|
||||
# GRID Settings
|
||||
self.grid_label = QtWidgets.QLabel('<b>%s</b>' % _('Grid Settings'))
|
||||
grid0.addWidget(self.grid_label, 0, 0, 1, 2)
|
||||
|
||||
# Grid X Entry
|
||||
self.gridx_label = QtWidgets.QLabel('%s:' % _('X value'))
|
||||
self.gridx_label.setToolTip(
|
||||
_("This is the Grid snap value on X axis.")
|
||||
)
|
||||
self.gridx_entry = FCDoubleSpinner()
|
||||
self.gridx_entry.set_precision(self.decimals)
|
||||
self.gridx_entry.setSingleStep(0.1)
|
||||
|
||||
grid0.addWidget(self.gridx_label, 1, 0)
|
||||
grid0.addWidget(self.gridx_entry, 1, 1)
|
||||
|
||||
# Grid Y Entry
|
||||
self.gridy_label = QtWidgets.QLabel('%s:' % _('Y value'))
|
||||
self.gridy_label.setToolTip(
|
||||
_("This is the Grid snap value on Y axis.")
|
||||
)
|
||||
self.gridy_entry = FCDoubleSpinner()
|
||||
self.gridy_entry.set_precision(self.decimals)
|
||||
self.gridy_entry.setSingleStep(0.1)
|
||||
|
||||
grid0.addWidget(self.gridy_label, 2, 0)
|
||||
grid0.addWidget(self.gridy_entry, 2, 1)
|
||||
|
||||
# Snap Max Entry
|
||||
self.snap_max_label = QtWidgets.QLabel('%s:' % _('Snap Max'))
|
||||
self.snap_max_label.setToolTip(_("Max. magnet distance"))
|
||||
self.snap_max_dist_entry = FCDoubleSpinner()
|
||||
self.snap_max_dist_entry.set_precision(self.decimals)
|
||||
self.snap_max_dist_entry.setSingleStep(0.1)
|
||||
|
||||
grid0.addWidget(self.snap_max_label, 3, 0)
|
||||
grid0.addWidget(self.snap_max_dist_entry, 3, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 4, 0, 1, 2)
|
||||
|
||||
# Workspace
|
||||
self.workspace_label = QtWidgets.QLabel('<b>%s</b>' % _('Workspace Settings'))
|
||||
grid0.addWidget(self.workspace_label, 5, 0, 1, 2)
|
||||
|
||||
self.workspace_cb = FCCheckBox('%s' % _('Active'))
|
||||
self.workspace_cb.setToolTip(
|
||||
_("Draw a delimiting rectangle on canvas.\n"
|
||||
"The purpose is to illustrate the limits for our work.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.workspace_cb, 6, 0, 1, 2)
|
||||
|
||||
self.workspace_type_lbl = QtWidgets.QLabel('%s:' % _('Size'))
|
||||
self.workspace_type_lbl.setToolTip(
|
||||
_("Select the type of rectangle to be used on canvas,\n"
|
||||
"as valid workspace.")
|
||||
)
|
||||
self.wk_cb = FCComboBox()
|
||||
|
||||
grid0.addWidget(self.workspace_type_lbl, 7, 0)
|
||||
grid0.addWidget(self.wk_cb, 7, 1)
|
||||
|
||||
self.pagesize = {}
|
||||
self.pagesize.update(
|
||||
{
|
||||
'A0': (841, 1189),
|
||||
'A1': (594, 841),
|
||||
'A2': (420, 594),
|
||||
'A3': (297, 420),
|
||||
'A4': (210, 297),
|
||||
'A5': (148, 210),
|
||||
'A6': (105, 148),
|
||||
'A7': (74, 105),
|
||||
'A8': (52, 74),
|
||||
'A9': (37, 52),
|
||||
'A10': (26, 37),
|
||||
|
||||
'B0': (1000, 1414),
|
||||
'B1': (707, 1000),
|
||||
'B2': (500, 707),
|
||||
'B3': (353, 500),
|
||||
'B4': (250, 353),
|
||||
'B5': (176, 250),
|
||||
'B6': (125, 176),
|
||||
'B7': (88, 125),
|
||||
'B8': (62, 88),
|
||||
'B9': (44, 62),
|
||||
'B10': (31, 44),
|
||||
|
||||
'C0': (917, 1297),
|
||||
'C1': (648, 917),
|
||||
'C2': (458, 648),
|
||||
'C3': (324, 458),
|
||||
'C4': (229, 324),
|
||||
'C5': (162, 229),
|
||||
'C6': (114, 162),
|
||||
'C7': (81, 114),
|
||||
'C8': (57, 81),
|
||||
'C9': (40, 57),
|
||||
'C10': (28, 40),
|
||||
|
||||
# American paper sizes
|
||||
'LETTER': (8.5, 11),
|
||||
'LEGAL': (8.5, 14),
|
||||
'ELEVENSEVENTEEN': (11, 17),
|
||||
|
||||
# From https://en.wikipedia.org/wiki/Paper_size
|
||||
'JUNIOR_LEGAL': (5, 8),
|
||||
'HALF_LETTER': (5.5, 8),
|
||||
'GOV_LETTER': (8, 10.5),
|
||||
'GOV_LEGAL': (8.5, 13),
|
||||
'LEDGER': (17, 11),
|
||||
}
|
||||
)
|
||||
|
||||
page_size_list = list(self.pagesize.keys())
|
||||
|
||||
self.wk_cb.addItems(page_size_list)
|
||||
|
||||
# Page orientation
|
||||
self.wk_orientation_label = QtWidgets.QLabel('%s:' % _("Orientation"))
|
||||
self.wk_orientation_label.setToolTip(_("Can be:\n"
|
||||
"- Portrait\n"
|
||||
"- Landscape"))
|
||||
|
||||
self.wk_orientation_radio = RadioSet([{'label': _('Portrait'), 'value': 'p'},
|
||||
{'label': _('Landscape'), 'value': 'l'},
|
||||
], stretch=False)
|
||||
|
||||
self.wks = OptionalInputSection(self.workspace_cb,
|
||||
[
|
||||
self.workspace_type_lbl,
|
||||
self.wk_cb,
|
||||
self.wk_orientation_label,
|
||||
self.wk_orientation_radio
|
||||
])
|
||||
|
||||
grid0.addWidget(self.wk_orientation_label, 8, 0)
|
||||
grid0.addWidget(self.wk_orientation_radio, 8, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 9, 0, 1, 2)
|
||||
|
||||
# Font Size
|
||||
self.font_size_label = QtWidgets.QLabel('<b>%s</b>' % _('Font Size'))
|
||||
grid0.addWidget(self.font_size_label, 10, 0, 1, 2)
|
||||
|
||||
# Notebook Font Size
|
||||
self.notebook_font_size_label = QtWidgets.QLabel('%s:' % _('Notebook'))
|
||||
self.notebook_font_size_label.setToolTip(
|
||||
_("This sets the font size for the elements found in the Notebook.\n"
|
||||
"The notebook is the collapsible area in the left side of the GUI,\n"
|
||||
"and include the Project, Selected and Tool tabs.")
|
||||
)
|
||||
|
||||
self.notebook_font_size_spinner = FCSpinner()
|
||||
self.notebook_font_size_spinner.set_range(8, 40)
|
||||
self.notebook_font_size_spinner.setWrapping(True)
|
||||
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
if qsettings.contains("notebook_font_size"):
|
||||
self.notebook_font_size_spinner.set_value(qsettings.value('notebook_font_size', type=int))
|
||||
else:
|
||||
self.notebook_font_size_spinner.set_value(12)
|
||||
|
||||
grid0.addWidget(self.notebook_font_size_label, 11, 0)
|
||||
grid0.addWidget(self.notebook_font_size_spinner, 11, 1)
|
||||
|
||||
# Axis Font Size
|
||||
self.axis_font_size_label = QtWidgets.QLabel('%s:' % _('Axis'))
|
||||
self.axis_font_size_label.setToolTip(
|
||||
_("This sets the font size for canvas axis.")
|
||||
)
|
||||
|
||||
self.axis_font_size_spinner = FCSpinner()
|
||||
self.axis_font_size_spinner.set_range(0, 40)
|
||||
self.axis_font_size_spinner.setWrapping(True)
|
||||
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
if qsettings.contains("axis_font_size"):
|
||||
self.axis_font_size_spinner.set_value(qsettings.value('axis_font_size', type=int))
|
||||
else:
|
||||
self.axis_font_size_spinner.set_value(8)
|
||||
|
||||
grid0.addWidget(self.axis_font_size_label, 12, 0)
|
||||
grid0.addWidget(self.axis_font_size_spinner, 12, 1)
|
||||
|
||||
# TextBox Font Size
|
||||
self.textbox_font_size_label = QtWidgets.QLabel('%s:' % _('Textbox'))
|
||||
self.textbox_font_size_label.setToolTip(
|
||||
_("This sets the font size for the Textbox GUI\n"
|
||||
"elements that are used in FlatCAM.")
|
||||
)
|
||||
|
||||
self.textbox_font_size_spinner = FCSpinner()
|
||||
self.textbox_font_size_spinner.set_range(8, 40)
|
||||
self.textbox_font_size_spinner.setWrapping(True)
|
||||
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
if qsettings.contains("textbox_font_size"):
|
||||
self.textbox_font_size_spinner.set_value(settings.value('textbox_font_size', type=int))
|
||||
else:
|
||||
self.textbox_font_size_spinner.set_value(10)
|
||||
|
||||
grid0.addWidget(self.textbox_font_size_label, 13, 0)
|
||||
grid0.addWidget(self.textbox_font_size_spinner, 13, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 14, 0, 1, 2)
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# -------------- MOUSE SETTINGS -----------------------------
|
||||
# -----------------------------------------------------------
|
||||
|
||||
self.mouse_lbl = QtWidgets.QLabel('<b>%s</b>' % _('Mouse Settings'))
|
||||
grid0.addWidget(self.mouse_lbl, 21, 0, 1, 2)
|
||||
|
||||
# Mouse Cursor Shape
|
||||
self.cursor_lbl = QtWidgets.QLabel('%s:' % _('Cursor Shape'))
|
||||
self.cursor_lbl.setToolTip(
|
||||
_("Choose a mouse cursor shape.\n"
|
||||
"- Small -> with a customizable size.\n"
|
||||
"- Big -> Infinite lines")
|
||||
)
|
||||
|
||||
self.cursor_radio = RadioSet([
|
||||
{"label": _("Small"), "value": "small"},
|
||||
{"label": _("Big"), "value": "big"}
|
||||
], orientation='horizontal', stretch=False)
|
||||
|
||||
grid0.addWidget(self.cursor_lbl, 22, 0)
|
||||
grid0.addWidget(self.cursor_radio, 22, 1)
|
||||
|
||||
# Mouse Cursor Size
|
||||
self.cursor_size_lbl = QtWidgets.QLabel('%s:' % _('Cursor Size'))
|
||||
self.cursor_size_lbl.setToolTip(
|
||||
_("Set the size of the mouse cursor, in pixels.")
|
||||
)
|
||||
|
||||
self.cursor_size_entry = FCSpinner()
|
||||
self.cursor_size_entry.set_range(10, 70)
|
||||
self.cursor_size_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(self.cursor_size_lbl, 23, 0)
|
||||
grid0.addWidget(self.cursor_size_entry, 23, 1)
|
||||
|
||||
# Cursor Width
|
||||
self.cursor_width_lbl = QtWidgets.QLabel('%s:' % _('Cursor Width'))
|
||||
self.cursor_width_lbl.setToolTip(
|
||||
_("Set the line width of the mouse cursor, in pixels.")
|
||||
)
|
||||
|
||||
self.cursor_width_entry = FCSpinner()
|
||||
self.cursor_width_entry.set_range(1, 10)
|
||||
self.cursor_width_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(self.cursor_width_lbl, 24, 0)
|
||||
grid0.addWidget(self.cursor_width_entry, 24, 1)
|
||||
|
||||
# Cursor Color Enable
|
||||
self.mouse_cursor_color_cb = FCCheckBox(label='%s' % _('Cursor Color'))
|
||||
self.mouse_cursor_color_cb.setToolTip(
|
||||
_("Check this box to color mouse cursor.")
|
||||
)
|
||||
grid0.addWidget(self.mouse_cursor_color_cb, 25, 0, 1, 2)
|
||||
|
||||
# Cursor Color
|
||||
self.mouse_color_label = QtWidgets.QLabel('%s:' % _('Cursor Color'))
|
||||
self.mouse_color_label.setToolTip(
|
||||
_("Set the color of the mouse cursor.")
|
||||
)
|
||||
self.mouse_cursor_entry = FCEntry()
|
||||
self.mouse_cursor_button = QtWidgets.QPushButton()
|
||||
self.mouse_cursor_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_1 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_1.addWidget(self.mouse_cursor_entry)
|
||||
self.form_box_child_1.addWidget(self.mouse_cursor_button)
|
||||
self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.mouse_color_label, 26, 0)
|
||||
grid0.addLayout(self.form_box_child_1, 26, 1)
|
||||
|
||||
self.mois = OptionalInputSection(
|
||||
self.mouse_cursor_color_cb,
|
||||
[
|
||||
self.mouse_color_label,
|
||||
self.mouse_cursor_entry,
|
||||
self.mouse_cursor_button
|
||||
]
|
||||
)
|
||||
# Select mouse pan button
|
||||
self.panbuttonlabel = QtWidgets.QLabel('%s:' % _('Pan Button'))
|
||||
self.panbuttonlabel.setToolTip(
|
||||
_("Select the mouse button to use for panning:\n"
|
||||
"- MMB --> Middle Mouse Button\n"
|
||||
"- RMB --> Right Mouse Button")
|
||||
)
|
||||
self.pan_button_radio = RadioSet([{'label': _('MMB'), 'value': '3'},
|
||||
{'label': _('RMB'), 'value': '2'}])
|
||||
|
||||
grid0.addWidget(self.panbuttonlabel, 27, 0)
|
||||
grid0.addWidget(self.pan_button_radio, 27, 1)
|
||||
|
||||
# Multiple Selection Modifier Key
|
||||
self.mselectlabel = QtWidgets.QLabel('%s:' % _('Multiple Selection'))
|
||||
self.mselectlabel.setToolTip(
|
||||
_("Select the key used for multiple selection.")
|
||||
)
|
||||
self.mselect_radio = RadioSet([{'label': _('CTRL'), 'value': 'Control'},
|
||||
{'label': _('SHIFT'), 'value': 'Shift'}])
|
||||
|
||||
grid0.addWidget(self.mselectlabel, 28, 0)
|
||||
grid0.addWidget(self.mselect_radio, 28, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 29, 0, 1, 2)
|
||||
|
||||
# Delete confirmation
|
||||
self.delete_conf_cb = FCCheckBox(_('Delete object confirmation'))
|
||||
self.delete_conf_cb.setToolTip(
|
||||
_("When checked the application will ask for user confirmation\n"
|
||||
"whenever the Delete object(s) event is triggered, either by\n"
|
||||
"menu shortcut or key shortcut.")
|
||||
)
|
||||
grid0.addWidget(self.delete_conf_cb, 30, 0, 1, 2)
|
||||
|
||||
# Open behavior
|
||||
self.open_style_cb = FCCheckBox('%s' % _('"Open" behavior'))
|
||||
self.open_style_cb.setToolTip(
|
||||
_("When checked the path for the last saved file is used when saving files,\n"
|
||||
"and the path for the last opened file is used when opening files.\n\n"
|
||||
"When unchecked the path for opening files is the one used last: either the\n"
|
||||
"path for saving files or the path for opening files.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.open_style_cb, 31, 0, 1, 2)
|
||||
|
||||
# Enable/Disable ToolTips globally
|
||||
self.toggle_tooltips_cb = FCCheckBox(label=_('Enable ToolTips'))
|
||||
self.toggle_tooltips_cb.setToolTip(
|
||||
_("Check this box if you want to have toolTips displayed\n"
|
||||
"when hovering with mouse over items throughout the App.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.toggle_tooltips_cb, 32, 0, 1, 2)
|
||||
|
||||
# Machinist settings that allow unsafe settings
|
||||
self.machinist_cb = FCCheckBox(_("Allow Machinist Unsafe Settings"))
|
||||
self.machinist_cb.setToolTip(
|
||||
_("If checked, some of the application settings will be allowed\n"
|
||||
"to have values that are usually unsafe to use.\n"
|
||||
"Like Z travel negative values or Z Cut positive values.\n"
|
||||
"It will applied at the next application start.\n"
|
||||
"<<WARNING>>: Don't change this unless you know what you are doing !!!")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.machinist_cb, 33, 0, 1, 2)
|
||||
|
||||
# Bookmarks Limit in the Help Menu
|
||||
self.bm_limit_spinner = FCSpinner()
|
||||
self.bm_limit_spinner.set_range(0, 9999)
|
||||
self.bm_limit_label = QtWidgets.QLabel('%s:' % _('Bookmarks limit'))
|
||||
self.bm_limit_label.setToolTip(
|
||||
_("The maximum number of bookmarks that may be installed in the menu.\n"
|
||||
"The number of bookmarks in the bookmark manager may be greater\n"
|
||||
"but the menu will hold only so much.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.bm_limit_label, 34, 0)
|
||||
grid0.addWidget(self.bm_limit_spinner, 34, 1)
|
||||
|
||||
# Activity monitor icon
|
||||
self.activity_label = QtWidgets.QLabel('%s:' % _("Activity Icon"))
|
||||
self.activity_label.setToolTip(
|
||||
_("Select the GIF that show activity when FlatCAM is active.")
|
||||
)
|
||||
self.activity_combo = FCComboBox()
|
||||
self.activity_combo.addItems(['Ball black', 'Ball green', 'Arrow green', 'Eclipse green'])
|
||||
|
||||
grid0.addWidget(self.activity_label, 35, 0)
|
||||
grid0.addWidget(self.activity_combo, 35, 1)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
self.mouse_cursor_color_cb.stateChanged.connect(self.on_mouse_cursor_color_enable)
|
||||
|
||||
self.mouse_cursor_entry.editingFinished.connect(self.on_mouse_cursor_entry)
|
||||
self.mouse_cursor_button.clicked.connect(self.on_mouse_cursor_button)
|
||||
|
||||
def on_mouse_cursor_color_enable(self, val):
|
||||
if val:
|
||||
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
|
||||
else:
|
||||
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
|
||||
if theme_settings.contains("theme"):
|
||||
theme = theme_settings.value('theme', type=str)
|
||||
else:
|
||||
theme = 'white'
|
||||
|
||||
if theme == 'white':
|
||||
self.app.cursor_color_3D = 'black'
|
||||
else:
|
||||
self.app.cursor_color_3D = 'gray'
|
||||
|
||||
def on_mouse_cursor_entry(self):
|
||||
self.app.defaults['global_cursor_color'] = self.mouse_cursor_entry.get_value()
|
||||
self.mouse_cursor_button.setStyleSheet("background-color:%s" % str(self.app.defaults['global_cursor_color']))
|
||||
|
||||
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
|
||||
|
||||
def on_mouse_cursor_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_cursor_color'])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
proj_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if proj_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.mouse_cursor_button.setStyleSheet("background-color:%s" % str(proj_color.name()))
|
||||
|
||||
new_val_sel = str(proj_color.name())
|
||||
self.mouse_cursor_entry.set_value(new_val_sel)
|
||||
self.app.defaults['global_cursor_color'] = new_val_sel
|
||||
|
||||
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
|
||||
374
flatcamGUI/preferences/general/GeneralAppPrefGroupUI.py
Normal file
374
flatcamGUI/preferences/general/GeneralAppPrefGroupUI.py
Normal file
@@ -0,0 +1,374 @@
|
||||
import sys
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5.QtCore import QSettings
|
||||
|
||||
import FlatCAMTranslation as fcTranslate
|
||||
from flatcamGUI.GUIElements import RadioSet, FCSpinner, FCCheckBox, FCComboBox, FCButton, OptionalInputSection, \
|
||||
FCDoubleSpinner
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
|
||||
|
||||
class GeneralAppPrefGroupUI(OptionsGroupUI):
|
||||
def __init__(self, decimals=4, parent=None):
|
||||
super(GeneralAppPrefGroupUI, self).__init__(self)
|
||||
|
||||
self.setTitle(_("App Preferences"))
|
||||
self.decimals = decimals
|
||||
|
||||
# Create a form layout for the Application general settings
|
||||
grid0 = QtWidgets.QGridLayout()
|
||||
self.layout.addLayout(grid0)
|
||||
grid0.setColumnStretch(0, 0)
|
||||
grid0.setColumnStretch(1, 1)
|
||||
|
||||
# Units for FlatCAM
|
||||
self.unitslabel = QtWidgets.QLabel('<span style="color:red;"><b>%s:</b></span>' % _('Units'))
|
||||
self.unitslabel.setToolTip(_("The default value for FlatCAM units.\n"
|
||||
"Whatever is selected here is set every time\n"
|
||||
"FlatCAM is started."))
|
||||
self.units_radio = RadioSet([{'label': _('MM'), 'value': 'MM'},
|
||||
{'label': _('IN'), 'value': 'IN'}])
|
||||
|
||||
grid0.addWidget(self.unitslabel, 0, 0)
|
||||
grid0.addWidget(self.units_radio, 0, 1)
|
||||
|
||||
# Precision Metric
|
||||
self.precision_metric_label = QtWidgets.QLabel('%s:' % _('Precision MM'))
|
||||
self.precision_metric_label.setToolTip(
|
||||
_("The number of decimals used throughout the application\n"
|
||||
"when the set units are in METRIC system.\n"
|
||||
"Any change here require an application restart.")
|
||||
)
|
||||
self.precision_metric_entry = FCSpinner()
|
||||
self.precision_metric_entry.set_range(2, 16)
|
||||
self.precision_metric_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(self.precision_metric_label, 1, 0)
|
||||
grid0.addWidget(self.precision_metric_entry, 1, 1)
|
||||
|
||||
# Precision Inch
|
||||
self.precision_inch_label = QtWidgets.QLabel('%s:' % _('Precision INCH'))
|
||||
self.precision_inch_label.setToolTip(
|
||||
_("The number of decimals used throughout the application\n"
|
||||
"when the set units are in INCH system.\n"
|
||||
"Any change here require an application restart.")
|
||||
)
|
||||
self.precision_inch_entry = FCSpinner()
|
||||
self.precision_inch_entry.set_range(2, 16)
|
||||
self.precision_inch_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(self.precision_inch_label, 2, 0)
|
||||
grid0.addWidget(self.precision_inch_entry, 2, 1)
|
||||
|
||||
# Graphic Engine for FlatCAM
|
||||
self.ge_label = QtWidgets.QLabel('<b>%s:</b>' % _('Graphic Engine'))
|
||||
self.ge_label.setToolTip(_("Choose what graphic engine to use in FlatCAM.\n"
|
||||
"Legacy(2D) -> reduced functionality, slow performance but enhanced compatibility.\n"
|
||||
"OpenGL(3D) -> full functionality, high performance\n"
|
||||
"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')
|
||||
|
||||
grid0.addWidget(self.ge_label, 3, 0)
|
||||
grid0.addWidget(self.ge_radio, 3, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 4, 0, 1, 2)
|
||||
|
||||
# Application Level for FlatCAM
|
||||
self.app_level_label = QtWidgets.QLabel('<span style="color:red;"><b>%s:</b></span>' % _('APP. 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.app_level_radio = RadioSet([{'label': _('Basic'), 'value': 'b'},
|
||||
{'label': _('Advanced'), 'value': 'a'}])
|
||||
|
||||
grid0.addWidget(self.app_level_label, 5, 0)
|
||||
grid0.addWidget(self.app_level_radio, 5, 1)
|
||||
|
||||
# Portability for FlatCAM
|
||||
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, 6, 0, 1, 2)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 7, 0, 1, 2)
|
||||
|
||||
# Languages for FlatCAM
|
||||
self.languagelabel = QtWidgets.QLabel('<b>%s</b>' % _('Languages'))
|
||||
self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
|
||||
self.language_cb = FCComboBox()
|
||||
|
||||
grid0.addWidget(self.languagelabel, 8, 0, 1, 2)
|
||||
grid0.addWidget(self.language_cb, 9, 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."))
|
||||
|
||||
grid0.addWidget(self.language_apply_btn, 15, 0, 1, 2)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 16, 0, 1, 2)
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# ----------- APPLICATION STARTUP SETTINGS ------------------
|
||||
# -----------------------------------------------------------
|
||||
|
||||
self.startup_label = QtWidgets.QLabel('<b>%s</b>' % _('Startup Settings'))
|
||||
grid0.addWidget(self.startup_label, 17, 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, 18, 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, 19, 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, 20, 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, 21, 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, 22, 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, 23, 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.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 24, 0, 1, 2)
|
||||
|
||||
# Worker Numbers
|
||||
self.worker_number_label = QtWidgets.QLabel('%s:' % _('Workers number'))
|
||||
self.worker_number_label.setToolTip(
|
||||
_("The number of Qthreads made available to the App.\n"
|
||||
"A bigger number may finish the jobs more quickly but\n"
|
||||
"depending on your computer speed, may make the App\n"
|
||||
"unresponsive. Can have a value between 2 and 16.\n"
|
||||
"Default value is 2.\n"
|
||||
"After change, it will be applied at next App start.")
|
||||
)
|
||||
self.worker_number_sb = FCSpinner()
|
||||
self.worker_number_sb.set_range(2, 16)
|
||||
|
||||
grid0.addWidget(self.worker_number_label, 25, 0)
|
||||
grid0.addWidget(self.worker_number_sb, 25, 1)
|
||||
|
||||
# Geometric tolerance
|
||||
tol_label = QtWidgets.QLabel('%s:' % _("Geo Tolerance"))
|
||||
tol_label.setToolTip(_(
|
||||
"This value can counter the effect of the Circle Steps\n"
|
||||
"parameter. Default value is 0.005.\n"
|
||||
"A lower value will increase the detail both in image\n"
|
||||
"and in Gcode for the circles, with a higher cost in\n"
|
||||
"performance. Higher value will provide more\n"
|
||||
"performance at the expense of level of detail."
|
||||
))
|
||||
self.tol_entry = FCDoubleSpinner()
|
||||
self.tol_entry.setSingleStep(0.001)
|
||||
self.tol_entry.set_precision(6)
|
||||
|
||||
grid0.addWidget(tol_label, 26, 0)
|
||||
grid0.addWidget(self.tol_entry, 26, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 27, 0, 1, 2)
|
||||
|
||||
# Save Settings
|
||||
self.save_label = QtWidgets.QLabel('<b>%s</b>' % _("Save Settings"))
|
||||
grid0.addWidget(self.save_label, 28, 0, 1, 2)
|
||||
|
||||
# Save compressed project CB
|
||||
self.save_type_cb = FCCheckBox(_('Save Compressed Project'))
|
||||
self.save_type_cb.setToolTip(
|
||||
_("Whether to save a compressed or uncompressed project.\n"
|
||||
"When checked it will save a compressed FlatCAM project.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.save_type_cb, 29, 0, 1, 2)
|
||||
|
||||
# Project LZMA Comppression Level
|
||||
self.compress_spinner = FCSpinner()
|
||||
self.compress_spinner.set_range(0, 9)
|
||||
self.compress_label = QtWidgets.QLabel('%s:' % _('Compression'))
|
||||
self.compress_label.setToolTip(
|
||||
_("The level of compression used when saving\n"
|
||||
"a FlatCAM project. Higher value means better compression\n"
|
||||
"but require more RAM usage and more processing time.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.compress_label, 30, 0)
|
||||
grid0.addWidget(self.compress_spinner, 30, 1)
|
||||
|
||||
self.proj_ois = OptionalInputSection(self.save_type_cb, [self.compress_label, self.compress_spinner], True)
|
||||
|
||||
# Auto save CB
|
||||
self.autosave_cb = FCCheckBox(_('Enable Auto Save'))
|
||||
self.autosave_cb.setToolTip(
|
||||
_("Check to enable the autosave feature.\n"
|
||||
"When enabled, the application will try to save a project\n"
|
||||
"at the set interval.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.autosave_cb, 31, 0, 1, 2)
|
||||
|
||||
# Auto Save Timeout Interval
|
||||
self.autosave_entry = FCSpinner()
|
||||
self.autosave_entry.set_range(0, 9999999)
|
||||
self.autosave_label = QtWidgets.QLabel('%s:' % _('Interval'))
|
||||
self.autosave_label.setToolTip(
|
||||
_("Time interval for autosaving. In milliseconds.\n"
|
||||
"The application will try to save periodically but only\n"
|
||||
"if the project was saved manually at least once.\n"
|
||||
"While active, some operations may block this feature.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.autosave_label, 32, 0)
|
||||
grid0.addWidget(self.autosave_entry, 32, 1)
|
||||
|
||||
# self.as_ois = OptionalInputSection(self.autosave_cb, [self.autosave_label, self.autosave_entry], True)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 33, 0, 1, 2)
|
||||
|
||||
self.pdf_param_label = QtWidgets.QLabel('<B>%s:</b>' % _("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, 34, 0, 1, 2)
|
||||
|
||||
# Top Margin value
|
||||
self.tmargin_entry = FCDoubleSpinner()
|
||||
self.tmargin_entry.set_precision(self.decimals)
|
||||
self.tmargin_entry.set_range(0.0000, 9999.9999)
|
||||
|
||||
self.tmargin_label = QtWidgets.QLabel('%s:' % _("Top Margin"))
|
||||
self.tmargin_label.setToolTip(
|
||||
_("Distance between text body and the top of the PDF file.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.tmargin_label, 35, 0)
|
||||
grid0.addWidget(self.tmargin_entry, 35, 1)
|
||||
|
||||
# Bottom Margin value
|
||||
self.bmargin_entry = FCDoubleSpinner()
|
||||
self.bmargin_entry.set_precision(self.decimals)
|
||||
self.bmargin_entry.set_range(0.0000, 9999.9999)
|
||||
|
||||
self.bmargin_label = QtWidgets.QLabel('%s:' % _("Bottom Margin"))
|
||||
self.bmargin_label.setToolTip(
|
||||
_("Distance between text body and the bottom of the PDF file.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.bmargin_label, 36, 0)
|
||||
grid0.addWidget(self.bmargin_entry, 36, 1)
|
||||
|
||||
# Left Margin value
|
||||
self.lmargin_entry = FCDoubleSpinner()
|
||||
self.lmargin_entry.set_precision(self.decimals)
|
||||
self.lmargin_entry.set_range(0.0000, 9999.9999)
|
||||
|
||||
self.lmargin_label = QtWidgets.QLabel('%s:' % _("Left Margin"))
|
||||
self.lmargin_label.setToolTip(
|
||||
_("Distance between text body and the left of the PDF file.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.lmargin_label, 37, 0)
|
||||
grid0.addWidget(self.lmargin_entry, 37, 1)
|
||||
|
||||
# Right Margin value
|
||||
self.rmargin_entry = FCDoubleSpinner()
|
||||
self.rmargin_entry.set_precision(self.decimals)
|
||||
self.rmargin_entry.set_range(0.0000, 9999.9999)
|
||||
|
||||
self.rmargin_label = QtWidgets.QLabel('%s:' % _("Right Margin"))
|
||||
self.rmargin_label.setToolTip(
|
||||
_("Distance between text body and the right of the PDF file.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.rmargin_label, 38, 0)
|
||||
grid0.addWidget(self.rmargin_entry, 38, 1)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
if sys.platform != 'win32':
|
||||
self.portability_cb.hide()
|
||||
|
||||
# splash screen button signal
|
||||
self.splash_cb.stateChanged.connect(self.on_splash_changed)
|
||||
|
||||
# Monitor the checkbox from the Application Defaults Tab and show the TCL shell or not depending on it's value
|
||||
self.shell_startup_cb.clicked.connect(self.app.on_toggle_shell_from_settings)
|
||||
|
||||
self.language_apply_btn.clicked.connect(lambda: fcTranslate.on_language_apply_click(app=self.app, restart=True))
|
||||
|
||||
@staticmethod
|
||||
def on_splash_changed(state):
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
qsettings.setValue('splash_screen', 1) if state else qsettings.setValue('splash_screen', 0)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del qsettings
|
||||
772
flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py
Normal file
772
flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py
Normal file
@@ -0,0 +1,772 @@
|
||||
from PyQt5 import QtWidgets, QtCore, QtGui
|
||||
from PyQt5.QtCore import QSettings, Qt
|
||||
|
||||
from flatcamGUI.GUIElements import RadioSet, FCCheckBox, FCButton, FCComboBox, FCEntry, FCSpinner
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
|
||||
|
||||
class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||
def __init__(self, decimals=4, parent=None):
|
||||
super(GeneralGUIPrefGroupUI, self).__init__(self)
|
||||
|
||||
self.setTitle(str(_("GUI Preferences")))
|
||||
self.decimals = decimals
|
||||
|
||||
# Create a grid layout for the Application general settings
|
||||
grid0 = QtWidgets.QGridLayout()
|
||||
self.layout.addLayout(grid0)
|
||||
grid0.setColumnStretch(0, 0)
|
||||
grid0.setColumnStretch(1, 1)
|
||||
|
||||
# Theme selection
|
||||
self.theme_label = QtWidgets.QLabel('%s:' % _('Theme'))
|
||||
self.theme_label.setToolTip(
|
||||
_("Select a theme for FlatCAM.\n"
|
||||
"It will theme the plot area.")
|
||||
)
|
||||
|
||||
self.theme_radio = RadioSet([
|
||||
{"label": _("Light"), "value": "white"},
|
||||
{"label": _("Dark"), "value": "black"}
|
||||
], orientation='vertical')
|
||||
|
||||
grid0.addWidget(self.theme_label, 0, 0)
|
||||
grid0.addWidget(self.theme_radio, 0, 1)
|
||||
|
||||
# Enable Gray Icons
|
||||
self.gray_icons_cb = FCCheckBox('%s' % _('Use Gray Icons'))
|
||||
self.gray_icons_cb.setToolTip(
|
||||
_("Check this box to use a set of icons with\n"
|
||||
"a lighter (gray) color. To be used when a\n"
|
||||
"full dark theme is applied.")
|
||||
)
|
||||
grid0.addWidget(self.gray_icons_cb, 1, 0, 1, 3)
|
||||
|
||||
self.theme_button = FCButton(_("Apply Theme"))
|
||||
self.theme_button.setToolTip(
|
||||
_("Select a theme for FlatCAM.\n"
|
||||
"It will theme the plot area.\n"
|
||||
"The application will restart after change.")
|
||||
)
|
||||
grid0.addWidget(self.theme_button, 2, 0, 1, 3)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 3, 0, 1, 2)
|
||||
|
||||
# Layout selection
|
||||
self.layout_label = QtWidgets.QLabel('%s:' % _('Layout'))
|
||||
self.layout_label.setToolTip(
|
||||
_("Select an layout for FlatCAM.\n"
|
||||
"It is applied immediately.")
|
||||
)
|
||||
self.layout_combo = FCComboBox()
|
||||
# don't translate the QCombo items as they are used in QSettings and identified by name
|
||||
self.layout_combo.addItem("standard")
|
||||
self.layout_combo.addItem("compact")
|
||||
self.layout_combo.addItem("minimal")
|
||||
|
||||
grid0.addWidget(self.layout_label, 4, 0)
|
||||
grid0.addWidget(self.layout_combo, 4, 1)
|
||||
|
||||
# Set the current index for layout_combo
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
if qsettings.contains("layout"):
|
||||
layout = qsettings.value('layout', type=str)
|
||||
idx = self.layout_combo.findText(layout.capitalize())
|
||||
self.layout_combo.setCurrentIndex(idx)
|
||||
|
||||
# Style selection
|
||||
self.style_label = QtWidgets.QLabel('%s:' % _('Style'))
|
||||
self.style_label.setToolTip(
|
||||
_("Select an style for FlatCAM.\n"
|
||||
"It will be applied at the next app start.")
|
||||
)
|
||||
self.style_combo = FCComboBox()
|
||||
self.style_combo.addItems(QtWidgets.QStyleFactory.keys())
|
||||
# find current style
|
||||
index = self.style_combo.findText(QtWidgets.qApp.style().objectName(), QtCore.Qt.MatchFixedString)
|
||||
self.style_combo.setCurrentIndex(index)
|
||||
self.style_combo.activated[str].connect(self.handle_style)
|
||||
|
||||
grid0.addWidget(self.style_label, 5, 0)
|
||||
grid0.addWidget(self.style_combo, 5, 1)
|
||||
|
||||
# Enable High DPI Support
|
||||
self.hdpi_cb = FCCheckBox('%s' % _('Activate HDPI Support'))
|
||||
self.hdpi_cb.setToolTip(
|
||||
_("Enable High DPI support for FlatCAM.\n"
|
||||
"It will be applied at the next app start.")
|
||||
)
|
||||
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
if qsettings.contains("hdpi"):
|
||||
self.hdpi_cb.set_value(qsettings.value('hdpi', type=int))
|
||||
else:
|
||||
self.hdpi_cb.set_value(False)
|
||||
self.hdpi_cb.stateChanged.connect(self.handle_hdpi)
|
||||
|
||||
grid0.addWidget(self.hdpi_cb, 6, 0, 1, 3)
|
||||
|
||||
# Enable Hover box
|
||||
self.hover_cb = FCCheckBox('%s' % _('Display Hover Shape'))
|
||||
self.hover_cb.setToolTip(
|
||||
_("Enable display of a hover shape for FlatCAM objects.\n"
|
||||
"It is displayed whenever the mouse cursor is hovering\n"
|
||||
"over any kind of not-selected object.")
|
||||
)
|
||||
grid0.addWidget(self.hover_cb, 8, 0, 1, 3)
|
||||
|
||||
# Enable Selection box
|
||||
self.selection_cb = FCCheckBox('%s' % _('Display Selection Shape'))
|
||||
self.selection_cb.setToolTip(
|
||||
_("Enable the display of a selection shape for FlatCAM objects.\n"
|
||||
"It is displayed whenever the mouse selects an object\n"
|
||||
"either by clicking or dragging mouse from left to right or\n"
|
||||
"right to left.")
|
||||
)
|
||||
grid0.addWidget(self.selection_cb, 9, 0, 1, 3)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 14, 0, 1, 2)
|
||||
|
||||
# Plot Selection (left - right) Color
|
||||
self.sel_lr_label = QtWidgets.QLabel('<b>%s</b>' % _('Left-Right Selection Color'))
|
||||
grid0.addWidget(self.sel_lr_label, 15, 0, 1, 2)
|
||||
|
||||
self.sl_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
|
||||
self.sl_color_label.setToolTip(
|
||||
_("Set the line color for the 'left to right' selection box.")
|
||||
)
|
||||
self.sl_color_entry = FCEntry()
|
||||
self.sl_color_button = QtWidgets.QPushButton()
|
||||
self.sl_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_4 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_4.addWidget(self.sl_color_entry)
|
||||
self.form_box_child_4.addWidget(self.sl_color_button)
|
||||
self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.sl_color_label, 16, 0)
|
||||
grid0.addLayout(self.form_box_child_4, 16, 1)
|
||||
|
||||
self.sf_color_label = QtWidgets.QLabel('%s:' % _('Fill'))
|
||||
self.sf_color_label.setToolTip(
|
||||
_("Set the fill color for the selection box\n"
|
||||
"in case that the selection is done from left to right.\n"
|
||||
"First 6 digits are the color and the last 2\n"
|
||||
"digits are for alpha (transparency) level.")
|
||||
)
|
||||
self.sf_color_entry = FCEntry()
|
||||
self.sf_color_button = QtWidgets.QPushButton()
|
||||
self.sf_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_5 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_5.addWidget(self.sf_color_entry)
|
||||
self.form_box_child_5.addWidget(self.sf_color_button)
|
||||
self.form_box_child_5.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.sf_color_label, 17, 0)
|
||||
grid0.addLayout(self.form_box_child_5, 17, 1)
|
||||
|
||||
# Plot Selection (left - right) Fill Transparency Level
|
||||
self.sf_alpha_label = QtWidgets.QLabel('%s:' % _('Alpha'))
|
||||
self.sf_alpha_label.setToolTip(
|
||||
_("Set the fill transparency for the 'left to right' selection box.")
|
||||
)
|
||||
self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
|
||||
self.sf_color_alpha_slider.setMinimum(0)
|
||||
self.sf_color_alpha_slider.setMaximum(255)
|
||||
self.sf_color_alpha_slider.setSingleStep(1)
|
||||
|
||||
self.sf_color_alpha_spinner = FCSpinner()
|
||||
self.sf_color_alpha_spinner.setMinimumWidth(70)
|
||||
self.sf_color_alpha_spinner.set_range(0, 255)
|
||||
|
||||
self.form_box_child_6 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_6.addWidget(self.sf_color_alpha_slider)
|
||||
self.form_box_child_6.addWidget(self.sf_color_alpha_spinner)
|
||||
|
||||
grid0.addWidget(self.sf_alpha_label, 18, 0)
|
||||
grid0.addLayout(self.form_box_child_6, 18, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 19, 0, 1, 2)
|
||||
|
||||
# Plot Selection (left - right) Color
|
||||
self.sel_rl_label = QtWidgets.QLabel('<b>%s</b>' % _('Right-Left Selection Color'))
|
||||
grid0.addWidget(self.sel_rl_label, 20, 0, 1, 2)
|
||||
|
||||
# Plot Selection (right - left) Line Color
|
||||
self.alt_sl_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
|
||||
self.alt_sl_color_label.setToolTip(
|
||||
_("Set the line color for the 'right to left' selection box.")
|
||||
)
|
||||
self.alt_sl_color_entry = FCEntry()
|
||||
self.alt_sl_color_button = QtWidgets.QPushButton()
|
||||
self.alt_sl_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_7 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_7.addWidget(self.alt_sl_color_entry)
|
||||
self.form_box_child_7.addWidget(self.alt_sl_color_button)
|
||||
self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.alt_sl_color_label, 21, 0)
|
||||
grid0.addLayout(self.form_box_child_7, 21, 1)
|
||||
|
||||
# Plot Selection (right - left) Fill Color
|
||||
self.alt_sf_color_label = QtWidgets.QLabel('%s:' % _('Fill'))
|
||||
self.alt_sf_color_label.setToolTip(
|
||||
_("Set the fill color for the selection box\n"
|
||||
"in case that the selection is done from right to left.\n"
|
||||
"First 6 digits are the color and the last 2\n"
|
||||
"digits are for alpha (transparency) level.")
|
||||
)
|
||||
self.alt_sf_color_entry = FCEntry()
|
||||
self.alt_sf_color_button = QtWidgets.QPushButton()
|
||||
self.alt_sf_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_8 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_8.addWidget(self.alt_sf_color_entry)
|
||||
self.form_box_child_8.addWidget(self.alt_sf_color_button)
|
||||
self.form_box_child_8.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.alt_sf_color_label, 22, 0)
|
||||
grid0.addLayout(self.form_box_child_8, 22, 1)
|
||||
|
||||
# Plot Selection (right - left) Fill Transparency Level
|
||||
self.alt_sf_alpha_label = QtWidgets.QLabel('%s:' % _('Alpha'))
|
||||
self.alt_sf_alpha_label.setToolTip(
|
||||
_("Set the fill transparency for selection 'right to left' box.")
|
||||
)
|
||||
self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
|
||||
self.alt_sf_color_alpha_slider.setMinimum(0)
|
||||
self.alt_sf_color_alpha_slider.setMaximum(255)
|
||||
self.alt_sf_color_alpha_slider.setSingleStep(1)
|
||||
|
||||
self.alt_sf_color_alpha_spinner = FCSpinner()
|
||||
self.alt_sf_color_alpha_spinner.setMinimumWidth(70)
|
||||
self.alt_sf_color_alpha_spinner.set_range(0, 255)
|
||||
|
||||
self.form_box_child_9 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_9.addWidget(self.alt_sf_color_alpha_slider)
|
||||
self.form_box_child_9.addWidget(self.alt_sf_color_alpha_spinner)
|
||||
|
||||
grid0.addWidget(self.alt_sf_alpha_label, 23, 0)
|
||||
grid0.addLayout(self.form_box_child_9, 23, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 24, 0, 1, 2)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# ----------------------- Editor Color -----------------------------
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
self.editor_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Editor Color'))
|
||||
grid0.addWidget(self.editor_color_label, 25, 0, 1, 2)
|
||||
|
||||
# Editor Draw Color
|
||||
self.draw_color_label = QtWidgets.QLabel('%s:' % _('Drawing'))
|
||||
self.alt_sf_color_label.setToolTip(
|
||||
_("Set the color for the shape.")
|
||||
)
|
||||
self.draw_color_entry = FCEntry()
|
||||
self.draw_color_button = QtWidgets.QPushButton()
|
||||
self.draw_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_10 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_10.addWidget(self.draw_color_entry)
|
||||
self.form_box_child_10.addWidget(self.draw_color_button)
|
||||
self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.draw_color_label, 26, 0)
|
||||
grid0.addLayout(self.form_box_child_10, 26, 1)
|
||||
|
||||
# Editor Draw Selection Color
|
||||
self.sel_draw_color_label = QtWidgets.QLabel('%s:' % _('Selection'))
|
||||
self.sel_draw_color_label.setToolTip(
|
||||
_("Set the color of the shape when selected.")
|
||||
)
|
||||
self.sel_draw_color_entry = FCEntry()
|
||||
self.sel_draw_color_button = QtWidgets.QPushButton()
|
||||
self.sel_draw_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_11 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_11.addWidget(self.sel_draw_color_entry)
|
||||
self.form_box_child_11.addWidget(self.sel_draw_color_button)
|
||||
self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.sel_draw_color_label, 27, 0)
|
||||
grid0.addLayout(self.form_box_child_11, 27, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 28, 0, 1, 2)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# ----------------------- Project Settings -----------------------------
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
self.proj_settings_label = QtWidgets.QLabel('<b>%s</b>' % _('Project Items Color'))
|
||||
grid0.addWidget(self.proj_settings_label, 29, 0, 1, 2)
|
||||
|
||||
# Project Tab items color
|
||||
self.proj_color_label = QtWidgets.QLabel('%s:' % _('Enabled'))
|
||||
self.proj_color_label.setToolTip(
|
||||
_("Set the color of the items in Project Tab Tree.")
|
||||
)
|
||||
self.proj_color_entry = FCEntry()
|
||||
self.proj_color_button = QtWidgets.QPushButton()
|
||||
self.proj_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_12 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_12.addWidget(self.proj_color_entry)
|
||||
self.form_box_child_12.addWidget(self.proj_color_button)
|
||||
self.form_box_child_12.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.proj_color_label, 30, 0)
|
||||
grid0.addLayout(self.form_box_child_12, 30, 1)
|
||||
|
||||
self.proj_color_dis_label = QtWidgets.QLabel('%s:' % _('Disabled'))
|
||||
self.proj_color_dis_label.setToolTip(
|
||||
_("Set the color of the items in Project Tab Tree,\n"
|
||||
"for the case when the items are disabled.")
|
||||
)
|
||||
self.proj_color_dis_entry = FCEntry()
|
||||
self.proj_color_dis_button = QtWidgets.QPushButton()
|
||||
self.proj_color_dis_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_13 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_13.addWidget(self.proj_color_dis_entry)
|
||||
self.form_box_child_13.addWidget(self.proj_color_dis_button)
|
||||
self.form_box_child_13.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.proj_color_dis_label, 31, 0)
|
||||
grid0.addLayout(self.form_box_child_13, 31, 1)
|
||||
|
||||
# Project autohide CB
|
||||
self.project_autohide_cb = FCCheckBox(label=_('Project AutoHide'))
|
||||
self.project_autohide_cb.setToolTip(
|
||||
_("Check this box if you want the project/selected/tool tab area to\n"
|
||||
"hide automatically when there are no objects loaded and\n"
|
||||
"to show whenever a new object is created.")
|
||||
)
|
||||
|
||||
grid0.addWidget(self.project_autohide_cb, 32, 0, 1, 2)
|
||||
|
||||
# Just to add empty rows
|
||||
grid0.addWidget(QtWidgets.QLabel(''), 33, 0, 1, 2)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
self.theme_button.clicked.connect(self.on_theme_change)
|
||||
|
||||
# #############################################################################
|
||||
# ############################# GUI COLORS SIGNALS ############################
|
||||
# #############################################################################
|
||||
|
||||
# Setting selection (left - right) colors signals
|
||||
self.sf_color_entry.editingFinished.connect(self.on_sf_color_entry)
|
||||
self.sf_color_button.clicked.connect(self.on_sf_color_button)
|
||||
self.sf_color_alpha_spinner.valueChanged.connect(self.on_sf_color_spinner)
|
||||
self.sf_color_alpha_slider.valueChanged.connect(self.on_sf_color_slider)
|
||||
self.sl_color_entry.editingFinished.connect(self.on_sl_color_entry)
|
||||
self.sl_color_button.clicked.connect(self.on_sl_color_button)
|
||||
|
||||
# Setting selection (right - left) colors signals
|
||||
self.alt_sf_color_entry.editingFinished.connect(self.on_alt_sf_color_entry)
|
||||
self.alt_sf_color_button.clicked.connect(self.on_alt_sf_color_button)
|
||||
self.alt_sf_color_alpha_spinner.valueChanged.connect(self.on_alt_sf_color_spinner)
|
||||
self.alt_sf_color_alpha_slider.valueChanged.connect(self.on_alt_sf_color_slider)
|
||||
self.alt_sl_color_entry.editingFinished.connect(self.on_alt_sl_color_entry)
|
||||
self.alt_sl_color_button.clicked.connect(self.on_alt_sl_color_button)
|
||||
|
||||
# Setting Editor Draw colors signals
|
||||
self.draw_color_entry.editingFinished.connect(self.on_draw_color_entry)
|
||||
self.draw_color_button.clicked.connect(self.on_draw_color_button)
|
||||
|
||||
self.sel_draw_color_entry.editingFinished.connect(self.on_sel_draw_color_entry)
|
||||
self.sel_draw_color_button.clicked.connect(self.on_sel_draw_color_button)
|
||||
|
||||
self.proj_color_entry.editingFinished.connect(self.on_proj_color_entry)
|
||||
self.proj_color_button.clicked.connect(self.on_proj_color_button)
|
||||
|
||||
self.proj_color_dis_entry.editingFinished.connect(self.on_proj_color_dis_entry)
|
||||
self.proj_color_dis_button.clicked.connect(self.on_proj_color_dis_button)
|
||||
|
||||
self.layout_combo.activated.connect(self.on_layout)
|
||||
|
||||
def on_theme_change(self):
|
||||
val = self.theme_radio.get_value()
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
qsettings.setValue('theme', val)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del qsettings
|
||||
|
||||
self.app.on_app_restart()
|
||||
|
||||
@staticmethod
|
||||
def handle_style(style):
|
||||
# set current style
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
qsettings.setValue('style', style)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del qsettings
|
||||
|
||||
@staticmethod
|
||||
def handle_hdpi(state):
|
||||
# set current HDPI
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
qsettings.setValue('hdpi', state)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del qsettings
|
||||
|
||||
# Setting selection colors (left - right) handlers
|
||||
def on_sf_color_entry(self):
|
||||
self.app.defaults['global_sel_fill'] = self.app.defaults['global_sel_fill'][7:9]
|
||||
self.sf_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['global_sel_fill'])[:7])
|
||||
|
||||
def on_sf_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_sel_fill'][:7])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
plot_fill_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if plot_fill_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.sf_color_button.setStyleSheet("background-color:%s" % str(plot_fill_color.name()))
|
||||
|
||||
new_val = str(plot_fill_color.name()) + str(self.app.defaults['global_sel_fill'][7:9])
|
||||
self.sf_color_entry.set_value(new_val)
|
||||
self.app.defaults['global_sel_fill'] = new_val
|
||||
|
||||
def on_sf_color_spinner(self):
|
||||
spinner_value = self.sf_color_alpha_spinner.value()
|
||||
self.sf_color_alpha_slider.setValue(spinner_value)
|
||||
self.app.defaults['global_sel_fill'] = self.app.defaults['global_sel_fill'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
self.app.defaults['global_sel_line'] = self.app.defaults['global_sel_line'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
|
||||
def on_sf_color_slider(self):
|
||||
slider_value = self.sf_color_alpha_slider.value()
|
||||
self.sf_color_alpha_spinner.setValue(slider_value)
|
||||
|
||||
def on_sl_color_entry(self):
|
||||
self.app.defaults['global_sel_line'] = self.sl_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['global_sel_line'][7:9]
|
||||
self.sl_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['global_sel_line'])[:7])
|
||||
|
||||
def on_sl_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_sel_line'][:7])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
plot_line_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if plot_line_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.sl_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name()))
|
||||
|
||||
new_val_line = str(plot_line_color.name()) + str(self.app.defaults['global_sel_line'][7:9])
|
||||
self.sl_color_entry.set_value(new_val_line)
|
||||
self.app.defaults['global_sel_line'] = new_val_line
|
||||
|
||||
# Setting selection colors (right - left) handlers
|
||||
def on_alt_sf_color_entry(self):
|
||||
self.app.defaults['global_alt_sel_fill'] = self.alt_sf_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['global_alt_sel_fill'][7:9]
|
||||
self.alt_sf_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['global_alt_sel_fill'])[:7]
|
||||
)
|
||||
|
||||
def on_alt_sf_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_alt_sel_fill'][:7])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
plot_fill_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if plot_fill_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.alt_sf_color_button.setStyleSheet("background-color:%s" % str(plot_fill_color.name()))
|
||||
|
||||
new_val = str(plot_fill_color.name()) + str(self.app.defaults['global_alt_sel_fill'][7:9])
|
||||
self.alt_sf_color_entry.set_value(new_val)
|
||||
self.app.defaults['global_alt_sel_fill'] = new_val
|
||||
|
||||
def on_alt_sf_color_spinner(self):
|
||||
spinner_value = self.alt_sf_color_alpha_spinner.value()
|
||||
self.alt_sf_color_alpha_slider.setValue(spinner_value)
|
||||
self.app.defaults['global_alt_sel_fill'] = self.app.defaults['global_alt_sel_fill'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
self.app.defaults['global_alt_sel_line'] = self.app.defaults['global_alt_sel_line'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
|
||||
def on_alt_sf_color_slider(self):
|
||||
slider_value = self.alt_sf_color_alpha_slider.value()
|
||||
self.alt_sf_color_alpha_spinner.setValue(slider_value)
|
||||
|
||||
def on_alt_sl_color_entry(self):
|
||||
self.app.defaults['global_alt_sel_line'] = self.alt_sl_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['global_alt_sel_line'][7:9]
|
||||
self.alt_sl_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['global_alt_sel_line'])[:7]
|
||||
)
|
||||
|
||||
def on_alt_sl_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_alt_sel_line'][:7])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
plot_line_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if plot_line_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.alt_sl_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name()))
|
||||
|
||||
new_val_line = str(plot_line_color.name()) + str(self.app.defaults['global_alt_sel_line'][7:9])
|
||||
self.alt_sl_color_entry.set_value(new_val_line)
|
||||
self.app.defaults['global_alt_sel_line'] = new_val_line
|
||||
|
||||
# Setting Editor colors
|
||||
def on_draw_color_entry(self):
|
||||
self.app.defaults['global_draw_color'] = self.draw_color_entry.get_value()
|
||||
self.draw_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['global_draw_color']))
|
||||
|
||||
def on_draw_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_draw_color'])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
draw_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if draw_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.draw_color_button.setStyleSheet("background-color:%s" % str(draw_color.name()))
|
||||
|
||||
new_val = str(draw_color.name())
|
||||
self.draw_color_entry.set_value(new_val)
|
||||
self.app.defaults['global_draw_color'] = new_val
|
||||
|
||||
def on_sel_draw_color_entry(self):
|
||||
self.app.defaults['global_sel_draw_color'] = self.sel_draw_color_entry.get_value()
|
||||
self.sel_draw_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['global_sel_draw_color']))
|
||||
|
||||
def on_sel_draw_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_sel_draw_color'])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
sel_draw_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if sel_draw_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.sel_draw_color_button.setStyleSheet("background-color:%s" % str(sel_draw_color.name()))
|
||||
|
||||
new_val_sel = str(sel_draw_color.name())
|
||||
self.sel_draw_color_entry.set_value(new_val_sel)
|
||||
self.app.defaults['global_sel_draw_color'] = new_val_sel
|
||||
|
||||
def on_proj_color_entry(self):
|
||||
self.app.defaults['global_proj_item_color'] = self.proj_color_entry.get_value()
|
||||
self.proj_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['global_proj_item_color']))
|
||||
|
||||
def on_proj_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_proj_item_color'])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
proj_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if proj_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.proj_color_button.setStyleSheet("background-color:%s" % str(proj_color.name()))
|
||||
|
||||
new_val_sel = str(proj_color.name())
|
||||
self.proj_color_entry.set_value(new_val_sel)
|
||||
self.app.defaults['global_proj_item_color'] = new_val_sel
|
||||
|
||||
def on_proj_color_dis_entry(self):
|
||||
self.app.defaults['global_proj_item_dis_color'] = self.proj_color_dis_entry.get_value()
|
||||
self.proj_color_dis_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['global_proj_item_dis_color']))
|
||||
|
||||
def on_proj_color_dis_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['global_proj_item_dis_color'])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
proj_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if proj_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.proj_color_dis_button.setStyleSheet("background-color:%s" % str(proj_color.name()))
|
||||
|
||||
new_val_sel = str(proj_color.name())
|
||||
self.proj_color_dis_entry.set_value(new_val_sel)
|
||||
self.app.defaults['global_proj_item_dis_color'] = new_val_sel
|
||||
|
||||
def on_layout(self, index=None, lay=None):
|
||||
"""
|
||||
Set the toolbars layout (location)
|
||||
|
||||
:param index:
|
||||
:param lay: Type of layout to be set on the toolbard
|
||||
:return: None
|
||||
"""
|
||||
self.app.defaults.report_usage("on_layout()")
|
||||
if lay:
|
||||
current_layout = lay
|
||||
else:
|
||||
current_layout = self.layout_combo.get_value()
|
||||
|
||||
lay_settings = QSettings("Open Source", "FlatCAM")
|
||||
lay_settings.setValue('layout', current_layout)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del lay_settings
|
||||
|
||||
# first remove the toolbars:
|
||||
try:
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbarfile)
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbargeo)
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbarview)
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbarshell)
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbartools)
|
||||
self.app.ui.removeToolBar(self.app.ui.exc_edit_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.geo_edit_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.grb_edit_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.snap_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbarshell)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if current_layout == 'compact':
|
||||
# ## TOOLBAR INSTALLATION # ##
|
||||
self.app.ui.toolbarfile = QtWidgets.QToolBar('File Toolbar')
|
||||
self.app.ui.toolbarfile.setObjectName('File_TB')
|
||||
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbarfile)
|
||||
|
||||
self.app.ui.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
|
||||
self.app.ui.toolbargeo.setObjectName('Edit_TB')
|
||||
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbargeo)
|
||||
|
||||
self.app.ui.toolbarshell = QtWidgets.QToolBar('Shell Toolbar')
|
||||
self.app.ui.toolbarshell.setObjectName('Shell_TB')
|
||||
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbarshell)
|
||||
|
||||
self.app.ui.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
|
||||
self.app.ui.toolbartools.setObjectName('Tools_TB')
|
||||
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbartools)
|
||||
|
||||
self.app.ui.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
|
||||
# self.app.ui.geo_edit_toolbar.setVisible(False)
|
||||
self.app.ui.geo_edit_toolbar.setObjectName('GeoEditor_TB')
|
||||
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.geo_edit_toolbar)
|
||||
|
||||
self.app.ui.toolbarview = QtWidgets.QToolBar('View Toolbar')
|
||||
self.app.ui.toolbarview.setObjectName('View_TB')
|
||||
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.toolbarview)
|
||||
|
||||
self.app.ui.addToolBarBreak(area=Qt.RightToolBarArea)
|
||||
|
||||
self.app.ui.grb_edit_toolbar = QtWidgets.QToolBar('Gerber Editor Toolbar')
|
||||
# self.app.ui.grb_edit_toolbar.setVisible(False)
|
||||
self.app.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
|
||||
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.grb_edit_toolbar)
|
||||
|
||||
self.app.ui.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
|
||||
self.app.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
|
||||
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.exc_edit_toolbar)
|
||||
|
||||
self.app.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
|
||||
self.app.ui.snap_toolbar.setObjectName('Snap_TB')
|
||||
self.app.ui.snap_toolbar.setMaximumHeight(30)
|
||||
self.app.ui.splitter_left.addWidget(self.app.ui.snap_toolbar)
|
||||
|
||||
self.app.ui.corner_snap_btn.setVisible(True)
|
||||
self.app.ui.snap_magnet.setVisible(True)
|
||||
else:
|
||||
# ## TOOLBAR INSTALLATION # ##
|
||||
self.app.ui.toolbarfile = QtWidgets.QToolBar('File Toolbar')
|
||||
self.app.ui.toolbarfile.setObjectName('File_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.toolbarfile)
|
||||
|
||||
self.app.ui.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
|
||||
self.app.ui.toolbargeo.setObjectName('Edit_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.toolbargeo)
|
||||
|
||||
self.app.ui.toolbarview = QtWidgets.QToolBar('View Toolbar')
|
||||
self.app.ui.toolbarview.setObjectName('View_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.toolbarview)
|
||||
|
||||
self.app.ui.toolbarshell = QtWidgets.QToolBar('Shell Toolbar')
|
||||
self.app.ui.toolbarshell.setObjectName('Shell_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.toolbarshell)
|
||||
|
||||
self.app.ui.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
|
||||
self.app.ui.toolbartools.setObjectName('Tools_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.toolbartools)
|
||||
|
||||
self.app.ui.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
|
||||
# self.app.ui.exc_edit_toolbar.setVisible(False)
|
||||
self.app.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.exc_edit_toolbar)
|
||||
|
||||
self.app.ui.addToolBarBreak()
|
||||
|
||||
self.app.ui.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
|
||||
# self.app.ui.geo_edit_toolbar.setVisible(False)
|
||||
self.app.ui.geo_edit_toolbar.setObjectName('GeoEditor_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.geo_edit_toolbar)
|
||||
|
||||
self.app.ui.grb_edit_toolbar = QtWidgets.QToolBar('Gerber Editor Toolbar')
|
||||
# self.app.ui.grb_edit_toolbar.setVisible(False)
|
||||
self.app.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.grb_edit_toolbar)
|
||||
|
||||
self.app.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
|
||||
self.app.ui.snap_toolbar.setObjectName('Snap_TB')
|
||||
# self.app.ui.snap_toolbar.setMaximumHeight(30)
|
||||
self.app.ui.addToolBar(self.app.ui.snap_toolbar)
|
||||
|
||||
self.app.ui.corner_snap_btn.setVisible(False)
|
||||
self.app.ui.snap_magnet.setVisible(False)
|
||||
|
||||
if current_layout == 'minimal':
|
||||
self.app.ui.toolbarview.setVisible(False)
|
||||
self.app.ui.toolbarshell.setVisible(False)
|
||||
self.app.ui.snap_toolbar.setVisible(False)
|
||||
self.app.ui.geo_edit_toolbar.setVisible(False)
|
||||
self.app.ui.grb_edit_toolbar.setVisible(False)
|
||||
self.app.ui.exc_edit_toolbar.setVisible(False)
|
||||
self.app.ui.lock_toolbar(lock=True)
|
||||
|
||||
# add all the actions to the toolbars
|
||||
self.app.ui.populate_toolbars()
|
||||
|
||||
# reconnect all the signals to the toolbar actions
|
||||
self.app.connect_toolbar_signals()
|
||||
|
||||
self.app.ui.grid_snap_btn.setChecked(True)
|
||||
self.app.on_grid_snap_triggered(state=True)
|
||||
|
||||
self.app.ui.grid_gap_x_entry.setText(str(self.app.defaults["global_gridx"]))
|
||||
self.app.ui.grid_gap_y_entry.setText(str(self.app.defaults["global_gridy"]))
|
||||
self.app.ui.snap_max_dist_entry.setText(str(self.app.defaults["global_snap_max"]))
|
||||
self.app.ui.grid_gap_link_cb.setChecked(True)
|
||||
28
flatcamGUI/preferences/general/GeneralPreferencesUI.py
Normal file
28
flatcamGUI/preferences/general/GeneralPreferencesUI.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
from flatcamGUI.preferences.general.GeneralAppPrefGroupUI import GeneralAppPrefGroupUI
|
||||
from flatcamGUI.preferences.general.GeneralAPPSetGroupUI import GeneralAPPSetGroupUI
|
||||
from flatcamGUI.preferences.general.GeneralGUIPrefGroupUI import GeneralGUIPrefGroupUI
|
||||
|
||||
|
||||
class GeneralPreferencesUI(QtWidgets.QWidget):
|
||||
def __init__(self, decimals, parent=None):
|
||||
QtWidgets.QWidget.__init__(self, parent=parent)
|
||||
self.layout = QtWidgets.QHBoxLayout()
|
||||
self.setLayout(self.layout)
|
||||
self.decimals = decimals
|
||||
|
||||
self.general_app_group = GeneralAppPrefGroupUI(decimals=self.decimals)
|
||||
self.general_app_group.setMinimumWidth(250)
|
||||
|
||||
self.general_gui_group = GeneralGUIPrefGroupUI(decimals=self.decimals)
|
||||
self.general_gui_group.setMinimumWidth(250)
|
||||
|
||||
self.general_app_set_group = GeneralAPPSetGroupUI(decimals=self.decimals)
|
||||
self.general_app_set_group.setMinimumWidth(250)
|
||||
|
||||
self.layout.addWidget(self.general_app_group)
|
||||
self.layout.addWidget(self.general_gui_group)
|
||||
self.layout.addWidget(self.general_app_set_group)
|
||||
|
||||
self.layout.addStretch()
|
||||
0
flatcamGUI/preferences/general/__init__.py
Normal file
0
flatcamGUI/preferences/general/__init__.py
Normal file
Reference in New Issue
Block a user