Add a copy to clipboard button to the job log viewer dialog

This commit is contained in:
Kovid Goyal 2018-09-28 20:26:13 +05:30
parent 01a9fb6687
commit 86671138dc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -443,6 +443,15 @@ class DetailView(Dialog): # {{{
def sizeHint(self):
return QSize(700, 500)
@property
def plain_text(self):
if self.html_view:
return self.tb.toPlainText()
return self.log.toPlainText()
def copy_to_clipboard(self):
QApplication.instance().clipboard().setText(self.plain_text)
def setup_ui(self):
self.l = l = QVBoxLayout(self)
if self.html_view:
@ -453,6 +462,9 @@ class DetailView(Dialog): # {{{
l.addWidget(w)
l.addWidget(self.bb)
self.bb.clear(), self.bb.setStandardButtons(self.bb.Close)
self.copy_button = b = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole)
b.setIcon(QIcon(I('edit-copy.png')))
b.clicked.connect(self.copy_to_clipboard)
self.next_pos = 0
self.update()
self.timer = QTimer(self)