|
|
|
|
@ -130,7 +130,6 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
|
|
|
|
m_dropHint->setAttribute(Qt::WA_TransparentForMouseEvents); m_dropHint->setAlignment(Qt::AlignCenter); |
|
|
|
|
m_dropHint->setStyleSheet("QLabel { border: 2px dashed palette(highlight); background: palette(window); color: palette(text); }"); |
|
|
|
|
m_dropHint->setText(text("Copy to my files")); m_dropHint->hide(); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: drop targets installed count=%d", int(dropTargets.size())); |
|
|
|
|
connect(reload, &QPushButton::clicked, this, [this]() { m_staleRetries = 0; refresh(); }); |
|
|
|
|
connect(up, &QPushButton::clicked, this, [this]() { |
|
|
|
|
m_entries->setFocus(); |
|
|
|
|
@ -150,13 +149,11 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
|
|
|
|
auto* removeShortcut = new QShortcut(QKeySequence(Qt::Key_Delete), m_entries); |
|
|
|
|
removeShortcut->setContext(Qt::WidgetWithChildrenShortcut); removeShortcut->setAutoRepeat(false); |
|
|
|
|
connect(removeShortcut, &QShortcut::activated, this, [this] { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: Delete key path=%s enabled=%d", qPrintable(selectedPath()), m_remove->isEnabled()); |
|
|
|
|
m_remove->click(); |
|
|
|
|
}); |
|
|
|
|
auto* upShortcut = new QShortcut(QKeySequence(Qt::Key_Backspace), m_entries); |
|
|
|
|
upShortcut->setContext(Qt::WidgetWithChildrenShortcut); upShortcut->setAutoRepeat(false); |
|
|
|
|
connect(upShortcut, &QShortcut::activated, this, [this, up] { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: Backspace key path=%s enabled=%d", qPrintable(m_path), up->isEnabled()); |
|
|
|
|
up->click(); |
|
|
|
|
}); |
|
|
|
|
for (auto key : {Qt::Key_Return, Qt::Key_Enter}) { |
|
|
|
|
@ -164,7 +161,6 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
|
|
|
|
enterShortcut->setContext(Qt::WidgetWithChildrenShortcut); enterShortcut->setAutoRepeat(false); |
|
|
|
|
connect(enterShortcut, &QShortcut::activated, this, [this] { |
|
|
|
|
auto* item = m_entries->currentItem(); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: Enter key path=%s selected=%d", qPrintable(selectedPath()), item != nullptr); |
|
|
|
|
if (item) enter(item); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
@ -289,7 +285,7 @@ void MemberFileBrowser::updateActions() {
|
|
|
|
|
|
|
|
|
|
bool MemberFileBrowser::post(mf_message& message) { |
|
|
|
|
if (!m_group || !server() || !gui_bridge_is_uasync_ready()) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI post rejected cmd=%s group=%llx server=%llx ready=%d", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI post rejected cmd=%s group=%llx server=%llx ready=%d", |
|
|
|
|
mf_command_text(message.command), (unsigned long long)m_group, (unsigned long long)server(), gui_bridge_is_uasync_ready()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -297,7 +293,7 @@ bool MemberFileBrowser::post(mf_message& message) {
|
|
|
|
|
if (!q) { DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "file browser: request allocation failed"); return false; } |
|
|
|
|
message.request_id = requestId(); message.kind = MF_REQUEST; |
|
|
|
|
q->inst = gui_bridge_get_inst(); q->group = m_group; q->server = server(); q->message = message; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI post id=%llu cmd=%s group=%llx server=%llx owner=%llx path=%s", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI post id=%llu cmd=%s group=%llx server=%llx owner=%llx path=%s", |
|
|
|
|
(unsigned long long)message.request_id, mf_command_text(message.command), (unsigned long long)m_group, |
|
|
|
|
(unsigned long long)server(), (unsigned long long)message.owner, message.path); |
|
|
|
|
gui_bridge_post_uasync_fn(member_files_gui_request, q); return true; |
|
|
|
|
@ -321,7 +317,7 @@ void MemberFileBrowser::requestQuota() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MemberFileBrowser::refresh() { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI refresh old_id=%llu group=%llx server=%llx owner=%llx path=%s", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI refresh old_id=%llu group=%llx server=%llx owner=%llx path=%s", |
|
|
|
|
(unsigned long long)m_listId, (unsigned long long)m_group, (unsigned long long)server(), (unsigned long long)owner(), qPrintable(m_path)); |
|
|
|
|
cancelRequest(m_listId); m_listId = 0; m_entries->clear(); m_location->setText(m_path); updateActions(); |
|
|
|
|
cancelRequest(m_quotaId); m_quotaId = 0; m_refreshGeneration++; |
|
|
|
|
@ -355,21 +351,21 @@ void MemberFileBrowser::enter(QTreeWidgetItem* item) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MemberFileBrowser::onResponse(const uint8_t* data, int length) { |
|
|
|
|
if (!data || length < 16) { DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI short response bytes=%d", length); return; } |
|
|
|
|
if (!data || length < 16) { DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "member_files: GUI short response bytes=%d", length); return; } |
|
|
|
|
if (mf_get64(data) != m_group || mf_get64(data + 8) != server()) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI response ignored context group=%llx/%llx server=%llx/%llx", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI response ignored context group=%llx/%llx server=%llx/%llx", |
|
|
|
|
(unsigned long long)mf_get64(data), (unsigned long long)m_group, |
|
|
|
|
(unsigned long long)mf_get64(data + 8), (unsigned long long)server()); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
mf_message r{}; if (mf_decode(data + 16, (size_t)length - 16, &r)) return; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI response id=%llu list_id=%llu cmd=%s status=%s bytes=%u owner=%llx/%llx path=%s", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI response id=%llu list_id=%llu cmd=%s status=%s bytes=%u owner=%llx/%llx path=%s", |
|
|
|
|
(unsigned long long)r.request_id, (unsigned long long)m_listId, mf_command_text(r.command), mf_status_text(r.status), r.data_len, |
|
|
|
|
(unsigned long long)r.owner, (unsigned long long)owner(), r.path); |
|
|
|
|
if (m_batch && m_batch->response(r)) return; |
|
|
|
|
if (r.command == MF_QUOTA) { |
|
|
|
|
if (r.request_id != m_quotaId || r.owner != owner()) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI stale quota response id=%llu", (unsigned long long)r.request_id); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI stale quota response id=%llu", (unsigned long long)r.request_id); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
m_quotaId = 0; |
|
|
|
|
@ -393,7 +389,7 @@ void MemberFileBrowser::onResponse(const uint8_t* data, int length) {
|
|
|
|
|
m_quota->setText(label); |
|
|
|
|
m_quota->setToolTip(text("Used: %1 bytes\nLimit: %2 bytes\nReserved: %3 bytes\nFiles: %4\nDirectories: %5") |
|
|
|
|
.arg(used).arg(limit).arg(reserved).arg(files).arg(directories)); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, |
|
|
|
|
"member_files: GUI quota owner=%llu used=%llu limit=%llu reserved=%llu files=%llu directories=%llu", |
|
|
|
|
(unsigned long long)owner(), (unsigned long long)used, (unsigned long long)limit, (unsigned long long)reserved, |
|
|
|
|
(unsigned long long)files, (unsigned long long)directories); |
|
|
|
|
@ -434,13 +430,13 @@ void MemberFileBrowser::onResponse(const uint8_t* data, int length) {
|
|
|
|
|
} else { |
|
|
|
|
m_listId = 0; m_entries->setSortingEnabled(true); m_entries->sortItems(0, Qt::AscendingOrder); |
|
|
|
|
m_status->setText(text("%1 entries").arg(m_entries->topLevelItemCount())); updateActions(); |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI directory ready id=%llu entries=%d", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI directory ready id=%llu entries=%d", |
|
|
|
|
(unsigned long long)r.request_id, m_entries->topLevelItemCount()); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!m_actions.contains(r.request_id)) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "member_files: GUI response ignored stale id=%llu cmd=%s", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_MEDIA, "member_files: GUI response ignored stale id=%llu cmd=%s", |
|
|
|
|
(unsigned long long)r.request_id, mf_command_text(r.command)); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -583,7 +579,7 @@ void MemberFileBrowser::exportFile(bool clipboard, const QString& destination) {
|
|
|
|
|
auto* mime = new DeferredFileMimeData; |
|
|
|
|
mime->localFiles = [guard, id, result] { |
|
|
|
|
if (guard && 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_MEDIA, "file browser: drag waiting for batch id=%llu", (unsigned long long)id); |
|
|
|
|
QEventLoop wait; |
|
|
|
|
QObject::connect(guard, &MemberFileBrowser::exportFinished, &wait, &QEventLoop::quit); |
|
|
|
|
QObject::connect(guard, &QObject::destroyed, &wait, &QEventLoop::quit); |
|
|
|
|
|