From: Markus Goetz Date: Tue, 20 Oct 2015 13:42:14 +0000 (+0200) Subject: OS X: Use Cocoa Pasteboard instead of QClipBoard #3300 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1529 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=98b966d27433a51b4a4f77816b8c2d689bafec5e;p=nextcloud-desktop.git OS X: Use Cocoa Pasteboard instead of QClipBoard #3300 --- diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index e9a18be90..69d65ad33 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -97,6 +97,7 @@ IF( APPLE ) list(APPEND client_SRCS settingsdialogmac.cpp) list(APPEND client_SRCS socketapisocket_mac.mm) list(APPEND client_SRCS systray.mm) + list(APPEND client_SRCS clipboard.mm) if(SPARKLE_FOUND) # Define this, we need to check in updater.cpp diff --git a/src/gui/clipboard.mm b/src/gui/clipboard.mm new file mode 100644 index 000000000..56361b7c9 --- /dev/null +++ b/src/gui/clipboard.mm @@ -0,0 +1,16 @@ +#include +#include +#import + +namespace OCC { + +// https://github.com/owncloud/client/issues/3300 +void copyToPasteboard(const QString &string) +{ + qDebug() << Q_FUNC_INFO << string; + [[NSPasteboard generalPasteboard] clearContents]; + [[NSPasteboard generalPasteboard] setString:[NSString stringWithUTF8String:string.toUtf8().data()] + forType:NSStringPboardType]; +} + +} diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index c4ac51a88..c4c5b7142 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -590,10 +590,18 @@ void ShareDialog::slotCheckBoxExpireClicked() } } +#ifdef Q_OS_MAC +extern void copyToPasteboard(const QString &string); +#endif + void ShareDialog::slotPushButtonCopyLinkPressed() { +#ifdef Q_OS_MAC + copyToPasteboard(_shareUrl); +#else QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(_shareUrl); +#endif } void ShareDialog::slotCheckBoxEditingClicked()