[ui] Introduce ClipboardHelper for copying to clipboard from QML

* add ClipboardHelper class that contains a QClipboard and exposes its method as Slots
* use Clipboard instead of hidden TextEdit where meaningful
This commit is contained in:
Yann Lanthony 2019-05-07 11:46:46 +02:00
parent 9ce077778b
commit 438622a14b
No known key found for this signature in database
GPG key ID: 519FAE6DF7A70642
6 changed files with 35 additions and 3 deletions

View file

@ -0,0 +1,20 @@
from PySide2.QtCore import Slot, QObject
from PySide2.QtGui import QClipboard
class ClipboardHelper(QObject):
"""
Simple wrapper around a QClipboard with methods exposed as Slots for QML use.
"""
def __init__(self, parent=None):
super(ClipboardHelper, self).__init__(parent)
self._clipboard = QClipboard(parent=self)
@Slot(str)
def setText(self, value):
self._clipboard.setText(value)
@Slot()
def clear(self):
self._clipboard.clear()