- made optional the saving of an edited object. Now the user can cancel the changes to the object.

- replaced the standard buttons in the QMessageBox's used in the app with custom ones that can have text translated
- updated the POT translation file and the MO/PO files for English and Romanian language
This commit is contained in:
Marius Stanciu 2019-04-12 22:55:20 +03:00
parent 57e8db1f9b
commit a1f7c86996
12 changed files with 6053 additions and 4740 deletions

View File

@ -2086,16 +2086,18 @@ class App(QtCore.QObject):
"""
self.report_usage("object2editor()")
# adjust the visibility of some of the canvas context menu
self.ui.popmenu_edit.setVisible(False)
self.ui.popmenu_save.setVisible(True)
# adjust the status of the menu entries related to the editor
self.ui.menueditedit.setDisabled(True)
self.ui.menueditok.setDisabled(False)
edited_object = self.collection.get_active()
if isinstance(edited_object, FlatCAMGerber) or isinstance(edited_object, FlatCAMGeometry) or \
isinstance(edited_object, FlatCAMExcellon):
# adjust the status of the menu entries related to the editor
self.ui.menueditedit.setDisabled(True)
self.ui.menueditok.setDisabled(False)
else:
self.inform.emit(_("[WARNING_NOTCL] Select a Geometry or Excellon Object to edit."))
return
if isinstance(edited_object, FlatCAMGeometry):
# store the Geometry Editor Toolbar visibility before entering in the Editor
self.geo_editor.toolbar_old_state = True if self.ui.geo_edit_toolbar.isVisible() else False
@ -2131,10 +2133,6 @@ class App(QtCore.QObject):
# set call source to the Editor we go into
self.call_source = 'grb_editor'
else:
self.inform.emit(_("[WARNING_NOTCL] Select a Geometry or Excellon Object to edit."))
return
# make sure that we can't select another object while in Editor Mode:
self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
@ -2168,60 +2166,96 @@ class App(QtCore.QObject):
edited_obj = self.collection.get_active()
obj_type = ""
if isinstance(edited_obj, FlatCAMGeometry):
obj_type = "Geometry"
if cleanup is None:
self.geo_editor.update_fcgeometry(edited_obj)
self.geo_editor.update_options(edited_obj)
self.geo_editor.deactivate()
if cleanup is None:
msgbox = QtWidgets.QMessageBox()
msgbox.setText(_("Do you want to save the edited object?"))
msgbox.setWindowTitle(_("Close Editor"))
msgbox.setWindowIcon(QtGui.QIcon('share/save_as.png'))
# update the geo object options so it is including the bounding box values
try:
xmin, ymin, xmax, ymax = edited_obj.bounds()
edited_obj.options['xmin'] = xmin
edited_obj.options['ymin'] = ymin
edited_obj.options['xmax'] = xmax
edited_obj.options['ymax'] = ymax
except AttributeError as e:
self.inform.emit(_("[WARNING] Object empty after edit."))
log. debug("App.editor2object() --> Geometry --> %s" % str(e))
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole)
elif isinstance(edited_obj, FlatCAMGerber):
new_obj = self.collection.get_active()
obj_type = "Gerber"
if cleanup is None:
self.grb_editor.update_fcgerber(edited_obj)
self.grb_editor.update_options(new_obj)
self.grb_editor.deactivate_grb_editor()
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
# delete the old object (the source object) if it was an empty one
if edited_obj.solid_geometry.is_empty:
old_name = edited_obj.options['name']
self.collection.set_active(old_name)
self.collection.delete_active()
else:
# update the geo object options so it is including the bounding box values
# but don't do this for objects that are made out of empty source objects, it will fail
try:
xmin, ymin, xmax, ymax = new_obj.bounds()
new_obj.options['xmin'] = xmin
new_obj.options['ymin'] = ymin
new_obj.options['xmax'] = xmax
new_obj.options['ymax'] = ymax
except Exception as e:
self.inform.emit(_("[WARNING] Object empty after edit."))
log.debug("App.editor2object() --> Gerber --> %s" % str(e))
if response == bt_yes:
if isinstance(edited_obj, FlatCAMGeometry):
obj_type = "Geometry"
if cleanup is None:
self.geo_editor.update_fcgeometry(edited_obj)
self.geo_editor.update_options(edited_obj)
self.geo_editor.deactivate()
elif isinstance(edited_obj, FlatCAMExcellon):
obj_type = "Excellon"
if cleanup is None:
self.exc_editor.update_fcexcellon(edited_obj)
self.exc_editor.update_options(edited_obj)
self.exc_editor.deactivate()
# update the geo object options so it is including the bounding box values
try:
xmin, ymin, xmax, ymax = edited_obj.bounds()
edited_obj.options['xmin'] = xmin
edited_obj.options['ymin'] = ymin
edited_obj.options['xmax'] = xmax
edited_obj.options['ymax'] = ymax
except AttributeError as e:
self.inform.emit(_("[WARNING] Object empty after edit."))
log.debug("App.editor2object() --> Geometry --> %s" % str(e))
elif isinstance(edited_obj, FlatCAMGerber):
new_obj = self.collection.get_active()
obj_type = "Gerber"
if cleanup is None:
self.grb_editor.update_fcgerber(edited_obj)
self.grb_editor.update_options(new_obj)
self.grb_editor.deactivate_grb_editor()
# delete the old object (the source object) if it was an empty one
if edited_obj.solid_geometry.is_empty:
old_name = edited_obj.options['name']
self.collection.set_active(old_name)
self.collection.delete_active()
else:
# update the geo object options so it is including the bounding box values
# but don't do this for objects that are made out of empty source objects, it will fail
try:
xmin, ymin, xmax, ymax = new_obj.bounds()
new_obj.options['xmin'] = xmin
new_obj.options['ymin'] = ymin
new_obj.options['xmax'] = xmax
new_obj.options['ymax'] = ymax
except Exception as e:
self.inform.emit(_("[WARNING] Object empty after edit."))
log.debug("App.editor2object() --> Gerber --> %s" % str(e))
elif isinstance(edited_obj, FlatCAMExcellon):
obj_type = "Excellon"
if cleanup is None:
self.exc_editor.update_fcexcellon(edited_obj)
self.exc_editor.update_options(edited_obj)
self.exc_editor.deactivate()
else:
self.inform.emit(_("[WARNING_NOTCL] Select a Gerber, Geometry or Excellon Object to update."))
return
self.inform.emit(_("[selected] %s is updated, returning to App...") % obj_type)
elif response == bt_no:
if isinstance(edited_obj, FlatCAMGeometry):
self.geo_editor.deactivate()
elif isinstance(edited_obj, FlatCAMGerber):
self.grb_editor.deactivate_grb_editor()
elif isinstance(edited_obj, FlatCAMExcellon):
self.exc_editor.deactivate()
else:
self.inform.emit(_("[WARNING_NOTCL] Select a Gerber, Geometry or Excellon Object to update."))
return
elif response == bt_cancel:
return
else:
self.inform.emit(_("[WARNING_NOTCL] Select a Gerber, Geometry or Excellon Object to update."))
return
if isinstance(edited_obj, FlatCAMGeometry):
self.geo_editor.deactivate()
elif isinstance(edited_obj, FlatCAMGerber):
self.grb_editor.deactivate_grb_editor()
elif isinstance(edited_obj, FlatCAMExcellon):
self.exc_editor.deactivate()
else:
self.inform.emit(_("[WARNING_NOTCL] Select a Gerber, Geometry or Excellon Object to update."))
return
# if notebook is hidden we show it
if self.ui.splitter.sizes()[0] == 0:
@ -2233,11 +2267,7 @@ class App(QtCore.QObject):
edited_obj.plot()
self.ui.plot_tab_area.setTabText(0, "Plot Area")
self.ui.plot_tab_area.protectTab(0)
self.inform.emit(_("[selected] %s is updated, returning to App...") % obj_type)
# reset the Object UI to original settings
# edited_obj.set_ui(edited_obj.ui_type())
# edited_obj.build_ui()
# make sure that we reenable the selection on Project Tab after returning from Editor Mode:
self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
@ -3222,17 +3252,19 @@ class App(QtCore.QObject):
"Do you want to Save the project?"))
msgbox.setWindowTitle(_("Save changes"))
msgbox.setWindowIcon(QtGui.QIcon('share/save_as.png'))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No |
QtWidgets.QMessageBox.Cancel)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Yes)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole)
response = msgbox.exec_()
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
if response == QtWidgets.QMessageBox.Yes:
if response == bt_yes:
self.on_file_saveprojectas(thread=True, quit=True)
elif response == QtWidgets.QMessageBox.No:
elif response == bt_no:
self.quit_application()
elif response == QtWidgets.QMessageBox.Cancel:
elif response == bt_cancel:
return
else:
self.quit_application()
@ -3553,12 +3585,14 @@ class App(QtCore.QObject):
msgbox.setText("<B>Change project units ...</B>")
msgbox.setInformativeText("Changing the units of the project causes all geometrical "
"properties of all objects to be scaled accordingly.\nContinue?")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole)
response = msgbox.exec_()
msgbox.setDefaultButton(bt_ok)
msgbox.exec_()
response = msgbox.clickedButton()
if response == QtWidgets.QMessageBox.Ok:
if response == bt_ok:
self.options_read_form()
scale_options(factor)
self.options_write_form()
@ -4316,8 +4350,9 @@ class App(QtCore.QObject):
"Go to Preferences -> General - Show Advanced Options."))
msgbox.setWindowTitle("Tool adding ...")
msgbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
msgbox.setDefaultButton(bt_ok)
msgbox.exec_()
# work only if the notebook tab on focus is the Tools_Tab
@ -5526,17 +5561,20 @@ class App(QtCore.QObject):
"Do you want to Save the project?"))
msgbox.setWindowTitle(_("Save changes"))
msgbox.setWindowIcon(QtGui.QIcon('share/save_as.png'))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole)
response = msgbox.exec_()
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
if response == QtWidgets.QMessageBox.Yes:
if response == bt_yes:
self.on_file_saveprojectas()
elif response == QtWidgets.QMessageBox.Cancel:
elif response == bt_cancel:
return
self.on_file_new()
elif response == bt_no:
self.on_file_new()
else:
self.on_file_new()
self.inform.emit(_("[success] New Project created..."))
@ -5788,8 +5826,8 @@ class App(QtCore.QObject):
msg = _("Please Select a Geometry object to export")
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText(msg)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
msgbox.setDefaultButton(bt_ok)
msgbox.exec_()
return
@ -5799,8 +5837,8 @@ class App(QtCore.QObject):
msg = _("[ERROR_NOTCL] Only Geometry, Gerber and CNCJob objects can be used.")
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText(msg)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
msgbox.setDefaultButton(bt_ok)
msgbox.exec_()
return
@ -5985,8 +6023,8 @@ class App(QtCore.QObject):
msg = _("Please Select a Geometry object to export")
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText(msg)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
msgbox.setDefaultButton(bt_ok)
msgbox.exec_()
return
@ -5995,9 +6033,10 @@ class App(QtCore.QObject):
msg = _("[ERROR_NOTCL] Only Geometry objects can be used.")
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText(msg)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
msgbox.setDefaultButton(bt_ok)
msgbox.exec_()
return
name = self.collection.get_active().options["name"]

View File

@ -86,12 +86,14 @@ def on_language_apply_click(app, restart=False):
msgbox.setInformativeText("Are you sure do you want to change the current language to %s?" % name.capitalize())
msgbox.setWindowTitle("Apply Language ...")
msgbox.setWindowIcon(QtGui.QIcon('share/language32.png'))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel)
msgbox.setDefaultButton(QtWidgets.QMessageBox.Yes)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
response = msgbox.exec_()
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
if response == QtWidgets.QMessageBox.Cancel:
if response == bt_no:
return
else:
settings = QSettings("Open Source", "FlatCAM")

View File

@ -23,6 +23,9 @@ CAD program, and create G-Code for Isolation routing.
- when adding an aperture with code '0' (zero) it will automatically be set with size zero and type: 'REG' (from region); here we store all the regions from a Gerber file, the ones without a declared aperture
- Gerber Editor: added support for Gerber polarity change commands (LPD, LPC)
- moved the polarity change processing from FlatCAMGrbEditor() class to camlib.Gerber().parse_lines()
- made optional the saving of an edited object. Now the user can cancel the changes to the object.
- replaced the standard buttons in the QMessageBox's used in the app with custom ones that can have text translated
- updated the POT translation file and the MO/PO files for English and Romanian language
11.04.2019

View File

@ -1604,6 +1604,10 @@ class FlatCAMExcEditor(QtCore.QObject):
if self.app.ui.grid_snap_btn.isChecked() is False:
self.app.ui.grid_snap_btn.trigger()
# adjust the visibility of some of the canvas context menu
self.app.ui.popmenu_edit.setVisible(False)
self.app.ui.popmenu_save.setVisible(True)
# Tell the App that the editor is active
self.editor_active = True
@ -1657,6 +1661,10 @@ class FlatCAMExcEditor(QtCore.QObject):
self.app.ui.g_editor_cmenu.setEnabled(False)
self.app.ui.e_editor_cmenu.setEnabled(False)
# adjust the visibility of some of the canvas context menu
self.app.ui.popmenu_edit.setVisible(True)
self.app.ui.popmenu_save.setVisible(False)
# Show original geometry
if self.exc_obj:
self.exc_obj.visible = True

View File

@ -2864,6 +2864,10 @@ class FlatCAMGeoEditor(QtCore.QObject):
for w in sel_tab_widget_list:
w.setEnabled(False)
# adjust the visibility of some of the canvas context menu
self.app.ui.popmenu_edit.setVisible(False)
self.app.ui.popmenu_save.setVisible(True)
# Tell the App that the editor is active
self.editor_active = True
@ -2915,6 +2919,18 @@ class FlatCAMGeoEditor(QtCore.QObject):
# Tell the app that the editor is no longer active
self.editor_active = False
# adjust the visibility of some of the canvas context menu
self.app.ui.popmenu_edit.setVisible(True)
self.app.ui.popmenu_save.setVisible(False)
try:
# re-enable all the widgets in the Selected Tab that were disabled after entering in Edit Geometry Mode
sel_tab_widget_list = self.app.ui.selected_tab.findChildren(QtWidgets.QWidget)
for w in sel_tab_widget_list:
w.setEnabled(True)
except Exception as e:
log.debug("FlatCAMGeoEditor.deactivate() --> %s" % str(e))
# Show original geometry
if self.fcgeometry:
self.fcgeometry.visible = True
@ -3637,11 +3653,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
for shape in self.storage.get_objects():
fcgeometry.solid_geometry.append(shape.geo)
# re-enable all the widgets in the Selected Tab that were disabled after entering in Edit Geometry Mode
sel_tab_widget_list = self.app.ui.selected_tab.findChildren(QtWidgets.QWidget)
for w in sel_tab_widget_list:
w.setEnabled(True)
def update_options(self, obj):
if self.paint_tooldia:
obj.options['cnctooldia'] = self.paint_tooldia

View File

@ -1767,6 +1767,10 @@ class FlatCAMGrbEditor(QtCore.QObject):
if self.app.ui.grid_snap_btn.isChecked() is False:
self.app.ui.grid_snap_btn.trigger()
# adjust the visibility of some of the canvas context menu
self.app.ui.popmenu_edit.setVisible(False)
self.app.ui.popmenu_save.setVisible(True)
# Tell the App that the editor is active
self.editor_active = True
@ -1821,6 +1825,10 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.app.ui.grb_editor_cmenu.setEnabled(False)
self.app.ui.e_editor_cmenu.setEnabled(False)
# adjust the visibility of some of the canvas context menu
self.app.ui.popmenu_edit.setVisible(True)
self.app.ui.popmenu_save.setVisible(False)
# Show original geometry
if self.gerber_obj:
self.gerber_obj.visible = True

View File

@ -223,7 +223,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# Separator
self.menuedit.addSeparator()
self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), _('Edit Object\tE'))
self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), _('Save && Close Editor\tCTRL+S'))
self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), _('Close Editor\tCTRL+S'))
# adjust the initial state of the menu entries related to the editor
self.menueditedit.setDisabled(False)
@ -1546,7 +1546,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), _("Delete"))
self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), _("Edit"))
self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), _("Save && Close Edit"))
self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), _("Close Editor"))
self.popmenu_save.setVisible(False)
self.popMenu.addSeparator()
@ -3534,18 +3534,19 @@ class GeneralGUISetGroupUI(OptionsGroupUI):
def handle_clear(self):
msgbox = QtWidgets.QMessageBox()
# msgbox.setText("<B>Save changes ...</B>")
msgbox.setText(_("Are you sure you want to delete the GUI Settings? "
"\n")
)
msgbox.setWindowTitle(_("Clear GUI Settings"))
msgbox.setWindowIcon(QtGui.QIcon('share/trash32.png'))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
msgbox.setDefaultButton(QtWidgets.QMessageBox.No)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
response = msgbox.exec_()
msgbox.setDefaultButton(bt_no)
msgbox.exec_()
response = msgbox.clickedButton()
if response == QtWidgets.QMessageBox.Yes:
if response == bt_yes:
settings = QSettings("Open Source", "FlatCAM")
for key in settings.allKeys():
settings.remove(key)

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff