adding Q_INVOKABLE method for copying to Application clipboard

This commit is contained in:
Wayne Chen 2018-07-06 11:03:58 -07:00
parent 3994ec4176
commit 0facbedbbc
4 changed files with 10 additions and 20 deletions

View file

@ -8306,23 +8306,14 @@ void Application::saveNextPhysicsStats(QString filename) {
_physicsEngine->saveNextPhysicsStats(filename);
}
void Application::copyAddress() {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "copyAddress");
void Application::copyToClipboard(const QString& text) {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "copyToClipboard");
return;
}
// assume that the address is being copied because the user wants a shareable address
QApplication::clipboard()->setText(QString("copyAddress worked!"));
}
void Application::copyPath() {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "copyPath");
return;
}
QApplication::clipboard()->setText(QString("copyPath worked!"));
QApplication::clipboard()->setText(text);
}
#if defined(Q_OS_ANDROID)

View file

@ -368,8 +368,7 @@ public slots:
void resetSensors(bool andReload = false);
void setActiveFaceTracker() const;
void copyAddress();
void copyPath();
Q_INVOKABLE void copyToClipboard(const QString& text);
#if (PR_BUILD || DEV_BUILD)
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }

View file

@ -268,12 +268,13 @@ Menu::Menu() {
locationBookmarks->setupMenus(this, navigateMenu);
// Navigate > Copy Address
auto addressManager = DependencyManager::get<AddressManager>();
addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyAddress, 0,
qApp, SLOT(copyAddress()));
addressManager.data(), SLOT(copyAddress()));
// Navigate > Copy Path
addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyPath, 0,
qApp, SLOT(copyPath()));
addressManager.data(), SLOT(copyPath()));
// Settings menu ----------------------------------

View file

@ -852,17 +852,16 @@ void AddressManager::refreshPreviousLookup() {
void AddressManager::copyAddress() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "copyAddress");
QMetaObject::invokeMethod(qApp, "copyToClipboard", Q_ARG(QString, currentShareableAddress().toString()));
return;
}
// assume that the address is being copied because the user wants a shareable address
QGuiApplication::clipboard()->setText(currentShareableAddress().toString());
}
void AddressManager::copyPath() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "copyPath");
QMetaObject::invokeMethod(qApp, "copyToClipboard", Q_ARG(QString, currentPath()));
return;
}