- in Preferences General, Gerber, Geometry, Excellon, CNCJob sections made all the input fields of type SpinBox (where possible)

- updated the Distance Tool utility geometry color to adapt to the dark theme canvas
This commit is contained in:
Marius Stanciu 2019-10-08 05:25:27 +03:00 committed by Marius
parent 24723509f8
commit fbf982ab8e
4 changed files with 82 additions and 99 deletions

View File

@ -2114,6 +2114,9 @@ class App(QtCore.QObject):
# connect the abort_all_tasks related slots to the related signals
self.proc_container.idle_flag.connect(self.app_is_idle)
# signal emitted when a tab is closed in the Plot Area
self.ui.plot_tab_area.tab_closed_signal.connect(self.on_plot_area_tab_closed)
# #####################################################################################
# ########### FINISHED CONNECTING SIGNALS #############################################
# #####################################################################################
@ -2507,6 +2510,8 @@ class App(QtCore.QObject):
# Variable to store the GCODE that was edited
self.gcode_edited = ""
self.text_editor_tab = None
# reference for the self.ui.code_editor
self.reference_code_editor = None
self.script_code = ''
@ -7259,13 +7264,6 @@ class App(QtCore.QObject):
self.ui.plot_tab_area.setCurrentWidget(self.ui.preferences_tab)
# self.ui.show()
# this disconnect() is done so the slot will be connected only once
try:
self.ui.plot_tab_area.tab_closed_signal.disconnect(self.on_preferences_closed)
except (TypeError, AttributeError):
pass
self.ui.plot_tab_area.tab_closed_signal.connect(self.on_preferences_closed)
# detect changes in the preferences
for idx in range(self.ui.pref_tab_area.count()):
for tb in self.ui.pref_tab_area.widget(idx).findChildren(QtCore.QObject):
@ -7319,56 +7317,60 @@ class App(QtCore.QObject):
_("Preferences edited but not saved."))
self.preferences_changed_flag = True
def on_preferences_closed(self):
# disconnect
for idx in range(self.ui.pref_tab_area.count()):
for tb in self.ui.pref_tab_area.widget(idx).findChildren(QtCore.QObject):
try:
tb.textEdited.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
def on_plot_area_tab_closed(self, title):
if title == _("Preferences"):
# disconnect
for idx in range(self.ui.pref_tab_area.count()):
for tb in self.ui.pref_tab_area.widget(idx).findChildren(QtCore.QObject):
try:
tb.textEdited.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.modificationChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.modificationChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.toggled.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.toggled.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.valueChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.valueChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.currentIndexChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.currentIndexChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
if self.preferences_changed_flag is True:
msgbox = QtWidgets.QMessageBox()
msgbox.setText(_("One or more values are changed.\n"
"Do you want to save the Preferences?"))
msgbox.setWindowTitle(_("Save Preferences"))
msgbox.setWindowIcon(QtGui.QIcon('share/save_as.png'))
if self.preferences_changed_flag is True:
msgbox = QtWidgets.QMessageBox()
msgbox.setText(_("One or more values are changed.\n"
"Do you want to save the Preferences?"))
msgbox.setWindowTitle(_("Save Preferences"))
msgbox.setWindowIcon(QtGui.QIcon('share/save_as.png'))
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
if response == bt_yes:
self.on_save_button()
self.inform.emit('[success] %s' %
_("Preferences saved."))
else:
self.preferences_changed_flag = False
return
if response == bt_yes:
self.on_save_button()
self.inform.emit('[success] %s' %
_("Preferences saved."))
else:
self.preferences_changed_flag = False
return
if title == _("Code Editor"):
self.toggle_codeeditor = False
def on_flipy(self):
self.report_usage("on_flipy()")
@ -9226,28 +9228,28 @@ class App(QtCore.QObject):
def init_code_editor(self, name):
self.ui.text_editor_tab = TextEditor(app=self)
self.text_editor_tab = TextEditor(app=self)
# add the tab if it was closed
self.ui.plot_tab_area.addTab(self.ui.text_editor_tab, '%s' % name)
self.ui.text_editor_tab.setObjectName('text_editor_tab')
self.ui.plot_tab_area.addTab(self.text_editor_tab, '%s' % name)
self.text_editor_tab.setObjectName('text_editor_tab')
# delete the absolute and relative position and messages in the infobar
self.ui.position_label.setText("")
self.ui.rel_position_label.setText("")
# first clear previous text in text editor (if any)
self.ui.text_editor_tab.code_editor.clear()
self.ui.text_editor_tab.code_editor.setReadOnly(False)
self.text_editor_tab.code_editor.clear()
self.text_editor_tab.code_editor.setReadOnly(False)
self.toggle_codeeditor = True
self.ui.text_editor_tab.code_editor.completer_enable = False
self.ui.text_editor_tab.buttonRun.hide()
self.text_editor_tab.code_editor.completer_enable = False
self.text_editor_tab.buttonRun.hide()
# make sure to keep a reference to the code editor
self.reference_code_editor = self.ui.text_editor_tab.code_editor
self.reference_code_editor = self.text_editor_tab.code_editor
# Switch plot_area to CNCJob tab
self.ui.plot_tab_area.setCurrentWidget(self.ui.text_editor_tab)
self.ui.plot_tab_area.setCurrentWidget(self.text_editor_tab)
def on_view_source(self):
self.inform.emit('%s' %
@ -9341,10 +9343,11 @@ class App(QtCore.QObject):
if self.toggle_codeeditor is False:
self.init_code_editor(name=_("Code Editor"))
self.ui.text_editor_tab.buttonOpen.clicked.disconnect()
self.ui.text_editor_tab.buttonOpen.clicked.connect(lambda: self.ui.text_editor_tab.handleOpen())
self.ui.text_editor_tab.buttonSave.clicked.disconnect()
self.ui.text_editor_tab.buttonSave.clicked.connect(lambda: self.ui.text_editor_tab.handleSaveGCode())
self.text_editor_tab.buttonOpen.clicked.disconnect()
self.text_editor_tab.buttonOpen.clicked.connect(self.text_editor_tab.handleOpen)
self.text_editor_tab.buttonSave.clicked.disconnect()
self.text_editor_tab.buttonSave.clicked.connect(self.text_editor_tab.handleSaveGCode)
else:
for idx in range(self.ui.plot_tab_area.count()):
if self.ui.plot_tab_area.widget(idx).objectName() == "text_editor_tab":
@ -9352,6 +9355,10 @@ class App(QtCore.QObject):
break
self.toggle_codeeditor = False
def on_code_editor_close(self):
print("closed")
self.toggle_codeeditor = False
def on_filenewscript(self, silent=False, name=None, text=None):
"""
Will create a new script file and open it in the Code Editor
@ -11728,6 +11735,16 @@ class App(QtCore.QObject):
except Exception as e:
traceback.print_exc()
def on_plotarea_tab_closed(self, tab_idx):
widget = self.ui.plot_tab_area.widget(tab_idx)
if widget is not None:
print(widget.objectName())
if widget.objectName() == 'text_editor_tab':
print("aha")
widget.deleteLater()
self.ui.plot_tab_area.removeTab(tab_idx)
def on_options_app2project(self):
"""
Callback for Options->Transfer Options->App=>Project. Copies options

View File

@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
- modified the FCSpinner and FCDoubleSpinner GUI elements such that the wheel event will not change the values inside unless there is a focus in the lineedit of the SpinBox
- in Preferences General, Gerber, Geometry, Excellon, CNCJob sections made all the input fields of type SpinBox (where possible)
- updated the Distance Tool utility geometry color to adapt to the dark theme canvas
- Toggle Code Editor now works as expected even when the user is closing the Editor tab and not using the command Toggle Code Editor
7.10.2019

View File

@ -264,37 +264,4 @@ class TextEditor(QtWidgets.QWidget):
self.app.inform.emit(_("Code Editor content copied to clipboard ..."))
# def closeEvent(self, QCloseEvent):
# try:
# self.code_editor.textChanged.disconnect()
# except TypeError:
# pass
# try:
# self.buttonOpen.clicked.disconnect()
# except TypeError:
# pass
# try:
# self.buttonPrint.clicked.disconnect()
# except TypeError:
# pass
# try:
# self.buttonPreview.clicked.disconnect()
# except TypeError:
# pass
# try:
# self.buttonFind.clicked.disconnect()
# except TypeError:
# pass
# try:
# self.buttonReplace.clicked.disconnect()
# except TypeError:
# pass
# try:
# self.button_copy_all.clicked.disconnect()
# except TypeError:
# pass
# try:
# self.buttonRun.clicked.disconnect()
# except TypeError:
# pass
#
# super().closeEvent(QCloseEvent)

View File

@ -1538,7 +1538,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
class FCDetachableTab2(FCDetachableTab):
tab_closed_signal = pyqtSignal()
tab_closed_signal = pyqtSignal(object)
def __init__(self, protect=None, protect_by_name=None, parent=None):
super(FCDetachableTab2, self).__init__(protect=protect, protect_by_name=protect_by_name, parent=parent)
@ -1552,9 +1552,7 @@ class FCDetachableTab2(FCDetachableTab):
"""
idx = self.currentIndex()
# emit the signal only if the name is the one we want; the name should be a parameter somehow
if self.tabText(idx) == _("Preferences"):
self.tab_closed_signal.emit()
self.tab_closed_signal.emit(self.tabText(idx))
self.removeTab(currentIndex)