feat: render FA6 brain glyph as window icon
This commit is contained in:
parent
c294670df1
commit
5984dec374
30
gui/main.cpp
30
gui/main.cpp
|
|
@ -3,15 +3,43 @@
|
|||
#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(QIcon::fromTheme("utilities-terminal"));
|
||||
app.setWindowIcon(makeBrainIcon());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QQuickStyle::setStyle("org.kde.desktop");
|
||||
|
|
|
|||
Reference in New Issue