- SolderPaste Tool - the GCode Viewer will open a AppText Editor Tab with Plain Text
- GCode Editor - added an Exit action to the context menu in the GCode Editor Tab
This commit is contained in:
@@ -11,6 +11,8 @@ CHANGELOG for FlatCAM beta
|
|||||||
|
|
||||||
- GCode Editor - fixed the issue with the editor toolbar buttons not being updated like for the other editors
|
- GCode Editor - fixed the issue with the editor toolbar buttons not being updated like for the other editors
|
||||||
- GCode Editor - the plot_area tab GCode editor that is added will close the Editor when the tab itself is closed
|
- GCode Editor - the plot_area tab GCode editor that is added will close the Editor when the tab itself is closed
|
||||||
|
- SolderPaste Tool - the GCode Viewer will open a AppText Editor Tab with Plain Text
|
||||||
|
- GCode Editor - added an Exit action to the context menu in the GCode Editor Tab
|
||||||
|
|
||||||
12.12.2020
|
12.12.2020
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,14 @@ class AppGCodeEditor(QtCore.QObject):
|
|||||||
self.ui.gcode_editor_tab = AppTextEditor(app=self.app, plain_text=True)
|
self.ui.gcode_editor_tab = AppTextEditor(app=self.app, plain_text=True)
|
||||||
self.edit_area = self.ui.gcode_editor_tab.code_editor
|
self.edit_area = self.ui.gcode_editor_tab.code_editor
|
||||||
|
|
||||||
|
# add the Exit Editor action to the context menu
|
||||||
|
QtGui.QIcon(self.app.resource_location + '/power16.png'), _("Exit Editor")
|
||||||
|
self.edit_area.add_action_to_context_menu(text=_("Exit Editor"),
|
||||||
|
shortcut=_("Ctrl+S"),
|
||||||
|
icon=QtGui.QIcon(self.app.resource_location + '/power16.png'),
|
||||||
|
callback=self.app.editor2object,
|
||||||
|
separator='before')
|
||||||
|
|
||||||
# add the tab if it was closed
|
# add the tab if it was closed
|
||||||
self.app.ui.plot_tab_area.addTab(self.ui.gcode_editor_tab, '%s' % _("Code Editor"))
|
self.app.ui.plot_tab_area.addTab(self.ui.gcode_editor_tab, '%s' % _("Code Editor"))
|
||||||
self.ui.gcode_editor_tab.setObjectName('gcode_editor_tab')
|
self.ui.gcode_editor_tab.setObjectName('gcode_editor_tab')
|
||||||
|
|||||||
@@ -1879,13 +1879,54 @@ class FCPlainTextAreaExtended(QtWidgets.QPlainTextEdit):
|
|||||||
|
|
||||||
self.completer_enable = False
|
self.completer_enable = False
|
||||||
|
|
||||||
self.menu = None
|
|
||||||
self.undo_flag = False
|
self.undo_flag = False
|
||||||
self.redo_flag = False
|
self.redo_flag = False
|
||||||
|
|
||||||
self.undoAvailable.connect(self.on_undo_available)
|
self.undoAvailable.connect(self.on_undo_available)
|
||||||
self.redoAvailable.connect(self.on_redo_available)
|
self.redoAvailable.connect(self.on_redo_available)
|
||||||
|
|
||||||
|
# create the context menu
|
||||||
|
self.menu = QtWidgets.QMenu()
|
||||||
|
|
||||||
|
# UNDO
|
||||||
|
self.undo_action = QAction('%s\t%s' % (_("Undo"), _('Ctrl+Z')), self)
|
||||||
|
self.menu.addAction(self.undo_action)
|
||||||
|
self.undo_action.triggered.connect(self.undo)
|
||||||
|
|
||||||
|
# REDO
|
||||||
|
self.redo_action = QAction('%s\t%s' % (_("Redo"), _('Ctrl+Y')), self)
|
||||||
|
self.menu.addAction(self.redo_action)
|
||||||
|
self.redo_action.triggered.connect(self.redo)
|
||||||
|
|
||||||
|
self.menu.addSeparator()
|
||||||
|
|
||||||
|
# CUT
|
||||||
|
self. cut_action = QAction('%s\t%s' % (_("Cut"), _('Ctrl+X')), self)
|
||||||
|
self.menu.addAction(self.cut_action)
|
||||||
|
self.cut_action.triggered.connect(self.cut_text)
|
||||||
|
|
||||||
|
# COPY
|
||||||
|
self.copy_action = QAction('%s\t%s' % (_("Copy"), _('Ctrl+C')), self)
|
||||||
|
self.menu.addAction(self.copy_action)
|
||||||
|
self.copy_action.triggered.connect(self.copy_text)
|
||||||
|
|
||||||
|
# PASTE
|
||||||
|
self.paste_action = QAction('%s\t%s' % (_("Paste"), _('Ctrl+V')), self)
|
||||||
|
self.menu.addAction(self.paste_action)
|
||||||
|
self.paste_action.triggered.connect(self.paste_text)
|
||||||
|
|
||||||
|
# DELETE
|
||||||
|
self.delete_action = QAction('%s\t%s' % (_("Delete"), _('Del')), self)
|
||||||
|
self.menu.addAction(self.delete_action)
|
||||||
|
self.delete_action.triggered.connect(self.delete_text)
|
||||||
|
|
||||||
|
self.menu.addSeparator()
|
||||||
|
|
||||||
|
# SELECT ALL
|
||||||
|
self.sel_all_action = QAction('%s\t%s' % (_("Select All"), _('Ctrl+A')), self)
|
||||||
|
self.menu.addAction(self.sel_all_action)
|
||||||
|
self.sel_all_action.triggered.connect(self.selectAll)
|
||||||
|
|
||||||
def on_undo_available(self, val):
|
def on_undo_available(self, val):
|
||||||
self.undo_flag = val
|
self.undo_flag = val
|
||||||
|
|
||||||
@@ -1931,59 +1972,53 @@ class FCPlainTextAreaExtended(QtWidgets.QPlainTextEdit):
|
|||||||
QtWidgets.QPlainTextEdit.focusInEvent(self, event)
|
QtWidgets.QPlainTextEdit.focusInEvent(self, event)
|
||||||
|
|
||||||
def contextMenuEvent(self, event):
|
def contextMenuEvent(self, event):
|
||||||
self.menu = QtWidgets.QMenu()
|
|
||||||
tcursor = self.textCursor()
|
tcursor = self.textCursor()
|
||||||
txt = tcursor.selectedText()
|
txt = tcursor.selectedText()
|
||||||
|
|
||||||
# UNDO
|
# UNDO
|
||||||
undo_action = QAction('%s\t%s' % (_("Undo"), _('Ctrl+Z')), self)
|
|
||||||
self.menu.addAction(undo_action)
|
|
||||||
undo_action.triggered.connect(self.undo)
|
|
||||||
if self.undo_flag is False:
|
if self.undo_flag is False:
|
||||||
undo_action.setDisabled(True)
|
self.undo_action.setDisabled(True)
|
||||||
|
else:
|
||||||
|
self.undo_action.setDisabled(False)
|
||||||
|
|
||||||
# REDO
|
# REDO
|
||||||
redo_action = QAction('%s\t%s' % (_("Redo"), _('Ctrl+Y')), self)
|
|
||||||
self.menu.addAction(redo_action)
|
|
||||||
redo_action.triggered.connect(self.redo)
|
|
||||||
if self.redo_flag is False:
|
if self.redo_flag is False:
|
||||||
redo_action.setDisabled(True)
|
self.redo_action.setDisabled(True)
|
||||||
|
else:
|
||||||
self.menu.addSeparator()
|
self.redo_action.setDisabled(False)
|
||||||
|
|
||||||
# CUT
|
# CUT
|
||||||
cut_action = QAction('%s\t%s' % (_("Cut"), _('Ctrl+X')), self)
|
|
||||||
self.menu.addAction(cut_action)
|
|
||||||
cut_action.triggered.connect(self.cut_text)
|
|
||||||
if txt == '':
|
if txt == '':
|
||||||
cut_action.setDisabled(True)
|
self.cut_action.setDisabled(True)
|
||||||
|
else:
|
||||||
|
self.cut_action.setDisabled(False)
|
||||||
|
|
||||||
# COPY
|
# COPY
|
||||||
copy_action = QAction('%s\t%s' % (_("Copy"), _('Ctrl+C')), self)
|
|
||||||
self.menu.addAction(copy_action)
|
|
||||||
copy_action.triggered.connect(self.copy_text)
|
|
||||||
if txt == '':
|
if txt == '':
|
||||||
copy_action.setDisabled(True)
|
self.copy_action.setDisabled(True)
|
||||||
|
else:
|
||||||
# PASTE
|
self.copy_action.setDisabled(False)
|
||||||
paste_action = QAction('%s\t%s' % (_("Paste"), _('Ctrl+V')), self)
|
|
||||||
self.menu.addAction(paste_action)
|
|
||||||
paste_action.triggered.connect(self.paste_text)
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
delete_action = QAction('%s\t%s' % (_("Delete"), _('Del')), self)
|
|
||||||
self.menu.addAction(delete_action)
|
|
||||||
delete_action.triggered.connect(self.delete_text)
|
|
||||||
|
|
||||||
self.menu.addSeparator()
|
|
||||||
|
|
||||||
# SELECT ALL
|
|
||||||
sel_all_action = QAction('%s\t%s' % (_("Select All"), _('Ctrl+A')), self)
|
|
||||||
self.menu.addAction(sel_all_action)
|
|
||||||
sel_all_action.triggered.connect(self.selectAll)
|
|
||||||
|
|
||||||
self.menu.exec_(event.globalPos())
|
self.menu.exec_(event.globalPos())
|
||||||
|
|
||||||
|
def add_action_to_context_menu(self, text, shortcut='', icon=None, callback=lambda: None, separator=None):
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
if separator == 'before':
|
||||||
|
self.menu.addSeparator()
|
||||||
|
|
||||||
|
# New Action
|
||||||
|
if icon is None:
|
||||||
|
new_action = QAction('%s\t%s' % (text, shortcut), self)
|
||||||
|
else:
|
||||||
|
new_action = QAction(icon, '%s\t%s' % (text, shortcut), self)
|
||||||
|
self.menu.addAction(new_action)
|
||||||
|
new_action.triggered.connect(lambda: callback())
|
||||||
|
|
||||||
|
if separator == 'after':
|
||||||
|
self.menu.addSeparator()
|
||||||
|
|
||||||
def cut_text(self):
|
def cut_text(self):
|
||||||
tcursor = self.textCursor()
|
tcursor = self.textCursor()
|
||||||
clipboard = QtWidgets.QApplication.clipboard()
|
clipboard = QtWidgets.QApplication.clipboard()
|
||||||
|
|||||||
@@ -998,10 +998,10 @@ class SolderPaste(AppTool):
|
|||||||
"""
|
"""
|
||||||
time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
||||||
|
|
||||||
self.text_editor_tab = AppTextEditor(app=self.app)
|
self.text_editor_tab = AppTextEditor(app=self.app, plain_text=True)
|
||||||
|
|
||||||
# add the tab if it was closed
|
# add the tab if it was closed
|
||||||
self.app.ui.plot_tab_area.addTab(self.text_editor_tab, _("SP GCode Editor"))
|
self.app.ui.plot_tab_area.addTab(self.text_editor_tab, _("GCode Editor"))
|
||||||
self.text_editor_tab.setObjectName('solderpaste_gcode_editor_tab')
|
self.text_editor_tab.setObjectName('solderpaste_gcode_editor_tab')
|
||||||
|
|
||||||
# Switch plot_area to CNCJob tab
|
# Switch plot_area to CNCJob tab
|
||||||
|
|||||||
Reference in New Issue
Block a user