Validate batch snapshots and freeze deletion confirmation context
This commit is contained in:
1 parent
8785fc358a
commit
1ed467d236
3 files changed
+17
-8
No files matched your search
@@ -547,7 +547,7 @@ void MemberFileBrowser::publishExport(const QStringList& paths, bool clipboard)
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "file browser: exporting entries=%d clipboard=%d", int(paths.size()), clipboard);
|
||||
if (clipboard) {
|
||||
QGuiApplication::clipboard()->setMimeData(mime);
|
||||
m_status->setText(text("File 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);
|
||||
}
|
||||
@@ -556,14 +556,19 @@ void MemberFileBrowser::publishExport(const QStringList& paths, bool clipboard)
|
||||
void MemberFileBrowser::exportFile(bool clipboard, const QString& destination) {
|
||||
if (!m_copyAction->isEnabled()) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "file browser: export unavailable");
|
||||
m_status->setText(text("Select a file and finish the current transfer first")); return;
|
||||
m_status->setText(text("Select entries and finish the current transfer first")); return;
|
||||
}
|
||||
auto entries = selectedEntries(); if (entries.isEmpty()) return;
|
||||
QString base = destination.isEmpty() ? QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/file-exports" : destination;
|
||||
QString base = destination.isEmpty() ? QStandardPaths::writableLocation(QStandardPaths::CacheLocation) : destination;
|
||||
if (base.isEmpty()) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "file browser: export has no cache location");
|
||||
m_status->setText(text("Cannot prepare a local copy")); return;
|
||||
}
|
||||
if (destination.isEmpty()) base += "/file-exports";
|
||||
m_exportId = requestId(); m_exportResult.clear(); m_openAfter = false;
|
||||
quint64 id = m_exportId;
|
||||
auto* batch = createBatch(MemberFileBatch::Download);
|
||||
batch->finished = [this, batch, clipboard, destination](bool ok, const QString& summary, const QStringList& roots) {
|
||||
batch->finished = [this, batch, clipboard](bool ok, const QString& summary, const QStringList& roots) {
|
||||
m_batch = nullptr; m_exportId = 0; m_progress->hide(); m_uploadStatus->setText(summary);
|
||||
m_exportResult = ok ? roots : QStringList(); batch->deleteLater(); updateActions();
|
||||
if (ok && clipboard) publishExport(roots, true);
|
||||
@@ -637,10 +642,13 @@ void MemberFileBrowser::mutate(uint8_t command) {
|
||||
if (command == MF_REMOVE_PATH) {
|
||||
auto entries = selectedEntries(); if (entries.isEmpty()) return;
|
||||
QPointer<MemberFileBrowser> guard(this);
|
||||
m_dropId = requestId(); updateActions();
|
||||
QString prompt = entries.size() == 1 ? text("Delete %1?").arg(entries.first().remote) :
|
||||
text("Delete %1 selected entries? Non-empty folders will not be removed.").arg(entries.size());
|
||||
auto answer = QMessageBox::question(this, text("Delete"), prompt, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||
if (!guard || answer != QMessageBox::Yes) return;
|
||||
if (!guard) return;
|
||||
bool cancelled = !m_dropId; m_dropId = 0; updateActions();
|
||||
if (cancelled || answer != QMessageBox::Yes) return;
|
||||
auto* batch = createBatch(MemberFileBatch::Remove);
|
||||
batch->finished = [this, batch](bool, const QString& summary, const QStringList&) {
|
||||
m_batch = nullptr; m_progress->hide(); m_uploadStatus->setText(summary); batch->deleteLater(); updateActions(); refresh();
|
||||
|
||||
Reference in new issue
Block a user