Skip to content

Commit 85e5f55

Browse files
committed
Theme: theme style/font/padding handling updated
1 parent 380a6c4 commit 85e5f55

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

storybook/main.qml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import QtQuick.Dialogs
1111
import QtMultimedia
1212

1313
ApplicationWindow {
14+
id: root
15+
1416
width: 1450
1517
height: 840
1618
visible: true
@@ -26,7 +28,7 @@ ApplicationWindow {
2628

2729
anchors.fill: parent
2830

29-
onDarkModeChanged: Theme.changeTheme(darkMode ? Theme.Style.Dark
30-
: Theme.Style.Light)
31+
onDarkModeChanged: ThemeUtils.changeTheme(root, darkMode ? ThemeUtils.Style.Dark
32+
: ThemeUtils.Style.Light)
3133
}
3234
}

storybook/pages/NotificationCardBaseEditor.qml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import QtQuick.Controls
33
import QtQuick.Layouts
44

55
import StatusQ.Core.Theme
6+
import QtQuick.Window
67

78

89
Control {
@@ -48,15 +49,15 @@ Control {
4849
Layout.leftMargin: Theme.padding
4950
text: "XS"
5051
onCheckedChanged: {
51-
Theme.changeFontSize(ThemeUtils.FontSize.FontSizeXS)
52+
ThemeUtils.setFontSize(Window.window, ThemeUtils.FontSize.FontSizeXS)
5253
}
5354
}
5455

5556
RadioButton {
5657
Layout.leftMargin: Theme.padding
5758
text: "S"
5859
onCheckedChanged: {
59-
Theme.changeFontSize(ThemeUtils.FontSize.FontSizeS)
60+
ThemeUtils.setFontSize(Window.window, ThemeUtils.FontSize.FontSizeS)
6061
}
6162
}
6263

@@ -65,31 +66,31 @@ Control {
6566
text: "M"
6667
checked: true
6768
onCheckedChanged: {
68-
Theme.changeFontSize(ThemeUtils.FontSize.FontSizeM)
69+
ThemeUtils.setFontSize(Window.window, ThemeUtils.FontSize.FontSizeM)
6970
}
7071
}
7172

7273
RadioButton {
7374
Layout.leftMargin: Theme.padding
7475
text: "L"
7576
onCheckedChanged: {
76-
Theme.changeFontSize(ThemeUtils.FontSize.FontSizeL)
77+
ThemeUtils.setFontSize(Window.window, ThemeUtils.FontSize.FontSizeL)
7778
}
7879
}
7980

8081
RadioButton {
8182
Layout.leftMargin: Theme.padding
8283
text: "XL"
8384
onCheckedChanged: {
84-
Theme.changeFontSize(ThemeUtils.FontSize.FontSizeXL)
85+
ThemeUtils.setFontSize(Window.window, ThemeUtils.FontSize.FontSizeXL)
8586
}
8687
}
8788

8889
RadioButton {
8990
Layout.leftMargin: Theme.padding
9091
text: "XXL"
9192
onCheckedChanged: {
92-
Theme.changeFontSize(ThemeUtils.FontSize.FontSizeXXL)
93+
ThemeUtils.setFontSize(Window.window, ThemeUtils.FontSize.FontSizeXXL)
9394
}
9495
}
9596

ui/app/AppLayouts/Profile/ProfileLayout.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ StatusSectionLayout {
8787

8888
required property bool isCentralizedMetricsEnabled
8989

90-
required property int theme // Theme.Style.xxx
90+
required property int theme // ThemeUtils.Style.xxx
9191
required property int fontSize // ThemeUtils.FontSize.xxx
9292
required property int paddingFactor // ThemeUtils.PaddingFactor.xxx
9393

ui/app/AppLayouts/Profile/views/AppearanceView.qml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import StatusQ.Controls as StatusQ
1515
SettingsContentBase {
1616
id: root
1717

18-
required property int theme // Theme.Style.xxx
18+
required property int theme // ThemeUtils.Style.xxx
1919
required property int fontSize // ThemeUtils.FontSize.xxx
2020
required property int paddingFactor // ThemeUtils.PaddingFactor.xxx
2121

@@ -139,10 +139,10 @@ SettingsContentBase {
139139
Layout.fillWidth: true
140140
image.source: Assets.png("appearance-light")
141141
control.text: qsTr("Light")
142-
control.checked: root.theme === Theme.Style.Light
142+
control.checked: root.theme === ThemeUtils.Style.Light
143143
onRadioCheckedChanged: function(checked) {
144144
if (checked) {
145-
root.themeChangeRequested(Theme.Style.Light)
145+
root.themeChangeRequested(ThemeUtils.Style.Light)
146146
}
147147
}
148148
}
@@ -151,10 +151,10 @@ SettingsContentBase {
151151
Layout.fillWidth: true
152152
image.source: Assets.png("appearance-dark")
153153
control.text: qsTr("Dark")
154-
control.checked: root.theme === Theme.Style.Dark
154+
control.checked: root.theme === ThemeUtils.Style.Dark
155155
onRadioCheckedChanged: function(checked) {
156156
if (checked) {
157-
root.themeChangeRequested(Theme.Style.Dark)
157+
root.themeChangeRequested(ThemeUtils.Style.Dark)
158158
}
159159
}
160160
}
@@ -163,10 +163,10 @@ SettingsContentBase {
163163
Layout.fillWidth: true
164164
image.source: Assets.png("appearance-system")
165165
control.text: qsTr("System")
166-
control.checked: root.theme === Theme.Style.System
166+
control.checked: root.theme === ThemeUtils.Style.System
167167
onRadioCheckedChanged: function(checked) {
168168
if (checked) {
169-
root.themeChangeRequested(Theme.Style.System)
169+
root.themeChangeRequested(ThemeUtils.Style.System)
170170
}
171171
}
172172
}

ui/app/mainui/AppMain.qml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import QtQuick
44

55
import QtQuick.Controls
66
import QtQuick.Layouts
7+
import QtQuick.Window
78
import QtQml.Models
89

910
import AppLayouts.Browser
@@ -868,7 +869,7 @@ Item {
868869
property bool enableMessageBackupPopupSeen
869870
property var recentEmojis
870871
property string skinColor // NB: must be a string for the twemoji lib to work; we don't want the `#` in the name
871-
property int theme: Theme.Style.System
872+
property int theme: ThemeUtils.Style.System
872873
property int fontSize: {
873874
if (appMain.width < ThemeUtils.portraitBreakpoint.width) {
874875
return ThemeUtils.FontSize.FontSizeS
@@ -883,16 +884,9 @@ Item {
883884
}
884885

885886
Component.onCompleted: {
886-
Theme.changeTheme(appMainLocalSettings.theme)
887-
Theme.changeFontSize(appMainLocalSettings.fontSize)
888-
Theme.changePaddingFactor(appMainLocalSettings.paddingFactor)
889-
}
890-
}
891-
892-
Connections {
893-
target: Application.styleHints
894-
function onColorSchemeChanged() {
895-
Theme.changeTheme(appMainLocalSettings.theme) // re-apply the theme when the System theme/colorscheme changes
887+
ThemeUtils.changeTheme(appMain.Window.window, appMainLocalSettings.theme)
888+
ThemeUtils.setFontSize(appMain.Window.window, appMainLocalSettings.fontSize)
889+
ThemeUtils.setPaddingFactor(appMain.Window.window, appMainLocalSettings.paddingFactor)
896890
}
897891
}
898892

@@ -2152,15 +2146,15 @@ Item {
21522146

21532147
onThemeChangeRequested: function(theme) {
21542148
appMainLocalSettings.theme = theme
2155-
Theme.changeTheme(theme)
2149+
ThemeUtils.changeTheme(appMain.Window.window, theme)
21562150
}
21572151
onFontSizeChangeRequested: function(fontSize) {
21582152
appMainLocalSettings.fontSize = fontSize
2159-
Theme.changeFontSize(fontSize)
2153+
ThemeUtils.setFontSize(appMain.Window.window, fontSize)
21602154
}
21612155
onPaddingFactorChangeRequested: function(paddingFactor) {
21622156
appMainLocalSettings.paddingFactor = paddingFactor
2163-
Theme.changePaddingFactor(paddingFactor)
2157+
ThemeUtils.setPaddingFactor(appMain.Window.window, paddingFactor)
21642158
}
21652159
// Communities related settings view:
21662160
onLeaveCommunityRequest: appMain.communitiesStore.leaveCommunity(communityId)

ui/main.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import MobileUI
2626
Window {
2727
id: applicationWindow
2828

29+
Theme.style: Application.styleHints.colorScheme === Qt.ColorScheme.Dark
30+
? Theme.Style.Dark : Theme.Style.Light
31+
2932
property bool appIsReady: false
3033

3134
readonly property AppStores.FeatureFlagsStore featureFlagsStore: AppStores.FeatureFlagsStore {
@@ -48,7 +51,7 @@ Window {
4851
readonly property MetricsStore metricsStore: MetricsStore {}
4952
readonly property UtilsStore utilsStore: UtilsStore {}
5053
readonly property LanguageStore languageStore: LanguageStore {}
51-
readonly property bool appThemeDark: Theme.isDarkTheme
54+
readonly property bool appThemeDark: Theme.style === Theme.Style.Dark
5255
readonly property bool portraitLayout: height > width
5356
property bool biometricFlowPending: false
5457

0 commit comments

Comments
 (0)