-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjsrclipboardchange.cpp
More file actions
38 lines (28 loc) · 1005 Bytes
/
Copy pathjsrclipboardchange.cpp
File metadata and controls
38 lines (28 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "jsrclipboardchange.h"
#include <QApplication>
#include <QMimeData>
JSRClipboardChange::JSRClipboardChange(QJSEngine *pengine, QJSValue callback)
: JSCallback(pengine, callback)
{
//do nothing
}
bool JSRClipboardChange::exec()
{
m_clipboard = QApplication::clipboard();
connect(m_clipboard, SIGNAL(changed(QClipboard::Mode)),this,SLOT(changedSlot(QClipboard::Mode)));
return true;
}
void JSRClipboardChange::changedSlot(QClipboard::Mode mode)
{
//TODO: support images and other cool stuff like html, images, urls etc... @see QMimeData
QJSValueList args;
if(QApplication::clipboard()->mimeData()->hasText())
{
QString data = m_clipboard->text();
args.push_back(QJSValue(data));
}
call(args);
//emit a signal that our callback was completed, technically we should be able to
//delete the object but i'm not sure if we have to wait a little bit
emit callbackCompleted(this, m_callbackResult);
}