|
|
|
@ -37,6 +37,7 @@ |
|
|
|
#include <QEventLoop> |
|
|
|
#include <QEventLoop> |
|
|
|
#include <QCloseEvent> |
|
|
|
#include <QCloseEvent> |
|
|
|
#include <functional> |
|
|
|
#include <functional> |
|
|
|
|
|
|
|
#include <memory> |
|
|
|
#include <limits> |
|
|
|
#include <limits> |
|
|
|
#include <cstring> |
|
|
|
#include <cstring> |
|
|
|
extern "C" { |
|
|
|
extern "C" { |
|
|
|
@ -542,17 +543,13 @@ void MemberFileBrowser::download(bool open) { |
|
|
|
m_openAfter = open; startTransfer(selectedPath(), local, false, selectedVersion()); |
|
|
|
m_openAfter = open; startTransfer(selectedPath(), local, false, selectedVersion()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MemberFileBrowser::publishExport(const QStringList& paths, bool clipboard) { |
|
|
|
void MemberFileBrowser::publishExport(const QStringList& paths) { |
|
|
|
auto* mime = new QMimeData; QList<QUrl> urls; QByteArray gnome("copy"); |
|
|
|
auto* mime = new QMimeData; QList<QUrl> urls; QByteArray gnome("copy"); |
|
|
|
for (const auto& path : paths) { QUrl url = QUrl::fromLocalFile(path); urls.append(url); gnome += '\n' + url.toEncoded(); } |
|
|
|
for (const auto& path : paths) { QUrl url = QUrl::fromLocalFile(path); urls.append(url); gnome += '\n' + url.toEncoded(); } |
|
|
|
mime->setUrls(urls); mime->setData("x-special/gnome-copied-files", gnome); mime->setData("application/x-kde-cutselection", "0"); |
|
|
|
mime->setUrls(urls); mime->setData("x-special/gnome-copied-files", gnome); mime->setData("application/x-kde-cutselection", "0"); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "file browser: exporting entries=%d clipboard=%d", int(paths.size()), clipboard); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "file browser: clipboard ready entries=%d", int(paths.size())); |
|
|
|
if (clipboard) { |
|
|
|
QGuiApplication::clipboard()->setMimeData(mime); |
|
|
|
QGuiApplication::clipboard()->setMimeData(mime); |
|
|
|
m_status->setText(text("Selection copied. Paste it in your file manager.")); |
|
|
|
m_status->setText(text("Selection copied. Paste it in your file manager.")); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
auto* drag = new QDrag(m_entries); drag->setMimeData(mime); drag->exec(Qt::CopyAction, Qt::CopyAction); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MemberFileBrowser::exportFile(bool clipboard, const QString& destination) { |
|
|
|
void MemberFileBrowser::exportFile(bool clipboard, const QString& destination) { |
|
|
|
@ -567,13 +564,14 @@ void MemberFileBrowser::exportFile(bool clipboard, const QString& destination) { |
|
|
|
m_status->setText(text("Cannot prepare a local copy")); return; |
|
|
|
m_status->setText(text("Cannot prepare a local copy")); return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (destination.isEmpty()) base += "/file-exports"; |
|
|
|
if (destination.isEmpty()) base += "/file-exports"; |
|
|
|
m_exportId = requestId(); m_exportResult.clear(); m_openAfter = false; |
|
|
|
m_exportId = requestId(); m_openAfter = false; |
|
|
|
|
|
|
|
auto result = std::make_shared<QStringList>(); |
|
|
|
quint64 id = m_exportId; |
|
|
|
quint64 id = m_exportId; |
|
|
|
auto* batch = createBatch(MemberFileBatch::Download); |
|
|
|
auto* batch = createBatch(MemberFileBatch::Download); |
|
|
|
batch->finished = [this, batch, clipboard](bool ok, const QString& summary, const QStringList& roots) { |
|
|
|
batch->finished = [this, batch, clipboard, result](bool ok, const QString& summary, const QStringList& roots) { |
|
|
|
m_batch = nullptr; m_exportId = 0; m_progress->hide(); m_uploadStatus->setText(summary); |
|
|
|
m_batch = nullptr; m_exportId = 0; m_progress->hide(); m_uploadStatus->setText(summary); |
|
|
|
m_exportResult = ok ? roots : QStringList(); batch->deleteLater(); updateActions(); |
|
|
|
*result = ok ? roots : QStringList(); batch->deleteLater(); updateActions(); |
|
|
|
if (ok && clipboard) publishExport(roots, true); |
|
|
|
if (ok && clipboard) publishExport(roots); |
|
|
|
else m_status->setText(ok ? text("Local copy ready") : summary); |
|
|
|
else m_status->setText(ok ? text("Local copy ready") : summary); |
|
|
|
emit exportFinished(); |
|
|
|
emit exportFinished(); |
|
|
|
if (m_closeAfterBatch) QTimer::singleShot(0, this, &QWidget::close); |
|
|
|
if (m_closeAfterBatch) QTimer::singleShot(0, this, &QWidget::close); |
|
|
|
@ -583,16 +581,15 @@ void MemberFileBrowser::exportFile(bool clipboard, const QString& destination) { |
|
|
|
if (!clipboard && destination.isEmpty()) { |
|
|
|
if (!clipboard && destination.isEmpty()) { |
|
|
|
QPointer<MemberFileBrowser> guard(this); |
|
|
|
QPointer<MemberFileBrowser> guard(this); |
|
|
|
auto* mime = new DeferredFileMimeData; |
|
|
|
auto* mime = new DeferredFileMimeData; |
|
|
|
mime->localFiles = [guard, id] { |
|
|
|
mime->localFiles = [guard, id, result] { |
|
|
|
if (!guard) return QStringList(); |
|
|
|
if (guard && guard->m_exportId == id) { |
|
|
|
if (guard->m_exportId == id) { |
|
|
|
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: drag waiting for batch id=%llu", (unsigned long long)id); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: drag waiting for batch id=%llu", (unsigned long long)id); |
|
|
|
QEventLoop wait; |
|
|
|
QEventLoop wait; |
|
|
|
QObject::connect(guard, &MemberFileBrowser::exportFinished, &wait, &QEventLoop::quit); |
|
|
|
QObject::connect(guard, &MemberFileBrowser::exportFinished, &wait, &QEventLoop::quit); |
|
|
|
QObject::connect(guard, &QObject::destroyed, &wait, &QEventLoop::quit); |
|
|
|
QObject::connect(guard, &QObject::destroyed, &wait, &QEventLoop::quit); |
|
|
|
wait.exec(); |
|
|
|
wait.exec(); |
|
|
|
} |
|
|
|
} |
|
|
|
return guard ? guard->m_exportResult : QStringList(); |
|
|
|
return *result; |
|
|
|
}; |
|
|
|
}; |
|
|
|
auto* drag = new QDrag(m_entries); drag->setMimeData(mime); drag->setParent(QCoreApplication::instance()); |
|
|
|
auto* drag = new QDrag(m_entries); drag->setMimeData(mime); drag->setParent(QCoreApplication::instance()); |
|
|
|
connect(this, &QObject::destroyed, drag, [] { QDrag::cancel(); }); |
|
|
|
connect(this, &QObject::destroyed, drag, [] { QDrag::cancel(); }); |
|
|
|
|