diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3eff06742d..a58af6e623 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -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) diff --git a/interface/src/Application.h b/interface/src/Application.h index 13e4d83fd4..4556488f09 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -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); } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 4554d1efd8..646067169f 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -268,12 +268,13 @@ Menu::Menu() { locationBookmarks->setupMenus(this, navigateMenu); // Navigate > Copy Address + auto addressManager = DependencyManager::get(); 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 ---------------------------------- diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 3fe75c5495..00e552af89 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -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; }