This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-kde/gui/main.cpp

52 lines
1.7 KiB
C++

// ollie-gui-9p: minimal Qt GUI using 9P for all communication.
// Uses ollie-9p subprocess for 9P transport.
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
#include "ollie9pclient.h"
#include "chatblockmodel.h"
#include "thememanager.h"
#include "clipboardhelper.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QApplication app(argc, argv);
app.setApplicationName("ollie-gui");
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE"))
QQuickStyle::setStyle("Basic");
QQmlApplicationEngine engine;
auto *ollie = new Ollie9pClient(&app);
auto *chatModel = new ChatBlockModel(&app);
auto *theme = new ThemeManager(&app);
auto *clipboard = new ClipboardHelper(&app);
// Route chat stream to the block model.
// Reset + reload is handled in QML's onActiveSessionIdChanged so the
// readLogForSession 9P call is sequenced correctly; the C++ slot would
// fire before the QML handler and race against the log read.
QObject::connect(ollie, &Ollie9pClient::chatReceived, chatModel, &ChatBlockModel::appendData);
engine.rootContext()->setContextProperty("ollie", ollie);
engine.rootContext()->setContextProperty("chatModel", chatModel);
engine.rootContext()->setContextProperty("theme", theme);
engine.rootContext()->setContextProperty("clipboard", clipboard);
const QUrl url(QStringLiteral("qrc:/main.qml"));
engine.load(url);
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}