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

View File

@ -264,37 +264,4 @@ class TextEditor(QtWidgets.QWidget):
self.app.inform.emit(_("Code Editor content copied to clipboard ...")) self.app.inform.emit(_("Code Editor content copied to clipboard ..."))
# def closeEvent(self, QCloseEvent): # 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) # super().closeEvent(QCloseEvent)

View File

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