OS X: Use Cocoa Pasteboard instead of QClipBoard #3300
authorMarkus Goetz <markus@woboq.com>
Tue, 20 Oct 2015 13:42:14 +0000 (15:42 +0200)
committerMarkus Goetz <markus@woboq.com>
Tue, 20 Oct 2015 13:42:43 +0000 (15:42 +0200)
src/gui/CMakeLists.txt
src/gui/clipboard.mm [new file with mode: 0644]
src/gui/sharedialog.cpp

index e9a18be902ca1dfdb7a8f173cba74c75e02677b6..69d65ad33e61e047e81b76d0ff98b2bc4f830bba 100644 (file)
@@ -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 (file)
index 0000000..56361b7
--- /dev/null
@@ -0,0 +1,16 @@
+#include <QString>
+#include <QDebug>
+#import <Cocoa/Cocoa.h>
+
+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];
+}
+
+}
index c4ac51a887c85337217be8a3aa2e008ca872863d..c4c5b71429fe13d8ef643da1cd9e372174d9db33 100644 (file)
@@ -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()