-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipboardmanager.cpp
54 lines (38 loc) · 1.08 KB
/
clipboardmanager.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <QClipboard>
#include <QApplication>
#include<QDebug>
#include <typeinfo>
#include<QMimeData>
#include "clipboardmanager.h"
ClipboardManager::ClipboardManager(QObject *parent) : QObject(parent)
{
cb = QApplication::clipboard();
fileManager = new FileManager();
}
QString ClipboardManager::getClipboardData(){
if (fileManager->file.open(QIODevice::ReadWrite|QIODevice::Append)){
connect(cb, &QClipboard::dataChanged,[&]
{
md = cb->mimeData();
if(md->hasText()){
fileManager->saveFile(md->text());
_cbList.append(md->text());
emit clipboardChanged();
}
else if(md->hasImage()){
qDebug()<<md->imageData();
}
}
);
}
return cb->text();
}
void ClipboardManager::setClipboardData(const QString& text){
QMimeData * mime = new QMimeData;
mime->setText(text);
cb->setMimeData(mime,QClipboard::Clipboard);
fileManager->readFile();
}
ClipboardManager::~ClipboardManager(){
delete fileManager;
}