Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
theme.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025-2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4#include <QFontDatabase>
5
6#include "theme.h"
7
8Theme::Theme(QObject *parent)
9 : QObject(parent)
10{
11 registerFonts();
12}
13
15{
16 unregisterFonts();
17}
18
20{
21 if (m_symbolsOutlinedFontId == -1)
22 return QString();
23 return QFontDatabase::applicationFontFamilies(m_symbolsOutlinedFontId).value(0);
24}
25
27{
28 if (m_symbolsRoundedFontId == -1)
29 return QString();
30 return QFontDatabase::applicationFontFamilies(m_symbolsRoundedFontId).value(0);
31}
32
34{
35 if (m_symbolsSharpFontId == -1)
36 return QString();
37 return QFontDatabase::applicationFontFamilies(m_symbolsSharpFontId).value(0);
38}
39
40void Theme::registerFonts()
41{
42 if (m_symbolsOutlinedFontId == -1)
43 m_symbolsOutlinedFontId = QFontDatabase::addApplicationFont(
44 ":/Fluid/assets/fonts/MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf");
45 if (m_symbolsRoundedFontId == -1)
46 m_symbolsRoundedFontId = QFontDatabase::addApplicationFont(
47 ":/Fluid/assets/fonts/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf");
48 if (m_symbolsSharpFontId == -1)
49 m_symbolsSharpFontId = QFontDatabase::addApplicationFont(
50 ":/Fluid/assets/fonts/MaterialSymbolsSharp[FILL,GRAD,opsz,wght].ttf");
51}
52
53void Theme::unregisterFonts()
54{
55 if (m_symbolsOutlinedFontId != -1) {
56 QFontDatabase::removeApplicationFont(m_symbolsOutlinedFontId);
57 m_symbolsOutlinedFontId = -1;
58 }
59 if (m_symbolsRoundedFontId != -1) {
60 QFontDatabase::removeApplicationFont(m_symbolsRoundedFontId);
61 m_symbolsRoundedFontId = -1;
62 }
63 if (m_symbolsSharpFontId != -1) {
64 QFontDatabase::removeApplicationFont(m_symbolsSharpFontId);
65 m_symbolsSharpFontId = -1;
66 }
67}
QString symbolsRoundedFontFamily
Definition theme.h:14
QString symbolsSharpFontFamily
Definition theme.h:15
Theme(QObject *parent=nullptr)
Definition theme.cpp:8
QString symbolsOutlinedFontFamily
Definition theme.h:13
~Theme()
Definition theme.cpp:14