Skip to content

Commit 34c7c4c

Browse files
committed
feat(AppearanceView): Added screen scale factor slider for scaling tests
Adds a new screen scaling factor slider on mobile to the `AppearanceView` to experiment with UI scaling behavior. This allows adjusting screen scaling requiring a restart for testing different density levels and layout responsiveness. It's a testing commit that modifies the current `Local Settings` locations. NOT TO BE INTEGRATED ON MASTER.
1 parent 9ca945b commit 34c7c4c

File tree

10 files changed

+202
-3
lines changed

10 files changed

+202
-3
lines changed

mobile/wrapperApp/sources/main.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,39 @@
22
#include <unistd.h>
33
#include <qqml.h>
44
#include <QDir>
5+
#include <QSettings>
6+
#include <QStandardPaths>
7+
#include <QCoreApplication>
58

69
extern "C" {
710
void NimMain();
811
}
912

13+
static void applyScaleFromSettings() {
14+
QString path;
15+
QString filename;
16+
path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) ;
17+
filename = "testconfig.ini" ;
18+
QSettings s(path + "/"+ filename, QSettings::IniFormat);
19+
s.beginGroup("AppMainLocalSettings");
20+
const double sf = s.value("scaleFactor", 1.0).toDouble();
21+
s.endGroup();
22+
23+
if (sf > 0.0 && sf != 1.0) {
24+
QByteArray v = QByteArray::number(sf);
25+
qputenv("QT_SCALE_FACTOR", v);
26+
} else {
27+
// Leave native DPI (don’t force QT_SCALE_FACTOR)
28+
}
29+
}
30+
1031
int main(int argc, char* argv[])
1132
{
33+
1234
Q_INIT_RESOURCE(resources);
1335
qputenv("QT_FILE_SELECTORS", "noWebEngine");
14-
qputenv("QT_SCALE_FACTOR", "0.8");
36+
37+
applyScaleFromSettings();
1538

1639
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
1740
qmlRegisterModule("Qt.labs.settings", 1, 1);

ui/app/AppLayouts/Profile/ProfileLayout.qml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ StatusSectionLayout {
8888
required property int theme // Theme.Style.xxx
8989
required property int fontSize // Theme.FontSize.xxx
9090
required property int paddingFactor // Theme.PaddingFactor.xxx
91+
required property real scaleFactor // From 70/100 to 120/100
9192

9293
required property var whitelistedDomainsModel
93-
94+
9495
signal addressWasShownRequested(string address)
9596
signal connectUsernameRequested(string ensName, string ownerAddress)
9697
signal registerUsernameRequested(string ensName)
@@ -99,6 +100,7 @@ StatusSectionLayout {
99100
signal themeChangeRequested(int theme)
100101
signal fontSizeChangeRequested(int fontSize)
101102
signal paddingFactorChangeRequested(int paddingFactor)
103+
signal scaleFactorChangeRequested(real scaleFactor)
102104
signal leaveCommunityRequest(string communityId)
103105
signal setCommunityMutedRequest(string communityId, int mutedType)
104106
signal inviteFriends(var communityData)
@@ -382,9 +384,11 @@ StatusSectionLayout {
382384
theme: root.theme
383385
fontSize: root.fontSize
384386
paddingFactor: root.paddingFactor
387+
scaleFactor: root.scaleFactor
385388
onThemeChangeRequested: (theme) => root.themeChangeRequested(theme)
386389
onFontSizeChangeRequested: (fontSize) => root.fontSizeChangeRequested(fontSize)
387390
onPaddingFactorChangeRequested: (paddingFactor) => root.paddingFactorChangeRequested(paddingFactor)
391+
onScaleFactorChangeRequested: (scaleFactor) => root.scaleFactorChangeRequested(scaleFactor)
388392
}
389393
}
390394

ui/app/AppLayouts/Profile/popups/ConfirmAppRestartModal.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import StatusQ.Popups.Dialog
88
StatusDialog {
99
id: root
1010
title: qsTr("Application Restart")
11+
fillHeightOnBottomSheet: true
1112

1213
contentItem: StatusBaseText {
1314
text: qsTr("Please restart the application to apply the changes.")

ui/app/AppLayouts/Profile/popups/qmldir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ TokenListPopup 1.0 TokenListPopup.qml
1111
WalletKeypairAccountMenu 1.0 WalletKeypairAccountMenu.qml
1212
WalletAddressMenu 1.0 WalletAddressMenu.qml
1313
ConfirmChangePasswordModal 1.0 ConfirmChangePasswordModal.qml
14+
ConfirmAppRestartModal 1.0 ConfirmAppRestartModal.qml

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ import shared.views.chat
1111
import StatusQ.Core
1212
import StatusQ.Core.Theme
1313
import StatusQ.Controls as StatusQ
14+
import StatusQ.Core.Utils as SQUtils
15+
16+
import AppLayouts.Profile.popups
1417

1518
SettingsContentBase {
1619
id: root
1720

1821
required property int theme // Theme.Style.xxx
1922
required property int fontSize // Theme.FontSize.xxx
2023
required property int paddingFactor // Theme.PaddingFactor.xxx
24+
required property real scaleFactor // From 70/100 to 120/100
2125

2226
signal themeChangeRequested(int theme)
2327
signal fontSizeChangeRequested(int fontSize)
2428
signal paddingFactorChangeRequested(int paddingFactor)
29+
signal scaleFactorChangeRequested(real scaleFactor)
2530

2631
content: ColumnLayout {
2732
id: appearanceContainer
@@ -113,6 +118,46 @@ SettingsContentBase {
113118
onMoved: root.paddingFactorChangeRequested(value)
114119
}
115120

121+
StatusSectionHeadline {
122+
Layout.topMargin: 2 * Theme.padding
123+
text: qsTr("Zoom (requires restart)")
124+
visible: SQUtils.Utils.isMobile
125+
}
126+
127+
StatusQ.StatusLabeledSlider {
128+
id: zoomSlider
129+
130+
readonly property bool dirty: value !== (root.scaleFactor * 100.0)
131+
132+
Layout.fillWidth: true
133+
Layout.leftMargin: Theme.smallPadding
134+
Layout.rightMargin: Layout.leftMargin
135+
136+
visible: SQUtils.Utils.isMobile
137+
138+
from: 70
139+
to: 120
140+
stepSize: 10
141+
model: [qsTr("70%"), qsTr("80%"), qsTr("90%"), qsTr("100%"),
142+
qsTr("110%"), qsTr("120%")]
143+
value: root.scaleFactor * 100
144+
145+
onPressedChanged: {
146+
if (!pressed && dirty) {
147+
confirmAppRestartModal.open()
148+
}
149+
}
150+
151+
ConfirmAppRestartModal {
152+
id: confirmAppRestartModal
153+
onAccepted: {
154+
root.scaleFactorChangeRequested(zoomSlider.value / 100.0)
155+
SystemUtils.restartApplication()
156+
}
157+
onClosed: zoomSlider.value = root.scaleFactor * 100.0
158+
}
159+
}
160+
116161
Rectangle {
117162
Layout.topMargin: 2 * Theme.padding
118163
Layout.preferredHeight: 1

ui/app/mainui/AppMain.qml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ Item {
863863

864864
Settings {
865865
id: appMainLocalSettings
866-
category: "AppMainLocalSettings_%1".arg(allContacsAdaptor.selfPubKey)
866+
category: "AppMainLocalSettings"
867+
location: StandardPaths.writableLocation(StandardPaths.AppConfigLocation) + "/testconfig.ini"
867868
property var whitelistedUnfurledDomains: []
868869
property bool introduceYourselfPopupSeen
869870
property bool enableMessageBackupPopupSeen
@@ -877,6 +878,7 @@ Item {
877878
}
878879
return Theme.PaddingFactor.PaddingM
879880
}
881+
property real scaleFactor: 1.0
880882

881883
Component.onCompleted: {
882884
Theme.changeTheme(appMainLocalSettings.theme)
@@ -2134,6 +2136,7 @@ Item {
21342136
theme: appMainLocalSettings.theme
21352137
fontSize: appMainLocalSettings.fontSize
21362138
paddingFactor: appMainLocalSettings.paddingFactor
2139+
scaleFactor: appMainLocalSettings.scaleFactor
21372140

21382141
whitelistedDomainsModel: appMainLocalSettings.whitelistedUnfurledDomains
21392142

@@ -2155,6 +2158,9 @@ Item {
21552158
appMainLocalSettings.paddingFactor = paddingFactor
21562159
Theme.changePaddingFactor(paddingFactor)
21572160
}
2161+
onScaleFactorChangeRequested: function(scaleFactor) {
2162+
appMainLocalSettings.scaleFactor = scaleFactor
2163+
}
21582164
// Communities related settings view:
21592165
onLeaveCommunityRequest: appMain.communitiesStore.leaveCommunity(communityId)
21602166
onSetCommunityMutedRequest: appMain.communitiesStore.setCommunityMuted(communityId, mutedType)

ui/i18n/qml_base_en.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,34 @@ from &quot;%1&quot; to &quot;%2&quot;</source>
21602160
<source>System</source>
21612161
<translation type="unfinished"></translation>
21622162
</message>
2163+
<message>
2164+
<source>Zoom (requires restart)</source>
2165+
<translation type="unfinished"></translation>
2166+
</message>
2167+
<message>
2168+
<source>100%</source>
2169+
<translation type="unfinished"></translation>
2170+
</message>
2171+
<message>
2172+
<source>80%</source>
2173+
<translation type="unfinished"></translation>
2174+
</message>
2175+
<message>
2176+
<source>120%</source>
2177+
<translation type="unfinished"></translation>
2178+
</message>
2179+
<message>
2180+
<source>70%</source>
2181+
<translation type="unfinished"></translation>
2182+
</message>
2183+
<message>
2184+
<source>90%</source>
2185+
<translation type="unfinished"></translation>
2186+
</message>
2187+
<message>
2188+
<source>110%</source>
2189+
<translation type="unfinished"></translation>
2190+
</message>
21632191
</context>
21642192
<context>
21652193
<name>AssetContextMenu</name>

ui/i18n/qml_base_lokalise_en.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,6 +2652,41 @@
26522652
<comment>AppearanceView</comment>
26532653
<translation>System</translation>
26542654
</message>
2655+
<message>
2656+
<source>Zoom (requires restart)</source>
2657+
<comment>AppearanceView</comment>
2658+
<translation>Zoom (requires restart)</translation>
2659+
</message>
2660+
<message>
2661+
<source>100%</source>
2662+
<comment>AppearanceView</comment>
2663+
<translation>100%</translation>
2664+
</message>
2665+
<message>
2666+
<source>80%</source>
2667+
<comment>AppearanceView</comment>
2668+
<translation>80%</translation>
2669+
</message>
2670+
<message>
2671+
<source>120%</source>
2672+
<comment>AppearanceView</comment>
2673+
<translation>120%</translation>
2674+
</message>
2675+
<message>
2676+
<source>70%</source>
2677+
<comment>AppearanceView</comment>
2678+
<translation>70%</translation>
2679+
</message>
2680+
<message>
2681+
<source>90%</source>
2682+
<comment>AppearanceView</comment>
2683+
<translation>90%</translation>
2684+
</message>
2685+
<message>
2686+
<source>110%</source>
2687+
<comment>AppearanceView</comment>
2688+
<translation>110%</translation>
2689+
</message>
26552690
</context>
26562691
<context>
26572692
<name>AssetContextMenu</name>

ui/i18n/qml_cs.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,34 @@ from &quot;%1&quot; to &quot;%2&quot;</source>
21672167
<source>System</source>
21682168
<translation type="unfinished">Systémový</translation>
21692169
</message>
2170+
<message>
2171+
<source>Zoom (requires restart)</source>
2172+
<translation type="unfinished"></translation>
2173+
</message>
2174+
<message>
2175+
<source>100%</source>
2176+
<translation type="unfinished"></translation>
2177+
</message>
2178+
<message>
2179+
<source>80%</source>
2180+
<translation type="unfinished"></translation>
2181+
</message>
2182+
<message>
2183+
<source>120%</source>
2184+
<translation type="unfinished"></translation>
2185+
</message>
2186+
<message>
2187+
<source>70%</source>
2188+
<translation type="unfinished"></translation>
2189+
</message>
2190+
<message>
2191+
<source>90%</source>
2192+
<translation type="unfinished"></translation>
2193+
</message>
2194+
<message>
2195+
<source>110%</source>
2196+
<translation type="unfinished"></translation>
2197+
</message>
21702198
</context>
21712199
<context>
21722200
<name>AssetContextMenu</name>

ui/i18n/qml_ko.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,34 @@ from &quot;%1&quot; to &quot;%2&quot;</source>
21532153
<source>System</source>
21542154
<translation type="unfinished">시스템</translation>
21552155
</message>
2156+
<message>
2157+
<source>Zoom (requires restart)</source>
2158+
<translation type="unfinished"></translation>
2159+
</message>
2160+
<message>
2161+
<source>100%</source>
2162+
<translation type="unfinished"></translation>
2163+
</message>
2164+
<message>
2165+
<source>80%</source>
2166+
<translation type="unfinished"></translation>
2167+
</message>
2168+
<message>
2169+
<source>120%</source>
2170+
<translation type="unfinished"></translation>
2171+
</message>
2172+
<message>
2173+
<source>70%</source>
2174+
<translation type="unfinished"></translation>
2175+
</message>
2176+
<message>
2177+
<source>90%</source>
2178+
<translation type="unfinished"></translation>
2179+
</message>
2180+
<message>
2181+
<source>110%</source>
2182+
<translation type="unfinished"></translation>
2183+
</message>
21562184
</context>
21572185
<context>
21582186
<name>AssetContextMenu</name>

0 commit comments

Comments
 (0)