69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#include <QGuiApplication>
|
|
#include <QQmlApplicationEngine>
|
|
#include <QQmlContext>
|
|
#include <QQuickStyle>
|
|
#include <QIcon>
|
|
#include <QPixmap>
|
|
#include <QPainter>
|
|
#include <QFont>
|
|
#include <QFontDatabase>
|
|
|
|
#include "olliedbusclient.h"
|
|
|
|
static QIcon makeBrainIcon()
|
|
{
|
|
// Render FA6 brain glyph (U+F5DC) from the installed font
|
|
QFont fa("Font Awesome 6 Free Solid");
|
|
if (!QFontDatabase::hasFamily("Font Awesome 6 Free Solid")) {
|
|
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(200, 200, 200));
|
|
p.drawText(pix.rect(), Qt::AlignCenter, QString(QChar(0xf5dc)));
|
|
p.end();
|
|
icon.addPixmap(pix);
|
|
}
|
|
return icon;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QGuiApplication app(argc, argv);
|
|
app.setApplicationName("ollie");
|
|
app.setOrganizationName("ollie");
|
|
app.setWindowIcon(makeBrainIcon());
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
QQuickStyle::setStyle("org.kde.desktop");
|
|
#endif
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
// Register OllieDBusClient as a singleton
|
|
auto *dbus = new OllieDBusClient(&app);
|
|
engine.rootContext()->setContextProperty("dbus", dbus);
|
|
|
|
#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();
|
|
}
|