gui: RPC client, download table model, and a live main window
First vertical slice of velox-gui, built entirely against tools/mockd (no daemon dependency): - rpc/: RpcConnection runs a QLocalSocket on a worker thread with newline-delimited JSON-RPC framing, drives the session.hello / session.subscribe handshake, and reconnects with exponential backoff (250 ms -> 8 s). RpcClient is the main-thread face: marshals calls onto the worker, delivers replies as main-thread callbacks, re-emits server notifications as typed Qt signals, and issues the one-shot download.list on reaching Connected. - models/DownloadTableModel: QAbstractTableModel over TaskSummary. A progress batch is a row patch with a narrow dataChanged over the value columns only; beginResetModel() is reserved for the initial load and a reconnect resync. - widgets/ProgressDelegate: in-cell progress bar for the Status column. - mainwindow/MainWindow: the table, a status-bar connection dot, an offline banner instead of a modal, dialog-free pause/resume/stop actions, and QSettings column/geometry persistence. - gui/CMakeLists.txt links velox::proto (never velox::core, ADR 0009) and self-guards on the veloxproto target so main keeps configuring if it is ever absent again. - i18n from the first commit: every string via tr(), plus an Arabic .ts stub for the RTL check. - tests/: headless QTest for the model — proves the progress patch is a narrow dataChanged and never resets the model. Verified end-to-end against `mockd --tasks 300`: handshake, initial list, live progress batches applied to the model, and a clean Reconnecting -> Connected recovery when mockd is bounced mid-run. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Ne28kx4VreeBWZv82Nksd
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// velox-gui entry point. Lane GUI.
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLibraryInfo>
|
||||
#include <QLocale>
|
||||
#include <QString>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "mainwindow/MainWindow.hpp"
|
||||
#include "rpc/Protocol.hpp"
|
||||
#include "rpc/RpcClient.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
QString defaultSocketPath() {
|
||||
const QString override = qEnvironmentVariable("VELOX_SOCK");
|
||||
if (!override.isEmpty()) {
|
||||
return override;
|
||||
}
|
||||
QString runtimeDir = qEnvironmentVariable("XDG_RUNTIME_DIR");
|
||||
if (runtimeDir.isEmpty()) {
|
||||
runtimeDir = QStringLiteral("/run/user/%1").arg(getuid());
|
||||
}
|
||||
return runtimeDir + QStringLiteral("/velox/velox.sock");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
QApplication app(argc, argv);
|
||||
QApplication::setApplicationName(QStringLiteral("velox-gui"));
|
||||
QApplication::setOrganizationName(QStringLiteral("velox"));
|
||||
QApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
||||
|
||||
qRegisterMetaType<velox::gui::rpc::ConnectionState>();
|
||||
qRegisterMetaType<velox::gui::rpc::RpcReply>();
|
||||
|
||||
// i18n from the first commit: load the bundled catalogue for the system locale.
|
||||
// The Arabic stub (i18n/velox_ar.ts) exists to prove the RTL layout survives.
|
||||
QTranslator translator;
|
||||
const QString locale = QLocale::system().name();
|
||||
if (translator.load(QStringLiteral("velox_") + locale, QStringLiteral(":/i18n"))) {
|
||||
app.installTranslator(&translator);
|
||||
}
|
||||
|
||||
velox::gui::rpc::RpcClient client(defaultSocketPath());
|
||||
velox::gui::MainWindow window(&client);
|
||||
window.show();
|
||||
client.start();
|
||||
|
||||
return QApplication::exec();
|
||||
}
|
||||
Reference in New Issue
Block a user