Skip to content

Commit e73df74

Browse files
committed
#3371 webappclientservice: add more status and log messages
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 3a8a5f0 commit e73df74

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/services/webappclientservice.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ bool WebAppClientService::keepClipboard() {
8484
QBuffer buffer(&byteArray);
8585
buffer.open(QIODevice::WriteOnly);
8686
pixmap.save(&buffer, "PNG");
87-
const QString content = byteArray.toBase64();
8887

8988
_clipboardMimeType = "image/png";
90-
_clipboardContent = content;
89+
_clipboardContent = byteArray.toBase64();
9190
} else if (mimeData->hasText()) {
9291
_clipboardMimeType = "text/plain";
9392
_clipboardContent = clipboard->text();
@@ -106,6 +105,9 @@ bool WebAppClientService::sendClipboard() const {
106105
return false;
107106
}
108107

108+
qDebug() << __func__ << "_clipboardMimeType: " << _clipboardMimeType;
109+
qDebug() << __func__ << "_clipboardContent: " << _clipboardContent;
110+
109111
sendInsertIntoClipboard(_clipboardMimeType, _clipboardContent);
110112
return true;
111113
}
@@ -242,20 +244,34 @@ void WebAppClientService::onTextMessageReceived(const QString &message) {
242244
QClipboard *clipboard = QApplication::clipboard();
243245
const QString mimeType = jsonObject.value(QStringLiteral("mimeType")).toString();
244246
const QString content = jsonObject.value(QStringLiteral("content")).toString();
247+
qDebug() << __func__ << "mimeType: " << mimeType;
248+
qDebug() << __func__ << "content: " << content.left(200);
249+
250+
#ifndef INTEGRATION_TESTS
251+
MainWindow *mainWindow = MainWindow::instance();
245252

246253
if (mimeType == "text/plain") {
247254
clipboard->setText(content, QClipboard::Clipboard);
255+
mainWindow->showStatusBarMessage(
256+
tr("Text received from web app and copied to clipboard"), QStringLiteral("📋"),
257+
5000);
248258
} else if (mimeType == "text/html") {
249259
clipboard->setText(content, QClipboard::Clipboard);
260+
mainWindow->showStatusBarMessage(
261+
tr("HTML received from web app and copied to clipboard"), QStringLiteral("📋"),
262+
5000);
250263
} else if (mimeType == "image") {
251264
const QByteArray imageData = QByteArray::fromBase64(content.toUtf8());
252265
QImage image;
253266
image.loadFromData(imageData);
254267
clipboard->setImage(image, QClipboard::Clipboard);
268+
mainWindow->showStatusBarMessage(
269+
tr("Image received from web app and copied to clipboard"), QStringLiteral("📋"),
270+
5000);
255271
} else {
256272
qWarning() << "Unknown mime data type from web app: " << mimeType;
257-
return;
258273
}
274+
#endif
259275
} else {
260276
qWarning() << "Unknown message from web app: " << message;
261277
}

0 commit comments

Comments
 (0)