- reworked the offer to save a project so it is done only if there are objects in the project but those objects are new and/or are modified since last project load (if an old project was loaded.)
This commit is contained in:
parent
e717cb8f15
commit
367d6f3155
@ -111,6 +111,10 @@ class App(QtCore.QObject):
|
||||
|
||||
should_we_quit = True
|
||||
|
||||
# this variable will hold the project status
|
||||
# if True it will mean that the project was modified and not saved
|
||||
should_we_save = False
|
||||
|
||||
##################
|
||||
## Signals ##
|
||||
##################
|
||||
@ -1651,6 +1655,8 @@ class App(QtCore.QObject):
|
||||
self.ui.plot_tab_area.protectTab(0)
|
||||
self.inform.emit("[WARNING_NOTCL]Editor is activated ...")
|
||||
|
||||
self.should_we_save = True
|
||||
|
||||
def editor2object(self):
|
||||
"""
|
||||
Transfers the Geometry or Excellon from the editor to the current object.
|
||||
@ -2643,10 +2649,10 @@ class App(QtCore.QObject):
|
||||
self.inform.emit("Factory defaults saved.")
|
||||
|
||||
def final_save(self):
|
||||
if self.collection.get_list():
|
||||
if self.should_we_save and self.collection.get_list():
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
# msgbox.setText("<B>Save changes ...</B>")
|
||||
msgbox.setText("There are files/objects opened in FlatCAM. "
|
||||
msgbox.setText("There are files/objects modified in FlatCAM. "
|
||||
"\n"
|
||||
"Do you want to Save the project?")
|
||||
msgbox.setWindowTitle("Save changes")
|
||||
@ -4626,7 +4632,7 @@ class App(QtCore.QObject):
|
||||
layer=0, tolerance=None)
|
||||
|
||||
def on_file_new_click(self):
|
||||
if self.collection.get_list():
|
||||
if self.collection.get_list() and self.should_we_save:
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
# msgbox.setText("<B>Save changes ...</B>")
|
||||
msgbox.setText("There are files/objects opened in FlatCAM.\n"
|
||||
@ -5161,6 +5167,8 @@ class App(QtCore.QObject):
|
||||
|
||||
self.file_saved.emit("project", self.project_filename)
|
||||
|
||||
self.should_we_save = False
|
||||
|
||||
def on_file_saveprojectas(self, make_copy=False, thread=True):
|
||||
"""
|
||||
Callback for menu item File->Save Project As... Opens a file
|
||||
@ -5194,7 +5202,7 @@ class App(QtCore.QObject):
|
||||
except IOError:
|
||||
exists = False
|
||||
|
||||
msg = "File exists. Overwrite?"
|
||||
msg = "Project file exists. Overwrite?"
|
||||
if exists:
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setInformativeText(msg)
|
||||
@ -5217,6 +5225,8 @@ class App(QtCore.QObject):
|
||||
if not make_copy:
|
||||
self.project_filename = filename
|
||||
|
||||
self.should_we_save = False
|
||||
|
||||
def export_svg(self, obj_name, filename, scale_factor=0.00):
|
||||
"""
|
||||
Exports a Geometry Object to an SVG file.
|
||||
@ -6083,6 +6093,9 @@ class App(QtCore.QObject):
|
||||
|
||||
# self.plot_all()
|
||||
self.inform.emit("[success] Project loaded from: " + filename)
|
||||
|
||||
self.should_we_save = False
|
||||
|
||||
App.log.debug("Project loaded")
|
||||
|
||||
def propagate_defaults(self, silent=False):
|
||||
|
@ -3632,28 +3632,6 @@ class ExcellonExpPrefGroupUI(OptionsGroupUI):
|
||||
|
||||
form.addRow(self.excellon_units_label, self.excellon_units_radio)
|
||||
|
||||
# Select the Excellon Format
|
||||
self.format_label = QtWidgets.QLabel("<b>Format:</b>")
|
||||
self.format_label.setToolTip(
|
||||
"Select the kind of coordinates format used.\n"
|
||||
"Coordinates can be saved with decimal point or without.\n"
|
||||
"When there is no decimal point, it is required to specify\n"
|
||||
"the number of digits for integer part and the number of decimals.\n"
|
||||
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
||||
"or TZ = trailing zeros are kept."
|
||||
)
|
||||
self.format_radio = RadioSet([{'label': 'Decimal', 'value': 'dec'}, {'label': 'No-Decimal', 'value': 'ndec'}])
|
||||
self.format_radio.setToolTip(
|
||||
"Select the kind of coordinates format used.\n"
|
||||
"Coordinates can be saved with decimal point or without.\n"
|
||||
"When there is no decimal point, it is required to specify\n"
|
||||
"the number of digits for integer part and the number of decimals.\n"
|
||||
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
||||
"or TZ = trailing zeros are kept."
|
||||
)
|
||||
|
||||
form.addRow(self.format_label, self.format_radio)
|
||||
|
||||
# Excellon non-decimal format
|
||||
self.digits_label = QtWidgets.QLabel("<b>Int/Decimals:</b>")
|
||||
self.digits_label.setToolTip(
|
||||
@ -3692,6 +3670,28 @@ class ExcellonExpPrefGroupUI(OptionsGroupUI):
|
||||
|
||||
form.addRow(self.digits_label, hlay1)
|
||||
|
||||
# Select the Excellon Format
|
||||
self.format_label = QtWidgets.QLabel("<b>Format:</b>")
|
||||
self.format_label.setToolTip(
|
||||
"Select the kind of coordinates format used.\n"
|
||||
"Coordinates can be saved with decimal point or without.\n"
|
||||
"When there is no decimal point, it is required to specify\n"
|
||||
"the number of digits for integer part and the number of decimals.\n"
|
||||
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
||||
"or TZ = trailing zeros are kept."
|
||||
)
|
||||
self.format_radio = RadioSet([{'label': 'Decimal', 'value': 'dec'}, {'label': 'No-Decimal', 'value': 'ndec'}])
|
||||
self.format_radio.setToolTip(
|
||||
"Select the kind of coordinates format used.\n"
|
||||
"Coordinates can be saved with decimal point or without.\n"
|
||||
"When there is no decimal point, it is required to specify\n"
|
||||
"the number of digits for integer part and the number of decimals.\n"
|
||||
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
||||
"or TZ = trailing zeros are kept."
|
||||
)
|
||||
|
||||
form.addRow(self.format_label, self.format_radio)
|
||||
|
||||
# Excellon Zeros
|
||||
self.zeros_label = QtWidgets.QLabel('<b>Zeros</b>:')
|
||||
self.zeros_label.setAlignment(QtCore.Qt.AlignLeft)
|
||||
@ -3720,13 +3720,9 @@ class ExcellonExpPrefGroupUI(OptionsGroupUI):
|
||||
|
||||
def optimization_selection(self):
|
||||
if self.format_radio.get_value() == 'dec':
|
||||
self.digits_label.setDisabled(True)
|
||||
|
||||
self.zeros_label.setDisabled(True)
|
||||
self.zeros_radio.setDisabled(True)
|
||||
else:
|
||||
self.digits_label.setDisabled(False)
|
||||
|
||||
self.zeros_label.setDisabled(False)
|
||||
self.zeros_radio.setDisabled(False)
|
||||
|
||||
|
@ -679,6 +679,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
if group.child_count() is 1:
|
||||
self.view.setExpanded(group_index, True)
|
||||
|
||||
self.app.should_we_save = True
|
||||
|
||||
# decide if to show or hide the Notebook side of the screen
|
||||
if self.app.defaults["global_project_autohide"] is True:
|
||||
# always open the notebook on object added to collection
|
||||
@ -776,6 +778,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# always go to the Project Tab after object deletion as it may be done with a shortcut key
|
||||
self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab)
|
||||
|
||||
self.app.should_we_save = True
|
||||
|
||||
# decide if to show or hide the Notebook side of the screen
|
||||
if self.app.defaults["global_project_autohide"] is True:
|
||||
# hide the notebook if there are no objects in the collection
|
||||
|
@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||
- started to work in using the Excellon Export parameters
|
||||
- remade the Excellon export function to work with parameters entered in Edit -> Preferences -> Excellon Export
|
||||
- added a new entry in the Project Context Menu named 'Save'. It will actually work for Geometry and it will do Export DXF and for Excellon and it will do Export Excellon
|
||||
- reworked the offer to save a project so it is done only if there are objects in the project but those objects are new and/or are modified since last project load (if an old project was loaded.)
|
||||
|
||||
14.02.2019
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user