Skip to content

Commit d25bcb5

Browse files
committed
[Core] Load font from database
1 parent 2682850 commit d25bcb5

File tree

12 files changed

+30
-58
lines changed

12 files changed

+30
-58
lines changed

src/controls/qml/Button.qml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,14 @@ Button {
9797

9898
// The label of the button.
9999
contentItem: Text {
100-
FontLoader {
101-
id: localFont
102-
source: "file://"+Theme.fontPath
103-
}
104-
105100
verticalAlignment: Text.AlignVCenter
106101
horizontalAlignment: Text.AlignHCenter
107102
text: control.text
108103
color: Theme.textColor
109104
font.pixelSize: Theme.fontSizeMedium
110105
font.weight: control.primary ? Theme.fontWeightLarge : Theme.fontWeightMedium
111-
font.family: localFont.font.family
112-
font.styleName: localFont.font.styleName
106+
font.family: Theme.fontFamily
107+
font.styleName: Theme.fontStyleName
113108
opacity: control.enabled ? 1.0 : 0.7
114109
}
115110
}

src/controls/qml/HeaderToolsLayout.qml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ Item {
7777

7878
Label {
7979
id: titleTxt
80-
FontLoader {
81-
id: localFont
82-
source: "file://"+Theme.fontPath
83-
}
80+
font.family: Theme.fontFamily
81+
font.styleName: Theme.fontStyleName
8482
anchors{
8583
right: toolButtonsContainer.left
8684
left: backButton.visible ? backButton.right : parent.left

src/controls/qml/Label.qml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ import QtQuick 2.6
3333
import Nemo
3434

3535
Text {
36-
FontLoader {
37-
id: localFont
38-
source: "file://"+Theme.fontPath
39-
}
4036
color: Theme.textColor
4137
font.pixelSize: Theme.fontSizeMedium
42-
font.family: localFont.font.family
43-
font.styleName: localFont.font.styleName
38+
font.family: Theme.fontFamily
39+
font.styleName: Theme.fontStyleName
4440
elide: horizontalAlignment == Text.AlignLeft ? Text.ElideRight : (horizontalAlignment == Text.AlignRight ? Text.ElideLeft : Text.ElideMiddle)
4541
}

src/controls/qml/ListView.qml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,8 @@ ListView {
5252
Text {
5353
id: sectionText
5454
text: section
55-
FontLoader {
56-
id: localFont
57-
source: Theme.fontPath
58-
}
59-
font.family: localFont.font.family
60-
font.styleName: localFont.font.styleName
55+
font.family: Theme.fontFamily
56+
font.styleName: Theme.fontStyleName
6157
font.capitalization: Font.AllUppercase
6258
font.pixelSize: Theme.fontSizeSmall
6359
color: Theme.textColor

src/controls/qml/TabButton.qml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@ TabButton {
5454
}
5555

5656
contentItem: Text {
57-
FontLoader {
58-
id: localFont
59-
source: "file://"+Theme.fontPath
60-
}
61-
font.family: localFont.font.family
62-
font.styleName: localFont.font.styleName
57+
font.family: Theme.fontFamily
58+
font.styleName: Theme.fontStyleName
6359
anchors.fill: parent
6460
color: (control.checked) ? Theme.accentColor : Theme.textColor
6561
text: control.text.toUpperCase()

src/controls/qml/TextField.qml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@ TextField {
4141
selectedTextColor: Theme.textColor
4242
selectionColor: Theme.accentColor
4343
font.pixelSize: Theme.fontSizeMedium
44-
font.family: localFont.font.family
45-
font.styleName: localFont.font.styleName
44+
font.family: Theme.fontFamily
45+
font.styleName: Theme.fontStyleName
4646
placeholderTextColor: Theme.fillColor
4747

48-
FontLoader {
49-
id: localFont
50-
source: "file://"+Theme.fontPath
51-
}
52-
5348
onActiveFocusChanged: {
5449
if(activeFocus) {
5550
NemoFocus.nemoregister(this)

src/controls/qml/ToolButton.qml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ Item {
7878

7979
Text {
8080
id: counterText
81-
FontLoader {
82-
id: localFont
83-
source: "file://"+Theme.fontPath
84-
}
85-
font.family: localFont.font.family
86-
font.styleName: localFont.font.styleName
81+
font.family: Theme.fontFamily
82+
font.styleName: Theme.fontStyleName
8783

8884
text: toolButton.counterValue >= 100 ? "99+" : toolButton.counterValue
8985
color: Theme.textColor

src/core/nemo.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"fontSizeTiny" : 14 ,
2323
"fontWeightLarge" : 63,
2424
"fontWeightMedium" : 25,
25-
"fontPath" : "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf",
25+
"fontFamily" : "OpenSans",
26+
"fontStyleName" : "Regular",
2627
"accentColor" : "#0091e5",
2728
"fillColor" : "#474747",
2829
"fillDarkColor" : "#313131",

src/core/theme.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,8 @@ void Theme::setThemeValues()
168168
m_fontSizeTiny = floor(theme.value("fontSizeTiny").toInt());
169169
m_fontWeightLarge = theme.value("fontWeightLarge").toInt();
170170
m_fontWeightMedium = theme.value("fontWeightMedium").toInt();
171-
172-
QFile fontFile;
173-
fontFile.setFileName(theme.value("fontPath").toString());
174-
if (!themeFile.exists()) {
175-
qCWarning(lcNemoControlsCoreLog) << "Font file " << fontFile.fileName() << " not found";
176-
} else {
177-
m_fontPath = theme.value("fontPath").toString();
178-
updated = true;
179-
}
171+
m_fontFamily = theme.value("fontFamily").toString();
172+
m_fontStyleName = theme.value("fontStyleName").toString();
180173
m_accentColor = theme.value("accentColor").toString();
181174
m_fillColor = theme.value("fillColor").toString();
182175
m_fillDarkColor = theme.value("fillDarkColor").toString();
@@ -225,7 +218,8 @@ void Theme::loadDefaultValue()
225218
m_fontSizeTiny = 14;
226219
m_fontWeightLarge = 63;
227220
m_fontWeightMedium = 25;
228-
m_fontPath = "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf";
221+
m_fontFamily = "OpenSans";
222+
m_fontStyleName = "Regular";
229223

230224
m_accentColor = "#0091e5";
231225
m_fillColor = "#474747";

src/core/theme.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class Theme : public QObject {
6060
Q_PROPERTY(int fontWeightLarge READ fontWeightLarge NOTIFY themeUpdated)
6161
Q_PROPERTY(int fontWeightMedium READ fontWeightMedium NOTIFY themeUpdated)
6262

63-
Q_PROPERTY(QString fontPath READ fontPath NOTIFY themeUpdated)
63+
Q_PROPERTY(QString fontFamily READ fontFamily NOTIFY themeUpdated)
64+
Q_PROPERTY(QString fontStyleName READ fontStyleName NOTIFY themeUpdated)
6465

6566
Q_PROPERTY(QString accentColor READ accentColor NOTIFY themeUpdated)
6667
Q_PROPERTY(QString fillColor READ fillColor NOTIFY themeUpdated)
@@ -105,7 +106,8 @@ class Theme : public QObject {
105106
int fontWeightLarge() const { return m_fontWeightLarge * m_dpScaleFactor; }
106107
int fontWeightMedium() const { return m_fontWeightMedium * m_dpScaleFactor; }
107108

108-
QString fontPath() const { return m_fontPath; }
109+
QString fontFamily() const { return m_fontFamily; }
110+
QString fontStyleName() const { return m_fontStyleName; }
109111

110112
QString accentColor() const { return m_accentColor; }
111113
QString fillColor() const { return m_fillColor; }
@@ -157,7 +159,8 @@ private slots:
157159
int m_fontSizeTiny; // 16
158160
int m_fontWeightLarge; // 63
159161
int m_fontWeightMedium; // 25
160-
QString m_fontPath; //???
162+
QString m_fontFamily; // OpenSans
163+
QString m_fontStyleName; // Regular
161164

162165
QString m_accentColor; // #0091e5
163166
QString m_fillColor; // #474747

0 commit comments

Comments
 (0)