Skip to content

Commit

Permalink
WIP: copy selected entries to a standard file in /tmp
Browse files Browse the repository at this point in the history
Will support copying mdhi history to gcode editor for more complex editing and use.
  • Loading branch information
joco-nz committed Jun 18, 2020
1 parent 30d66f5 commit 787da78
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion qtpyvcp/widgets/input_widgets/mdihistory_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* be able to select a row and run commands from that point upwards
"""
import os

from qtpy.QtCore import Qt, Slot, Property, QTimer
from qtpy.QtGui import QIcon
Expand Down Expand Up @@ -152,6 +153,16 @@ def rowClicked(self):
"""Item row clicked."""
pass

@Slot()
def copySelectionToGcodeEditor(self):
fname = '/tmp/mdi_gcode.ngc'
selection = self.selectedItems()
with open(fname, 'w') as fh:
for item in selection:
cmd = str(item.text()).strip()
fh.write(cmd + '\n')
fh.write('M2\n')

@Slot()
def moveRowItemUp(self):
row = self.currentRow()
Expand All @@ -160,6 +171,7 @@ def moveRowItemUp(self):
item = self.takeItem(row)
self.insertItem(row-1, item)
self.setCurrentRow(row-1)
STATUS.mdi_swap_entries(row, row-1)

@Slot()
def moveRowItemDown(self):
Expand All @@ -169,7 +181,8 @@ def moveRowItemDown(self):
item = self.takeItem(row)
self.insertItem(row+1, item)
self.setCurrentRow(row+1)

STATUS.mdi_swap_entries(row, row+1)

def keyPressEvent(self, event):
"""Key movement processing.
Arrow keys move the selected list item up/down
Expand Down

0 comments on commit 787da78

Please sign in to comment.