- GUI Element FCLineEdit (and the inheritors) has now disabled cut/paste/delete context menu entries too

This commit is contained in:
Marius Stanciu
2020-11-21 03:09:37 +02:00
committed by Marius
parent 89453e56b4
commit cca04676e2
2 changed files with 11 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta
- Tool Copper Thieving - changed the units for plated area from mm2 in cm2 when the app units are Metric - Tool Copper Thieving - changed the units for plated area from mm2 in cm2 when the app units are Metric
- Calculator Tool - Electroplating Calculator - changing the area will update the current value - Calculator Tool - Electroplating Calculator - changing the area will update the current value
- GUI Elements FCDoubleSpinner and FCSpinner: modified the context menu to not allow cut/paste/delete/step_up/step_down when the GUI element is set as Read Only - GUI Elements FCDoubleSpinner and FCSpinner: modified the context menu to not allow cut/paste/delete/step_up/step_down when the GUI element is set as Read Only
- GUI Element FCLineEdit (and the inheritors) has now disabled cut/paste/delete context menu entries too
20.11.2020 20.11.2020

View File

@@ -286,6 +286,11 @@ class FCLineEdit(QtWidgets.QLineEdit):
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
self.menu = QtWidgets.QMenu() self.menu = QtWidgets.QMenu()
if self.isReadOnly():
undo_action = QAction('%s' % _("Read Only"), self)
self.menu.addAction(undo_action)
self.menu.addSeparator()
# UNDO # UNDO
undo_action = QAction('%s\t%s' % (_("Undo"), _('Ctrl+Z')), self) undo_action = QAction('%s\t%s' % (_("Undo"), _('Ctrl+Z')), self)
self.menu.addAction(undo_action) self.menu.addAction(undo_action)
@@ -306,7 +311,7 @@ class FCLineEdit(QtWidgets.QLineEdit):
cut_action = QAction('%s\t%s' % (_("Cut"), _('Ctrl+X')), self) cut_action = QAction('%s\t%s' % (_("Cut"), _('Ctrl+X')), self)
self.menu.addAction(cut_action) self.menu.addAction(cut_action)
cut_action.triggered.connect(self.cut_text) cut_action.triggered.connect(self.cut_text)
if not self.hasSelectedText(): if not self.hasSelectedText() or self.isReadOnly():
cut_action.setDisabled(True) cut_action.setDisabled(True)
# COPY # COPY
@@ -320,11 +325,15 @@ class FCLineEdit(QtWidgets.QLineEdit):
paste_action = QAction('%s\t%s' % (_("Paste"), _('Ctrl+V')), self) paste_action = QAction('%s\t%s' % (_("Paste"), _('Ctrl+V')), self)
self.menu.addAction(paste_action) self.menu.addAction(paste_action)
paste_action.triggered.connect(self.paste_text) paste_action.triggered.connect(self.paste_text)
if self.isReadOnly():
paste_action.setDisabled(True)
# DELETE # DELETE
delete_action = QAction('%s\t%s' % (_("Delete"), _('Del')), self) delete_action = QAction('%s\t%s' % (_("Delete"), _('Del')), self)
self.menu.addAction(delete_action) self.menu.addAction(delete_action)
delete_action.triggered.connect(self.del_) delete_action.triggered.connect(self.del_)
if self.isReadOnly():
delete_action.setDisabled(True)
self.menu.addSeparator() self.menu.addSeparator()