]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiClipboard.C
d518f1a3c45008410b15250d5a258a617beb2f75
[lyx.git] / src / frontends / qt4 / GuiClipboard.C
1 // -*- C++ -*-
2 /**
3  * \file qt4/GuiClipboard.C
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiClipboard.h"
16 #include "qt_helpers.h"
17
18 #include "debug.h"
19
20 #include <QApplication>
21 #include <QClipboard>
22 #include <QString>
23
24 #include "support/lstrings.h"
25 using lyx::support::internalLineEnding;
26 using lyx::support::externalLineEnding;
27
28 using std::endl;
29 using std::string;
30
31 namespace lyx {
32 namespace frontend {
33
34 string const GuiClipboard::get() const
35 {
36         QString const str = qApp->clipboard()->text(QClipboard::Clipboard);
37         lyxerr[Debug::ACTION] << "GuiClipboard::get: " << (const char*) str
38                               << endl;
39         if (str.isNull())
40                 return string();
41
42         return internalLineEnding(fromqstr(str));
43 }
44
45
46 void GuiClipboard::put(string const & str)
47 {
48         lyxerr[Debug::ACTION] << "GuiClipboard::put: " << str << endl;
49
50         qApp->clipboard()->setText(toqstr(externalLineEnding(str)),
51                                    QClipboard::Clipboard);
52 }
53
54 } // namespace frontend
55 } // namespace lyx