From 2552c737be8a761ab6f6993215f98baa95c09829 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Tue, 29 Apr 2014 15:28:21 +0200 Subject: [PATCH] GuiLog: Use GuiClipboard to put the log on the clipboard All direct interaction with the Qt clipboard is now done in either GuiClipboard or GuiSelection. --- src/frontends/Clipboard.h | 3 +++ src/frontends/qt4/GuiClipboard.cpp | 6 ++++++ src/frontends/qt4/GuiClipboard.h | 1 + src/frontends/qt4/GuiLog.cpp | 4 +++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/frontends/Clipboard.h b/src/frontends/Clipboard.h index 980c6bcbf7..faf4e0a8fe 100644 --- a/src/frontends/Clipboard.h +++ b/src/frontends/Clipboard.h @@ -75,6 +75,9 @@ public: */ virtual void put(std::string const & lyx, docstring const & html, docstring const & text) = 0; + /// Put a general string on the system clipboard (not LyX text) + virtual void put(std::string const & text) const = 0; + /// Does the clipboard contain text contents? virtual bool hasTextContents(TextType type = AnyTextType) const = 0; /// Does the clipboard contain graphics contents of a certain type? diff --git a/src/frontends/qt4/GuiClipboard.cpp b/src/frontends/qt4/GuiClipboard.cpp index 2df20a0cba..d96dd26f0b 100644 --- a/src/frontends/qt4/GuiClipboard.cpp +++ b/src/frontends/qt4/GuiClipboard.cpp @@ -413,6 +413,12 @@ docstring const GuiClipboard::getAsText(TextType type) const } +void GuiClipboard::put(string const & text) const +{ + qApp->clipboard()->setText(toqstr(text)); +} + + void GuiClipboard::put(string const & lyx, docstring const & html, docstring const & text) { LYXERR(Debug::ACTION, "GuiClipboard::put(`" << lyx << "' `" diff --git a/src/frontends/qt4/GuiClipboard.h b/src/frontends/qt4/GuiClipboard.h index 3ffdafcef6..392f0594c6 100644 --- a/src/frontends/qt4/GuiClipboard.h +++ b/src/frontends/qt4/GuiClipboard.h @@ -70,6 +70,7 @@ public: std::string const getAsLyX() const; FileName getAsGraphics(Cursor const & cur, GraphicsType type) const; docstring const getAsText(TextType type) const; + void put(std::string const & text) const; void put(std::string const & lyx, docstring const & html, docstring const & text); bool hasGraphicsContents(GraphicsType type = AnyGraphicsType) const; bool hasTextContents(TextType typetype = AnyTextType) const; diff --git a/src/frontends/qt4/GuiLog.cpp b/src/frontends/qt4/GuiLog.cpp index 8c74139e03..d81849a5ec 100644 --- a/src/frontends/qt4/GuiLog.cpp +++ b/src/frontends/qt4/GuiLog.cpp @@ -18,6 +18,8 @@ #include "qt_helpers.h" #include "Lexer.h" +#include "frontends/Clipboard.h" + #include "support/docstring.h" #include "support/FileName.h" #include "support/gettext.h" @@ -313,7 +315,7 @@ void GuiLog::getContents(ostream & ss) const void GuiLog::on_copyPB_clicked() { - qApp->clipboard()->setText(logTB->toPlainText()); + theClipboard().put(fromqstr(logTB->toPlainText())); }