From e86b03b4f7a0efbc508f54a12e7cebd52c8a3b76 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Sun, 8 Feb 2015 10:32:52 +0100 Subject: [PATCH] add copy to selection buffer (middle mouse-button issue #6) --- src/chatlog/chatlog.cpp | 14 ++++++++++++-- src/chatlog/chatlog.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index 4d3698cac..10e600490 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -180,6 +180,16 @@ void ChatLog::mousePressEvent(QMouseEvent* ev) if(!isOverSelection(scenePos)) clearSelection(); } + +#ifdef Q_OS_LINUX + if(ev->button() == Qt::MiddleButton) + { + copySelectedText(true); + + if(!isOverSelection(scenePos)) + clearSelection(); + } +#endif } void ChatLog::mouseReleaseEvent(QMouseEvent* ev) @@ -528,13 +538,13 @@ void ChatLog::clear() updateSceneRect(); } -void ChatLog::copySelectedText() const +void ChatLog::copySelectedText(bool toSelectionBuffer) const { QString text = getSelectedText(); QClipboard* clipboard = QApplication::clipboard(); if(clipboard && !text.isNull()) - clipboard->setText(text); + clipboard->setText(text, toSelectionBuffer ? QClipboard::Selection : QClipboard::Clipboard); } void ChatLog::setBusyNotification(ChatLine::Ptr notification) diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index 0ab495e4d..e89c789de 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -43,7 +43,7 @@ public: void insertChatlineOnTop(const QList& newLines); void clearSelection(); void clear(); - void copySelectedText() const; + void copySelectedText(bool toSelectionBuffer = false) const; void setBusyNotification(ChatLine::Ptr notification); void setTypingNotification(ChatLine::Ptr notification); void setTypingNotificationVisible(bool visible);