mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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 ----------------------------------
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue