- added some icons in the Code Editor

- replaced some icons in the app
- in Code Editor, when changing text, the Save Code button will change color (text and icon) to red and after save it will revert the color to the default one
- in Code Editor some methods rework
This commit is contained in:
Marius Stanciu
2020-07-18 00:26:03 +03:00
committed by Marius
parent 1b15d2a2c1
commit 8409c74e23
29 changed files with 61 additions and 61 deletions

View File

@@ -72,13 +72,17 @@ class AppTextEditor(QtWidgets.QWidget):
self.code_editor.setPlainText(text)
self.buttonPreview = QtWidgets.QPushButton(_('Print Preview'))
self.buttonPreview.setIcon(QtGui.QIcon(self.app.resource_location + '/preview32.png'))
self.buttonPreview.setToolTip(_("Open a OS standard Preview Print window."))
self.buttonPreview.setMinimumWidth(100)
self.buttonPrint = QtWidgets.QPushButton(_('Print Code'))
self.buttonPrint.setIcon(QtGui.QIcon(self.app.resource_location + '/printer32.png'))
self.buttonPrint.setToolTip(_("Open a OS standard Print window."))
self.buttonPrint.setMinimumWidth(100)
self.buttonFind = QtWidgets.QPushButton(_('Find in Code'))
self.buttonFind.setIcon(QtGui.QIcon(self.app.resource_location + '/find32.png'))
self.buttonFind.setToolTip(_("Will search and highlight in yellow the string in the Find box."))
self.buttonFind.setMinimumWidth(100)
@@ -86,6 +90,7 @@ class AppTextEditor(QtWidgets.QWidget):
self.entryFind.setToolTip(_("Find box. Enter here the strings to be searched in the text."))
self.buttonReplace = QtWidgets.QPushButton(_('Replace With'))
self.buttonReplace.setIcon(QtGui.QIcon(self.app.resource_location + '/replace32.png'))
self.buttonReplace.setToolTip(_("Will replace the string from the Find box with the one in the Replace box."))
self.buttonReplace.setMinimumWidth(100)
@@ -97,17 +102,23 @@ class AppTextEditor(QtWidgets.QWidget):
"with the text in the 'Replace' box.."))
self.button_copy_all = QtWidgets.QPushButton(_('Copy All'))
self.button_copy_all.setIcon(QtGui.QIcon(self.app.resource_location + '/copy_file32.png'))
self.button_copy_all.setToolTip(_("Will copy all the text in the Code Editor to the clipboard."))
self.button_copy_all.setMinimumWidth(100)
self.buttonOpen = QtWidgets.QPushButton(_('Open Code'))
self.buttonOpen.setIcon(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'))
self.buttonOpen.setToolTip(_("Will open a text file in the editor."))
self.buttonOpen.setMinimumWidth(100)
self.buttonSave = QtWidgets.QPushButton(_('Save Code'))
self.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
self.buttonSave.setToolTip(_("Will save the text in the editor into a file."))
self.buttonSave.setMinimumWidth(100)
self.buttonRun = QtWidgets.QPushButton(_('Run Code'))
self.buttonRun.setToolTip(_("Will run the TCL commands found in the text file, one by one."))
self.buttonRun.setMinimumWidth(100)
self.buttonRun.hide()
@@ -169,7 +180,26 @@ class AppTextEditor(QtWidgets.QWidget):
# enable = not self.ui.code_editor.document().isEmpty()
# self.ui.buttonPrint.setEnabled(enable)
# self.ui.buttonPreview.setEnabled(enable)
pass
self.buttonSave.setStyleSheet("QPushButton {color: red;}")
self.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as_red.png'))
def load_text(self, text, move_to_start=False, move_to_end=False, clear_text=True, as_html=False):
self.code_editor.textChanged.disconnect()
if clear_text:
# first clear previous text in text editor (if any)
self.code_editor.clear()
self.code_editor.setReadOnly(False)
if as_html is False:
self.code_editor.setPlainText(text)
else:
self.code_editor.setHtml(text)
if move_to_start:
self.code_editor.moveCursor(QtGui.QTextCursor.Start)
elif move_to_end:
self.code_editor.moveCursor(QtGui.QTextCursor.End)
self.code_editor.textChanged.connect(self.handleTextChanged)
def handleOpen(self, filt=None):
self.app.defaults.report_usage("handleOpen()")
@@ -268,6 +298,8 @@ class AppTextEditor(QtWidgets.QWidget):
with open(filename, 'w') as f:
for line in my_gcode:
f.write(line)
self.buttonSave.setStyleSheet("")
self.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
except FileNotFoundError:
self.app.inform.emit('[WARNING] %s' % _("No such file or directory"))
return