- updated code in self.on_view_source() to make it more responsive
This commit is contained in:
parent
462e3ac2ec
commit
e7493a350f
@ -7799,8 +7799,15 @@ class App(QtCore.QObject):
|
||||
def init_code_editor(self, name):
|
||||
# Signals section
|
||||
# Disconnect the old signals
|
||||
try:
|
||||
self.ui.buttonOpen.clicked.disconnect()
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.ui.buttonSave.clicked.disconnect()
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# add the tab if it was closed
|
||||
self.ui.plot_tab_area.addTab(self.ui.cncjob_tab, _('%s') % name)
|
||||
@ -7820,13 +7827,27 @@ class App(QtCore.QObject):
|
||||
self.ui.plot_tab_area.setCurrentWidget(self.ui.cncjob_tab)
|
||||
|
||||
def on_view_source(self):
|
||||
self.inform.emit('%s' %
|
||||
_("Viewing the source code of the selected object."))
|
||||
self.proc_container.view.set_busy(_("Loading..."))
|
||||
|
||||
try:
|
||||
obj = self.collection.get_active()
|
||||
except:
|
||||
except Exception as e:
|
||||
log.debug("App.on_view_source() --> %s" % str(e))
|
||||
self.inform.emit('[WARNING_NOTCL] %s' %
|
||||
_("Select an Gerber or Excellon file to view it's source file."))
|
||||
return 'fail'
|
||||
|
||||
if obj.kind == 'gerber':
|
||||
flt = "Gerber Files (*.GBR);;All Files (*.*)"
|
||||
else:
|
||||
flt = "Excellon Files (*.DRL);;All Files (*.*)"
|
||||
|
||||
self.init_code_editor(name=_("Source Editor"))
|
||||
self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt))
|
||||
self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt))
|
||||
|
||||
# then append the text from GCode to the text editor
|
||||
try:
|
||||
file = StringIO(obj.source_file)
|
||||
@ -7835,29 +7856,24 @@ class App(QtCore.QObject):
|
||||
_("There is no selected object for which to see it's source file code."))
|
||||
return 'fail'
|
||||
|
||||
if obj.kind == 'gerber':
|
||||
flt = "Gerber Files (*.GBR);;All Files (*.*)"
|
||||
elif obj.kind == 'excellon':
|
||||
flt = "Excellon Files (*.DRL);;All Files (*.*)"
|
||||
|
||||
self.init_code_editor(name=_("Source Editor"))
|
||||
self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt))
|
||||
self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt))
|
||||
|
||||
self.ui.cncjob_frame.hide()
|
||||
try:
|
||||
for line in file:
|
||||
QtWidgets.QApplication.processEvents()
|
||||
proc_line = str(line).strip('\n')
|
||||
self.ui.code_editor.append(proc_line)
|
||||
except Exception as e:
|
||||
log.debug('App.on_view_source() -->%s' % str(e))
|
||||
self.inform.emit('[ERROR] %s %s' %
|
||||
(_('App.on_view_source() -->'), str(e)))
|
||||
self.inform.emit('[ERROR] %s: %s' %
|
||||
(_('Failed to load the source code for the selected object'), str(e)))
|
||||
return
|
||||
|
||||
self.ui.code_editor.moveCursor(QtGui.QTextCursor.Start)
|
||||
|
||||
self.handleTextChanged()
|
||||
self.ui.show()
|
||||
self.ui.cncjob_frame.show()
|
||||
|
||||
self.ui.code_editor.moveCursor(QtGui.QTextCursor.Start)
|
||||
self.proc_container.view.set_idle()
|
||||
# self.ui.show()
|
||||
|
||||
def on_toggle_code_editor(self):
|
||||
self.report_usage("on_toggle_code_editor()")
|
||||
|
@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||
- added the Gerber code as source for the panelized object in Panelize Tool
|
||||
- whenever a Gerber file is deleted, the mark_shapes objects are deleted also
|
||||
- made faster the Gerber parser for the case of having a not valid geometry when loading a Gerber file without buffering
|
||||
- updated code in self.on_view_source() to make it more responsive
|
||||
|
||||
10.09.2019
|
||||
|
||||
|
@ -1728,10 +1728,23 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
# ###################################
|
||||
# ## Here we build the CNCJob Tab ###
|
||||
# ###################################
|
||||
# self.cncjob_tab = QtWidgets.QWidget()
|
||||
# self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
|
||||
# self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
|
||||
# self.cncjob_tab.setLayout(self.cncjob_tab_layout)
|
||||
|
||||
self.cncjob_tab = QtWidgets.QWidget()
|
||||
self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
|
||||
|
||||
self.c_temp_layout = QtWidgets.QVBoxLayout(self.cncjob_tab)
|
||||
self.c_temp_layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
self.cncjob_frame = QtWidgets.QFrame()
|
||||
self.cncjob_frame.setContentsMargins(0, 0, 0, 0)
|
||||
self.c_temp_layout.addWidget(self.cncjob_frame)
|
||||
|
||||
self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_frame)
|
||||
self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
|
||||
self.cncjob_tab.setLayout(self.cncjob_tab_layout)
|
||||
self.cncjob_frame.setLayout(self.cncjob_tab_layout)
|
||||
|
||||
self.code_editor = FCTextAreaExtended()
|
||||
stylesheet = """
|
||||
|
Loading…
Reference in New Issue
Block a user