summaryrefslogtreecommitdiff
path: root/file-manager/pcmanfm-qt-uc.patch
blob: 16c80d26ce3c2b4a6f5ccd2950add63a69a97647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
diff -ur pcmanfm-qt-0.14.1/CMakeLists.txt pcmanfm-qt-patched/CMakeLists.txt
--- pcmanfm-qt-0.14.1/CMakeLists.txt	2019-02-23 20:16:13.000000000 -0400
+++ pcmanfm-qt-patched/CMakeLists.txt	2019-12-19 17:16:14.796019382 -0400
@@ -24,6 +24,7 @@
 find_package(Qt5LinguistTools ${QT_MINIMUM_VERSION} REQUIRED)
 find_package(Qt5Widgets ${QT_MINIMUM_VERSION} REQUIRED)
 find_package(Qt5X11Extras ${QT_MINIMUM_VERSION} REQUIRED)
+find_package(Qt5Network "${QT_MINIMUM_VERSION}" REQUIRED)
 find_package(fm-qt ${LIBFMQT_MINIMUM_VERSION} REQUIRED)
 find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
 
diff -ur pcmanfm-qt-0.14.1/pcmanfm/CMakeLists.txt pcmanfm-qt-patched/pcmanfm/CMakeLists.txt
--- pcmanfm-qt-0.14.1/pcmanfm/CMakeLists.txt	2019-02-23 20:16:13.000000000 -0400
+++ pcmanfm-qt-patched/pcmanfm/CMakeLists.txt	2019-12-19 17:16:55.556039000 -0400
@@ -79,6 +79,7 @@
     Qt5::X11Extras
     Qt5::Widgets
     Qt5::DBus
+    Qt5::Network
     fm-qt
 )
 
diff -ur pcmanfm-qt-0.14.1/pcmanfm/desktopwindow.cpp pcmanfm-qt-patched/pcmanfm/desktopwindow.cpp
--- pcmanfm-qt-0.14.1/pcmanfm/desktopwindow.cpp	2019-02-23 20:16:13.000000000 -0400
+++ pcmanfm-qt-patched/pcmanfm/desktopwindow.cpp	2019-12-19 16:52:39.985314000 -0400
@@ -40,6 +40,7 @@
 #include <QStandardPaths>
 #include <QClipboard>
 #include <QWindow>
+#include <QtNetwork/QLocalSocket>
 
 #include "./application.h"
 #include "mainwindow.h"
@@ -1324,11 +1325,73 @@
     }
 }
 
