mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-31 18:00:48 +03:00
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
|
#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());
|
||
|
}
|