gui: finish Add URL -> File Info -> Progress dialog flow
Wires up the three dialogs from build order step 5 (docs/03-gui-spec.md §§2-3) and the MainWindow slots that were declared but never implemented: - AddUrlDialog: clipboard prefill is the explicit path docs/06 R2 calls for (no passive monitoring, not advertised). - FileInfoDialog: async download.probe never blocks the UI; ends by calling download.add itself (Now / Later / Add to Queue). buildSpec() is a pure static so the optional-field-omission logic is unit-testable without touching a widget. - ProgressDialog: non-modal, WA_DeleteOnClose, driven by the taskProgress/ taskStateChanged signals RpcClient already re-broadcasts; download.get seeds state once for a dialog opened mid-transfer. Hosts SegmentBarsWidget and SpeedGraphWidget. MainWindow: openAddUrlDialog/openPropertiesForSelection/showTableContextMenu now have bodies; category.list/queue.list responses are cached so File Info can populate its category combo and queue menu without a second round trip. The row context menu covers what already exists (Resume/Pause/Stop/Delete/ Properties) and deliberately leaves out Open/Open With/Move-Rename/ Redownload/Add to Queue — those need dialogs later build-order steps haven't reached yet. util/Format.hpp: pulled the bytes/rate/eta formatting out of MainWindow and DownloadTableModel once the dialogs wanted the same strings a third time. Verified end-to-end against a running mockd (category.list/queue.list, download.probe, download.add, download.get, and live event.task.progress/ event.task.state) under ASan+UBSan: all three dialogs render correctly against real fixture data and the flow runs clean with no leaks or sanitizer reports. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NSCdCWFXBTSBBK3MzWtJiC
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Shared human-readable formatting. Lane GUI.
|
||||
//
|
||||
// Pulled out once three places (the table model, the main window status bar, the
|
||||
// progress dialog) all wanted the same "bytes / rate / eta" strings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QLocale>
|
||||
#include <QString>
|
||||
|
||||
namespace velox::gui::fmt {
|
||||
|
||||
inline QString bytes(qint64 n) {
|
||||
if (n < 0) {
|
||||
return QStringLiteral("—");
|
||||
}
|
||||
return QLocale().formattedDataSize(n, 2, QLocale::DataSizeIecFormat);
|
||||
}
|
||||
|
||||
inline QString rate(qint64 bytesPerSec) {
|
||||
if (bytesPerSec <= 0) {
|
||||
return QCoreApplication::translate("velox::gui::fmt", "0 B/s");
|
||||
}
|
||||
return QCoreApplication::translate("velox::gui::fmt", "%1/s")
|
||||
.arg(QLocale().formattedDataSize(bytesPerSec, 1, QLocale::DataSizeIecFormat));
|
||||
}
|
||||
|
||||
/// HH:MM:SS, or empty for a negative (unknown) eta.
|
||||
inline QString eta(qint64 secs) {
|
||||
if (secs < 0) {
|
||||
return QString();
|
||||
}
|
||||
const qint64 h = secs / 3600;
|
||||
const qint64 m = (secs % 3600) / 60;
|
||||
const qint64 s = secs % 60;
|
||||
return QStringLiteral("%1:%2:%3")
|
||||
.arg(h, 2, 10, QLatin1Char('0'))
|
||||
.arg(m, 2, 10, QLatin1Char('0'))
|
||||
.arg(s, 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
} // namespace velox::gui::fmt
|
||||
Reference in New Issue
Block a user