+void sendRawOrderList(const QStringList & order, QLocalSocket &socket, int idNextOrder)
+{
+    QByteArray block;
+    QDataStream out(&block, QIODevice::WriteOnly);
+    out.setVersion(QDataStream::Qt_4_4);
+    out << int(0);
+    out << idNextOrder;
+    out << order;
+    out.device()->seek(0);
+    out << block.size();
+    do //cut string list and send it as block of 32KB
+    {
+        QByteArray blockToSend;
+        int byteWriten;
+        blockToSend=block.left(32*1024);//32KB
+        block.remove(0,blockToSend.size());
+        byteWriten = socket.write(blockToSend);
+    }
+    while(block.size());
+}
+
 void DesktopWindow::onPasteActivated() {
     if(desktopHideItems_) {
         return;
     }
-    Fm::pasteFilesFromClipboard(path());
+    QClipboard* clipboard = QApplication::clipboard();
+    const QMimeData* data = clipboard->mimeData();
+    Fm::FilePathList paths;
+    bool isCut = false;
+
+    std::tie(paths, isCut) = Fm::parseClipboardData(*data);
+
+    if(!paths.empty()) {
+        QLocalSocket socket;
+        socket.connectToServer(QString::fromStdString("advanced-copier-"+std::to_string(getuid())));
+        socket.waitForConnected();
+        if(socket.state()==QLocalSocket::ConnectedState)
+        {
+            sendRawOrderList(QStringList() << "protocol" << "0002", socket, 1);
+            socket.waitForReadyRead();
+            socket.readAll();
+            QStringList l;
+            if(isCut) {
+                l << "mv";
+                clipboard->clear(QClipboard::Clipboard);
+            }
+            else {
+                l << "cp";
+            }
+            for(const Fm::FilePath &n : paths)
+                l << n.toString().get();
+            l << path().toString().get();
+            sendRawOrderList(l, socket, 2);
+            socket.waitForBytesWritten();
+            socket.close();
+        }
+        else
+        {
+            if(isCut) {
+                Fm::FileOperation::moveFiles(paths, path(), nullptr);
+                clipboard->clear(QClipboard::Clipboard);
+            }
+            else {
+                Fm::FileOperation::copyFiles(paths, path(), nullptr);
+            }
+        }
+    }
 }
 
 void DesktopWindow::onDeleteActivated() {
diff -ur pcmanfm-qt-0.14.1/pcmanfm/mainwindow.cpp pcmanfm-qt-patched/pcmanfm/mainwindow.cpp
--- pcmanfm-qt-0.14.1/pcmanfm/mainwindow.cpp	2019-02-23 20:16:13.000000000 -0400
+++ pcmanfm-qt-patched/pcmanfm/mainwindow.cpp	2019-12-19 17:21:07.078366000 -0400
@@ -34,6 +34,7 @@
 #include <QStandardPaths>
 #include <QClipboard>
 #include <QDebug>
+#include <QtNetwork/QLocalSocket>
 
 #include "tabpage.h"
 #include "launcher.h"
@@ -1529,8 +1530,70 @@
     cutFilesToClipboard(paths);
 }
 
+void sendRawOrderListA(const QStringList & order, QLocalSocket &socket, int idNextOrder)
+{
+    QByteArray block;
+    QDataStream out(&block, QIODevice::WriteOnly);
+    out.setVersion(QDataStream::Qt_4_4);
+    out << int(0);
+    out << idNextOrder;
+    out << order;
+    out.device()->seek(0);
+    out << block.size();
+    do //cut string list and send it as block of 32KB
+    {
+        QByteArray blockToSend;
+        int byteWriten;
+        blockToSend=block.left(32*1024);//32KB
+        block.remove(0,blockToSend.size());
+        byteWriten = socket.write(blockToSend);
+    }
+    while(block.size());
+}
+
 void MainWindow::on_actionPaste_triggered() {
-    pasteFilesFromClipboard(currentPage()->path(), this);
+    QClipboard* clipboard = QApplication::clipboard();
+    const QMimeData* data = clipboard->mimeData();
+    Fm::FilePathList paths;
+    bool isCut = false;
+
+    std::tie(paths, isCut) = parseClipboardData(*data);
+
+    if(!paths.empty()) {
+        QLocalSocket socket;
+        socket.connectToServer(QString::fromStdString("advanced-copier-"+std::to_string(getuid())));
+        socket.waitForConnected();
+        if(socket.state()==QLocalSocket::ConnectedState)
+        {
+            sendRawOrderListA(QStringList() << "protocol" << "0002", socket, 1);
+            socket.waitForReadyRead();
+            socket.readAll();
+            QStringList l;
+            if(isCut) {
+                l << "mv";
+                clipboard->clear(QClipboard::Clipboard);
+            }
+            else {
+                l << "cp";
+            }
+            for(const Fm::FilePath &n : paths)
+                l << n.toString().get();
+            l << currentPage()->path().toString().get();
+            sendRawOrderListA(l, socket, 2);
+            socket.waitForBytesWritten();
+            socket.close();
+        }
+        else
+        {
+            if(isCut) {
+                Fm::FileOperation::moveFiles(paths, currentPage()->path(), this);
+                clipboard->clear(QClipboard::Clipboard);
+            }
+            else {
+                Fm::FileOperation::copyFiles(paths, currentPage()->path(), this);
+            }
+        }
+    }
 }
 
 void MainWindow::on_actionDelete_triggered() {