#include #include #include #include #include #include #include #include #include #include "olliedbusclient.h" #include "thememanager.h" static QIcon makeBrainIcon() { // Use the theme icon if available (from hicolor scalable/apps/ollie.svg) if (QIcon::hasThemeIcon("ollie")) return QIcon::fromTheme("ollie"); // Fallback: render FA6 brain glyph from installed font QFont fa("Font Awesome 6 Free Solid"); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (!QFontDatabase::hasFamily("Font Awesome 6 Free Solid")) { #else if (!QFontDatabase().families().contains("Font Awesome 6 Free Solid")) { #endif fa = QFont("Font Awesome 6 Free"); fa.setWeight(QFont::Black); } QIcon icon; for (int size : {16, 22, 32, 48, 64, 128}) { QPixmap pix(size, size); pix.fill(Qt::transparent); QPainter p(&pix); fa.setPixelSize(size - 2); p.setFont(fa); p.setPen(QColor(0xe9, 0x1e, 0x63)); p.drawText(pix.rect(), Qt::AlignCenter, QString(QChar(0xf5dc))); p.end(); icon.addPixmap(pix); } return icon; } int main(int argc, char *argv[]) { // HiDPI support #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication app(argc, argv); app.setApplicationName("ollie-gui"); app.setDesktopFileName("org.ollie.gui"); app.setOrganizationName("ollie"); app.setWindowIcon(makeBrainIcon()); // Don't force org.kde.desktop style — it ignores explicit palette overrides. // Let the platform theme provide the style, or fall back to Basic which // properly respects the QML palette {} block. if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) QQuickStyle::setStyle("Basic"); // Theme manager — reads KDE color schemes, applies palette auto *theme = new ThemeManager(&app); QQmlApplicationEngine engine; // Register OllieDBusClient as a singleton auto *dbus = new OllieDBusClient(&app); engine.rootContext()->setContextProperty("dbus", dbus); engine.rootContext()->setContextProperty("theme", theme); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) const QUrl url(QStringLiteral("qrc:/gui/main.qml")); #else const QUrl url(QStringLiteral("qrc:/main.qml")); #endif QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }