Merge pull request #12171 from mnafees/21671

CR for Job #21671 - Window.copyToClipboard() doesn't work in .js files
This commit is contained in:
Seth Alves 2018-01-17 13:42:47 -08:00 committed by GitHub
commit 7af90d5429
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -411,6 +411,11 @@ int WindowScriptingInterface::getY() {
}
void WindowScriptingInterface::copyToClipboard(const QString& text) {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "copyToClipboard", Q_ARG(QString, text));
return;
}
qDebug() << "Copying";
QApplication::clipboard()->setText(text);
}

View file

@ -15,6 +15,7 @@
#include <QJsonDocument>
#include <QRegExp>
#include <QStringList>
#include <QThread>
#include <BuildInfo.h>
#include <GLMHelpers.h>
@ -761,11 +762,21 @@ void AddressManager::refreshPreviousLookup() {
}
void AddressManager::copyAddress() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "copyAddress");
return;
}
// assume that the address is being copied because the user wants a shareable address
QApplication::clipboard()->setText(currentShareableAddress().toString());
}
void AddressManager::copyPath() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "copyPath");
return;
}
QApplication::clipboard()->setText(currentPath());
}