mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
adding Q_INVOKABLE method for copying to Application clipboard
This commit is contained in:
parent
3994ec4176
commit
0facbedbbc
4 changed files with 10 additions and 20 deletions
|
@ -8306,23 +8306,14 @@ void Application::saveNextPhysicsStats(QString filename) {
|
||||||
_physicsEngine->saveNextPhysicsStats(filename);
|
_physicsEngine->saveNextPhysicsStats(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::copyAddress() {
|
void Application::copyToClipboard(const QString& text) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != qApp->thread()) {
|
||||||
QMetaObject::invokeMethod(this, "copyAddress");
|
QMetaObject::invokeMethod(this, "copyToClipboard");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assume that the address is being copied because the user wants a shareable address
|
// assume that the address is being copied because the user wants a shareable address
|
||||||
QApplication::clipboard()->setText(QString("copyAddress worked!"));
|
QApplication::clipboard()->setText(text);
|
||||||
}
|
|
||||||
|
|
||||||
void Application::copyPath() {
|
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
QMetaObject::invokeMethod(this, "copyPath");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QApplication::clipboard()->setText(QString("copyPath worked!"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
|
|
|
@ -368,8 +368,7 @@ public slots:
|
||||||
void resetSensors(bool andReload = false);
|
void resetSensors(bool andReload = false);
|
||||||
void setActiveFaceTracker() const;
|
void setActiveFaceTracker() const;
|
||||||
|
|
||||||
void copyAddress();
|
Q_INVOKABLE void copyToClipboard(const QString& text);
|
||||||
void copyPath();
|
|
||||||
|
|
||||||
#if (PR_BUILD || DEV_BUILD)
|
#if (PR_BUILD || DEV_BUILD)
|
||||||
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }
|
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }
|
||||||
|
|
|
@ -268,12 +268,13 @@ Menu::Menu() {
|
||||||
locationBookmarks->setupMenus(this, navigateMenu);
|
locationBookmarks->setupMenus(this, navigateMenu);
|
||||||
|
|
||||||
// Navigate > Copy Address
|
// Navigate > Copy Address
|
||||||
|
auto addressManager = DependencyManager::get<AddressManager>();
|
||||||
addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyAddress, 0,
|
addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyAddress, 0,
|
||||||
qApp, SLOT(copyAddress()));
|
addressManager.data(), SLOT(copyAddress()));
|
||||||
|
|
||||||
// Navigate > Copy Path
|
// Navigate > Copy Path
|
||||||
addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyPath, 0,
|
addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyPath, 0,
|
||||||
qApp, SLOT(copyPath()));
|
addressManager.data(), SLOT(copyPath()));
|
||||||
|
|
||||||
|
|
||||||
// Settings menu ----------------------------------
|
// Settings menu ----------------------------------
|
||||||
|
|
|
@ -852,17 +852,16 @@ void AddressManager::refreshPreviousLookup() {
|
||||||
|
|
||||||
void AddressManager::copyAddress() {
|
void AddressManager::copyAddress() {
|
||||||
if (QThread::currentThread() != qApp->thread()) {
|
if (QThread::currentThread() != qApp->thread()) {
|
||||||
QMetaObject::invokeMethod(this, "copyAddress");
|
QMetaObject::invokeMethod(qApp, "copyToClipboard", Q_ARG(QString, currentShareableAddress().toString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assume that the address is being copied because the user wants a shareable address
|
// assume that the address is being copied because the user wants a shareable address
|
||||||
QGuiApplication::clipboard()->setText(currentShareableAddress().toString());
|
QGuiApplication::clipboard()->setText(currentShareableAddress().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressManager::copyPath() {
|
void AddressManager::copyPath() {
|
||||||
if (QThread::currentThread() != qApp->thread()) {
|
if (QThread::currentThread() != qApp->thread()) {
|
||||||
QMetaObject::invokeMethod(this, "copyPath");
|
QMetaObject::invokeMethod(qApp, "copyToClipboard", Q_ARG(QString, currentPath()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue