mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 12:35:52 +03:00
Merge pull request #6515 from nextcloud/work/ervin/socketapi-use-ksystemclipboard-when-available
[socketapi] Replace QClipboard with KSystemClipboard when available
This commit is contained in:
commit
ffffc89414
2 changed files with 28 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
project(gui)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 QuickWidgets Xml Network)
|
||||
find_package(KF5Archive REQUIRED)
|
||||
find_package(KF5GuiAddons)
|
||||
|
||||
if(QUICK_COMPILER)
|
||||
find_package(Qt5QuickCompiler)
|
||||
|
@ -563,6 +564,14 @@ target_link_libraries(nextcloudCore
|
|||
KF5::Archive
|
||||
)
|
||||
|
||||
if(KF5GuiAddons_FOUND)
|
||||
target_link_libraries(nextcloudCore
|
||||
PUBLIC
|
||||
KF5::GuiAddons
|
||||
)
|
||||
add_definitions(-DHAVE_KGUIADDONS)
|
||||
endif()
|
||||
|
||||
add_subdirectory(socketapi)
|
||||
|
||||
# skip unity inclusion for files which cause problems with a CMake unity build
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
#include <QJsonObject>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include <QProcess>
|
||||
|
@ -77,6 +76,12 @@
|
|||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KGUIADDONS
|
||||
#include <QMimeData>
|
||||
#include <KSystemClipboard>
|
||||
#else
|
||||
#include <QClipboard>
|
||||
#endif
|
||||
|
||||
// This is the version that is returned when the client asks for the VERSION.
|
||||
// The first number should be changed if there is an incompatible change that breaks old clients.
|
||||
|
@ -194,6 +199,17 @@ static QString buildMessage(const QString &verb, const QString &path, const QStr
|
|||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
void setClipboardText(const QString &text)
|
||||
{
|
||||
#ifdef HAVE_KGUIADDONS
|
||||
auto mimeData = new QMimeData();
|
||||
mimeData->setText(text);
|
||||
KSystemClipboard::instance()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||
#else
|
||||
QApplication::clipboard()->setText(text);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace OCC {
|
||||
|
@ -902,7 +918,7 @@ void SocketApi::command_COPY_PUBLIC_LINK(const QString &localFile, SocketListene
|
|||
#ifdef Q_OS_WIN
|
||||
void SocketApi::command_COPYASPATH(const QString &localFile, SocketListener *)
|
||||
{
|
||||
QApplication::clipboard()->setText(localFile);
|
||||
setClipboardText(localFile);
|
||||
}
|
||||
|
||||
void SocketApi::command_OPENNEWWINDOW(const QString &localFile, SocketListener *)
|
||||
|
@ -995,7 +1011,7 @@ void SocketApi::command_MAKE_ONLINE_ONLY(const QString &filesArg, SocketListener
|
|||
|
||||
void SocketApi::copyUrlToClipboard(const QString &link)
|
||||
{
|
||||
QApplication::clipboard()->setText(link);
|
||||
setClipboardText(link);
|
||||
}
|
||||
|
||||
void SocketApi::command_RESOLVE_CONFLICT(const QString &localFile, SocketListener *)
|
||||
|
|
Loading…
Reference in a new issue