Merge branch 'Beta' into preferences-refactoring
This commit is contained in:
@@ -1292,10 +1292,89 @@ class ExcellonObjectUI(ObjectUI):
|
||||
self.grid5.addWidget(pp_geo_label, 16, 0)
|
||||
self.grid5.addWidget(self.pp_geo_name_cb, 16, 1)
|
||||
|
||||
# Exclusion Areas
|
||||
self.exclusion_cb = FCCheckBox('%s' % _("Add exclusion areas"))
|
||||
self.exclusion_cb.setToolTip(
|
||||
_(
|
||||
"Include exclusion areas.\n"
|
||||
"In those areas the travel of the tools\n"
|
||||
"is forbidden."
|
||||
)
|
||||
)
|
||||
self.grid5.addWidget(self.exclusion_cb, 17, 0, 1, 2)
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------
|
||||
# ------------------------- EXCLUSION AREAS ------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------------------------------------
|
||||
self.exclusion_frame = QtWidgets.QFrame()
|
||||
self.exclusion_frame.setContentsMargins(0, 0, 0, 0)
|
||||
self.grid5.addWidget(self.exclusion_frame, 18, 0, 1, 2)
|
||||
|
||||
self.exclusion_box = QtWidgets.QVBoxLayout()
|
||||
self.exclusion_box.setContentsMargins(0, 0, 0, 0)
|
||||
self.exclusion_frame.setLayout(self.exclusion_box)
|
||||
|
||||
h_lay = QtWidgets.QHBoxLayout()
|
||||
self.exclusion_box.addLayout(h_lay)
|
||||
|
||||
# Button Add Area
|
||||
self.add_area_button = QtWidgets.QPushButton(_('Add area'))
|
||||
self.add_area_button.setToolTip(_("Add an Exclusion Area."))
|
||||
h_lay.addWidget(self.add_area_button)
|
||||
|
||||
# Button Delete Area
|
||||
self.delete_area_button = QtWidgets.QPushButton(_('Clear areas'))
|
||||
self.delete_area_button.setToolTip(_("Delete all exclusion areas."))
|
||||
h_lay.addWidget(self.delete_area_button)
|
||||
|
||||
grid_l = QtWidgets.QGridLayout()
|
||||
grid_l.setColumnStretch(0, 0)
|
||||
grid_l.setColumnStretch(1, 1)
|
||||
self.exclusion_box.addLayout(grid_l)
|
||||
|
||||
# Area Selection shape
|
||||
self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
|
||||
self.area_shape_label.setToolTip(
|
||||
_("The kind of selection shape used for area selection.")
|
||||
)
|
||||
|
||||
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
|
||||
{'label': _("Polygon"), 'value': 'polygon'}])
|
||||
|
||||
grid_l.addWidget(self.area_shape_label, 0, 0)
|
||||
grid_l.addWidget(self.area_shape_radio, 0, 1)
|
||||
|
||||
# Chose Strategy
|
||||
self.strategy_label = FCLabel('%s:' % _("Strategy"))
|
||||
self.strategy_label.setToolTip(_("The strategy followed when encountering an exclusion area.\n"
|
||||
"Can be:\n"
|
||||
"- Over -> when encountering the area, the tool will go to a set height\n"
|
||||
"- Around -> will avoid the exclusion area by going around the area"))
|
||||
self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
|
||||
{'label': _('Around'), 'value': 'around'}])
|
||||
|
||||
grid_l.addWidget(self.strategy_label, 1, 0)
|
||||
grid_l.addWidget(self.strategy_radio, 1, 1)
|
||||
|
||||
# Over Z
|
||||
self.over_z_label = FCLabel('%s:' % _("Over Z"))
|
||||
self.over_z_label.setToolTip(_("The height Z to which the tool will rise in order to avoid\n"
|
||||
"an interdiction area."))
|
||||
self.over_z_entry = FCDoubleSpinner()
|
||||
self.over_z_entry.set_range(0.000, 9999.9999)
|
||||
self.over_z_entry.set_precision(self.decimals)
|
||||
|
||||
grid_l.addWidget(self.over_z_label, 2, 0)
|
||||
grid_l.addWidget(self.over_z_entry, 2, 1)
|
||||
|
||||
# -------------------------- EXCLUSION AREAS END -------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------------------------------------
|
||||
self.ois_exclusion_geo = OptionalHideInputSection(self.exclusion_cb, [self.exclusion_frame])
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
self.grid5.addWidget(separator_line, 17, 0, 1, 2)
|
||||
self.grid5.addWidget(separator_line, 19, 0, 1, 2)
|
||||
|
||||
# #################################################################
|
||||
# ################# GRID LAYOUT 6 ###############################
|
||||
@@ -2025,7 +2104,7 @@ class GeometryObjectUI(ObjectUI):
|
||||
# grid4.addWidget(QtWidgets.QLabel(''), 12, 0, 1, 2)
|
||||
|
||||
# Exclusion Areas
|
||||
self.exclusion_cb = FCCheckBox('%s:' % _("Exclusion areas"))
|
||||
self.exclusion_cb = FCCheckBox('%s' % _("Add exclusion areas"))
|
||||
self.exclusion_cb.setToolTip(
|
||||
_(
|
||||
"Include exclusion areas.\n"
|
||||
@@ -2046,35 +2125,29 @@ class GeometryObjectUI(ObjectUI):
|
||||
self.exclusion_box.setContentsMargins(0, 0, 0, 0)
|
||||
self.exclusion_frame.setLayout(self.exclusion_box)
|
||||
|
||||
h_lay = QtWidgets.QHBoxLayout()
|
||||
self.exclusion_box.addLayout(h_lay)
|
||||
self.exclusion_table = FCTable()
|
||||
self.exclusion_box.addWidget(self.exclusion_table)
|
||||
self.exclusion_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
|
||||
|
||||
# Button Add Area
|
||||
self.add_area_button = QtWidgets.QPushButton(_('Add area'))
|
||||
self.add_area_button.setToolTip(_("Add an Exclusion Area."))
|
||||
h_lay.addWidget(self.add_area_button)
|
||||
self.exclusion_table.setColumnCount(4)
|
||||
self.exclusion_table.setColumnWidth(0, 20)
|
||||
self.exclusion_table.setHorizontalHeaderLabels(['#', _('Object'), _('Strategy'), _('Over Z')])
|
||||
|
||||
# Button Delete Area
|
||||
self.delete_area_button = QtWidgets.QPushButton(_('Clear areas'))
|
||||
self.delete_area_button.setToolTip(_("Delete all exclusion areas."))
|
||||
h_lay.addWidget(self.delete_area_button)
|
||||
self.exclusion_table.horizontalHeaderItem(0).setToolTip(_("This is the Area ID."))
|
||||
self.exclusion_table.horizontalHeaderItem(1).setToolTip(
|
||||
_("Type of the object where the exclusion area was added."))
|
||||
self.exclusion_table.horizontalHeaderItem(2).setToolTip(
|
||||
_("The strategy used for exclusion area. Go around the exclusion areas or over it."))
|
||||
self.exclusion_table.horizontalHeaderItem(3).setToolTip(
|
||||
_("If the strategy is to go over the area then this is the height at which the tool will go to avoid the "
|
||||
"exclusion area."))
|
||||
|
||||
grid_l = QtWidgets.QGridLayout()
|
||||
grid_l.setColumnStretch(0, 0)
|
||||
grid_l.setColumnStretch(1, 1)
|
||||
self.exclusion_box.addLayout(grid_l)
|
||||
self.exclusion_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
|
||||
|
||||
# Area Selection shape
|
||||
self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
|
||||
self.area_shape_label.setToolTip(
|
||||
_("The kind of selection shape used for area selection.")
|
||||
)
|
||||
|
||||
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
|
||||
{'label': _("Polygon"), 'value': 'polygon'}])
|
||||
|
||||
grid_l.addWidget(self.area_shape_label, 0, 0)
|
||||
grid_l.addWidget(self.area_shape_radio, 0, 1)
|
||||
grid_a1 = QtWidgets.QGridLayout()
|
||||
grid_a1.setColumnStretch(0, 0)
|
||||
grid_a1.setColumnStretch(1, 1)
|
||||
self.exclusion_box.addLayout(grid_a1)
|
||||
|
||||
# Chose Strategy
|
||||
self.strategy_label = FCLabel('%s:' % _("Strategy"))
|
||||
@@ -2085,8 +2158,8 @@ class GeometryObjectUI(ObjectUI):
|
||||
self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
|
||||
{'label': _('Around'), 'value': 'around'}])
|
||||
|
||||
grid_l.addWidget(self.strategy_label, 1, 0)
|
||||
grid_l.addWidget(self.strategy_radio, 1, 1)
|
||||
grid_a1.addWidget(self.strategy_label, 1, 0)
|
||||
grid_a1.addWidget(self.strategy_radio, 1, 1)
|
||||
|
||||
# Over Z
|
||||
self.over_z_label = FCLabel('%s:' % _("Over Z"))
|
||||
@@ -2096,12 +2169,40 @@ class GeometryObjectUI(ObjectUI):
|
||||
self.over_z_entry.set_range(0.000, 9999.9999)
|
||||
self.over_z_entry.set_precision(self.decimals)
|
||||
|
||||
grid_l.addWidget(self.over_z_label, 2, 0)
|
||||
grid_l.addWidget(self.over_z_entry, 2, 1)
|
||||
grid_a1.addWidget(self.over_z_label, 2, 0)
|
||||
grid_a1.addWidget(self.over_z_entry, 2, 1)
|
||||
|
||||
# Button Add Area
|
||||
self.add_area_button = QtWidgets.QPushButton(_('Add area'))
|
||||
self.add_area_button.setToolTip(_("Add an Exclusion Area."))
|
||||
|
||||
# Area Selection shape
|
||||
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
|
||||
{'label': _("Polygon"), 'value': 'polygon'}])
|
||||
self.area_shape_radio.setToolTip(
|
||||
_("The kind of selection shape used for area selection.")
|
||||
)
|
||||
|
||||
grid_a1.addWidget(self.add_area_button, 4, 0)
|
||||
grid_a1.addWidget(self.area_shape_radio, 4, 1)
|
||||
|
||||
h_lay_1 = QtWidgets.QHBoxLayout()
|
||||
self.exclusion_box.addLayout(h_lay_1)
|
||||
|
||||
# Button Delete All Areas
|
||||
self.delete_area_button = QtWidgets.QPushButton(_('Clear areas'))
|
||||
self.delete_area_button.setToolTip(_("Delete all exclusion areas."))
|
||||
|
||||
# Button Delete Selected Areas
|
||||
self.delete_sel_area_button = QtWidgets.QPushButton(_('Delete Selected'))
|
||||
self.delete_sel_area_button.setToolTip(_("Delete all exclusion areas that are selected in the table."))
|
||||
|
||||
h_lay_1.addWidget(self.delete_area_button)
|
||||
h_lay_1.addWidget(self.delete_sel_area_button)
|
||||
|
||||
# -------------------------- EXCLUSION AREAS END -------------------------------------------------------------
|
||||
# ------------------------------------------------------------------------------------------------------------
|
||||
self.ois_exclusion_geo = OptionalInputSection(self.exclusion_cb, [self.exclusion_frame])
|
||||
self.ois_exclusion_geo = OptionalHideInputSection(self.exclusion_cb, [self.exclusion_frame])
|
||||
|
||||
warning_lbl = QtWidgets.QLabel(
|
||||
_(
|
||||
|
||||
@@ -287,6 +287,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
|
||||
def on_mouse_scroll(self, event):
|
||||
# key modifiers
|
||||
modifiers = event.modifiers
|
||||
|
||||
pan_delta_x = self.fcapp.defaults["global_gridx"]
|
||||
pan_delta_y = self.fcapp.defaults["global_gridy"]
|
||||
curr_pos = event.pos
|
||||
|
||||
@@ -714,7 +714,40 @@ class PreferencesUIManager:
|
||||
# make sure we update the self.current_defaults dict used to undo changes to self.defaults
|
||||
self.defaults.current_defaults.update(self.defaults)
|
||||
|
||||
if save_to_file:
|
||||
# deal with theme change
|
||||
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
|
||||
if theme_settings.contains("theme"):
|
||||
theme = theme_settings.value('theme', type=str)
|
||||
else:
|
||||
theme = 'white'
|
||||
|
||||
should_restart = False
|
||||
|
||||
val = self.get_form_field("global_theme").get_value()
|
||||
if val != theme:
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setText(_("Are you sure you want to continue?"))
|
||||
msgbox.setWindowTitle(_("Application restart"))
|
||||
msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/warning.png'))
|
||||
|
||||
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
|
||||
msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.NoRole)
|
||||
|
||||
msgbox.setDefaultButton(bt_yes)
|
||||
msgbox.exec_()
|
||||
response = msgbox.clickedButton()
|
||||
|
||||
if response == bt_yes:
|
||||
theme_settings.setValue('theme', val)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del theme_settings
|
||||
|
||||
should_restart = True
|
||||
else:
|
||||
self.ui.general_defaults_form.general_gui_group.theme_radio.set_value(theme)
|
||||
|
||||
if save_to_file or should_restart is True:
|
||||
self.save_defaults(silent=False)
|
||||
# load the defaults so they are updated into the app
|
||||
self.defaults.load(filename=os.path.join(self.data_path, 'current_defaults.FlatConfig'))
|
||||
@@ -752,6 +785,9 @@ class PreferencesUIManager:
|
||||
self.ui.plot_tab_area.closeTab(idx)
|
||||
break
|
||||
|
||||
if should_restart is True:
|
||||
self.ui.app.on_app_restart()
|
||||
|
||||
def on_pref_close_button(self):
|
||||
# Preferences saved, update flag
|
||||
self.preferences_changed_flag = False
|
||||
|
||||
@@ -25,8 +25,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI2):
|
||||
self.layout_field.activated.connect(self.on_layout)
|
||||
|
||||
self.theme_field = self.option_dict()["global_theme"].get_field()
|
||||
self.theme_apply_button = self.option_dict()["__button_apply_theme"].get_field()
|
||||
self.theme_apply_button.clicked.connect(self.on_theme_change)
|
||||
|
||||
self.style_field = self.option_dict()["style"].get_field()
|
||||
current_style_index = self.style_field.findText(QtWidgets.qApp.style().objectName(), QtCore.Qt.MatchFixedString)
|
||||
@@ -58,13 +56,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI2):
|
||||
label_text="Use Gray Icons",
|
||||
label_tooltip="Check this box to use a set of icons with\na lighter (gray) color. To be used when a\nfull dark theme is applied."
|
||||
),
|
||||
FullWidthButtonOptionUI(
|
||||
option="__button_apply_theme",
|
||||
label_text="Apply Theme",
|
||||
label_tooltip="Select a theme for FlatCAM.\n"
|
||||
"It will theme the plot area.\n"
|
||||
"The application will restart after change."
|
||||
),
|
||||
SeparatorOptionUI(),
|
||||
|
||||
ComboboxOptionUI(
|
||||
@@ -181,24 +172,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI2):
|
||||
),
|
||||
]
|
||||
|
||||
def on_theme_change(self):
|
||||
# FIXME: this should be moved out to a view model
|
||||
val = self.theme_field.get_value()
|
||||
|
||||
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
|
||||
if theme_settings.contains("theme"):
|
||||
theme = theme_settings.value('theme', type=str)
|
||||
else:
|
||||
theme = 'white'
|
||||
|
||||
if val != theme:
|
||||
theme_settings.setValue("theme", val)
|
||||
|
||||
# This will write the setting to the platform specific storage.
|
||||
del theme_settings
|
||||
|
||||
self.app.on_app_restart()
|
||||
|
||||
def on_layout(self, index=None, lay=None):
|
||||
if lay:
|
||||
current_layout = lay
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5.QtCore import QSettings
|
||||
|
||||
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, EvalEntry2
|
||||
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, FCEntry
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
|
||||
import gettext
|
||||
@@ -191,7 +191,7 @@ class ToolsTransformPrefGroupUI(OptionsGroupUI):
|
||||
"The 'x' in (x, y) will be used when using Flip on X and\n"
|
||||
"the 'y' in (x, y) will be used when using Flip on Y and")
|
||||
)
|
||||
self.flip_ref_entry = EvalEntry2("(0, 0)")
|
||||
self.flip_ref_entry = FCEntry()
|
||||
|
||||
grid0.addWidget(self.flip_ref_label, 14, 0, 1, 2)
|
||||
grid0.addWidget(self.flip_ref_entry, 15, 0, 1, 2)
|
||||
|
||||
Reference in New Issue
Block a user