Newer
Older
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
#include "InputBar.h"
#include <QClipboard>
#include <QGuiApplication>
#include <QMimeData>
#include "Logging.h"
bool
InputBar::paste(bool fromMouse)
{
const QMimeData *md = nullptr;
if (fromMouse) {
if (QGuiApplication::clipboard()->supportsSelection()) {
md = QGuiApplication::clipboard()->mimeData(QClipboard::Selection);
}
} else {
md = QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard);
}
if (!md)
return false;
if (md->hasImage()) {
return true;
} else {
nhlog::ui()->debug("formats: {}", md->formats().join(", ").toStdString());
return false;
}
}
void
InputBar::updateState(int selectionStart_, int selectionEnd_, int cursorPosition_, QString text_)
{
selectionStart = selectionStart_;
selectionEnd = selectionEnd_;
cursorPosition = cursorPosition_;
text = text_;
}
void
InputBar::send()
{
nhlog::ui()->debug("Send: {}", text.toStdString());
}