gui: Options, Scheduler, Speed Limiter, Batch, Grabber, and the tray icon

Continues the build order past the Add-URL/File-Info/Progress dialog flow.

- OptionsDialog: General/Save To/Connection/Downloads/Proxy/Sounds tabs, every
  control bound to a real settings.* key (contracts/schema/types/Settings.
  schema.json). The spec's File Types and Site Logins tabs have no settings.*
  backing (categories go through category.upsert, credentials through the
  Secret Service) so they don't exist here — a tab either binds to a real key
  or isn't shipped. diffChanged() sends only what actually changed, matching
  settings.set's "changed[] names exactly what took effect" contract.
- SchedulerDialog: per-queue schedule (schedule.get/set) plus maxConcurrent/
  onComplete (queue.upsert), Start Now/Stop. Queue.schema.json already carries
  the schedule so queue.list alone seeds the window.
- SpeedLimiterDialog: the live global limiter (limiter.get/set) — a different
  thing from Options' downloads.speedLimit* default. buildParams() enforces
  the schema's "0 with enabled true must not be offered".
- BatchDialog: clipboard-blob and {start..end}-wildcard tabs sharing one
  category/queue/start-mode footer into download.addBatch.
- GrabberWizard: 4-step QWizard (project label -> start URL/depth/filters ->
  file-type filter -> review), grabber.start feeding a poll+event.grabber.
  progress-driven review page, Finish = grabber.harvest for the checked files.
- TrayIcon: active-count tooltip, Show/Add URL/Pause All/Resume All/Speed
  Limiter submenu/Quit. Quit only closes the GUI — there is no RPC to stop
  veloxd itself, filed as a new gap in daemon-requests-m1.md. MainWindow now
  also hides to tray instead of closing when general.minimizeToTray is set.

Every dialog's non-widget logic (diffChanged, buildSchedule, buildParams,
parseUrlBlob/expandWildcard/buildAddBatchParams, buildFileTypes/
buildStartParams/buildHarvestParams) is a static pure function with its own
test, same shape as FileInfoDialog::buildSpec from the previous round.

Verified end-to-end against a running mockd under ASan+UBSan: all five
surfaces render real data (settings.get values, queue.list's two seeded
queues, limiter.get, a live grabber.start/status crawl returning 3 files) with
no sanitizer reports. gui-check (non-ASan) and dev (ASan+UBSan) presets both
build the whole repo clean; all gui-labeled ctest targets pass.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NSCdCWFXBTSBBK3MzWtJiC
This commit is contained in:
2026-09-11 17:17:43 +04:00
co-authored by Claude Sonnet 5
parent 39c69f3871
commit de83ee3cce
22 changed files with 2678 additions and 13 deletions
+103
View File
@@ -0,0 +1,103 @@
#include "dialogs/SpeedLimiterDialog.hpp"
#include <algorithm>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QLabel>
#include <QPointer>
#include <QSpinBox>
#include <QVBoxLayout>
#include "rpc/Protocol.hpp"
#include "rpc/RpcClient.hpp"
namespace velox::gui {
QJsonObject SpeedLimiterDialog::buildParams(bool enabled, int kibps, bool applyToRunning) {
const qint64 bps = enabled ? static_cast<qint64>(std::max(1, kibps)) * 1024 : 0;
return QJsonObject{
{"enabled", enabled},
{"globalBps", bps},
{"applyToRunning", applyToRunning},
};
}
SpeedLimiterDialog::SpeedLimiterDialog(rpc::RpcClient *client, QWidget *parent)
: QDialog(parent),
client_(client),
enabled_(new QCheckBox(tr("Limit download speed"), this)),
kibps_(new QSpinBox(this)),
applyToRunning_(new QCheckBox(tr("Apply to running downloads now"), this)),
statusLabel_(new QLabel(this)) {
setWindowTitle(tr("Speed Limiter"));
kibps_->setRange(1, 1000000);
kibps_->setSuffix(tr(" KiB/s"));
kibps_->setEnabled(false);
connect(enabled_, &QCheckBox::toggled, kibps_, &QWidget::setEnabled);
statusLabel_->setStyleSheet(QStringLiteral("color: #c0392b;"));
statusLabel_->hide();
auto *form = new QFormLayout;
form->addRow(enabled_);
form->addRow(tr("Limit to:"), kibps_);
form->addRow(applyToRunning_);
auto *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(buttons, &QDialogButtonBox::accepted, this, &SpeedLimiterDialog::save);
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
auto *layout = new QVBoxLayout(this);
layout->addLayout(form);
layout->addWidget(statusLabel_);
layout->addWidget(buttons);
setEnabled(false);
QPointer<SpeedLimiterDialog> self(this);
client_->call(QString::fromLatin1(rpc::method::kLimiterGet), {},
[self](const rpc::RpcReply &reply) {
if (!self) {
return;
}
self->setEnabled(true);
if (!reply.ok()) {
self->statusLabel_->setText(
tr("Could not load the limiter: %1").arg(reply.error.message));
self->statusLabel_->show();
return;
}
self->onLoaded(reply.result.toObject());
});
}
void SpeedLimiterDialog::onLoaded(const QJsonObject &limiter) {
const bool on = limiter.value("enabled").toBool();
const qint64 bps = static_cast<qint64>(limiter.value("globalBps").toDouble());
enabled_->setChecked(on);
kibps_->setValue(std::max<qint64>(1, bps / 1024));
kibps_->setEnabled(on);
}
void SpeedLimiterDialog::save() {
const QJsonObject params =
buildParams(enabled_->isChecked(), kibps_->value(), applyToRunning_->isChecked());
QPointer<SpeedLimiterDialog> self(this);
client_->call(QString::fromLatin1(rpc::method::kLimiterSet), params,
[self](const rpc::RpcReply &reply) {
if (!self) {
return;
}
if (!reply.ok()) {
self->statusLabel_->setText(
tr("Could not apply the limit: %1").arg(reply.error.message));
self->statusLabel_->show();
return;
}
self->accept();
});
}
} // namespace velox::gui