Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit 8ca1216

Browse files
authored
Merge pull request #503 from YIO-Remote/feature/12-hour_clock
feat: 12-hour time format option
2 parents f0e04ed + d1efdaf commit 8ca1216

File tree

7 files changed

+57
-14
lines changed

7 files changed

+57
-14
lines changed

basic_ui/ChargingScreen.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Rectangle {
143143
Text {
144144
id: timeText
145145
color: Style.color.text
146-
text: loader_main.item ? loader_main.item.statusBar.timeText.text : ""
146+
text: loader_main.item ? loader_main.item.statusBar.timeText.text.replace(" ", "\n") : ""
147147
verticalAlignment: Text.AlignVCenter
148148
anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: -400 }
149149
font { family: "Open Sans Light"; weight: Font.Light; pixelSize: 150 }

basic_ui/StatusBar.qml

+4-5
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,12 @@ Item {
124124
//////////////////////////////////////////////////////////////////////////////////////////////////
125125
Timer { // timer that updates the time and date
126126
id: timer
127-
interval: 100
127+
interval: 2000
128128
repeat: true
129129
running: true
130130

131-
onTriggered:
132-
{
133-
timeText.text = Qt.formatDateTime(new Date(),"hh:mm")
131+
onTriggered: {
132+
timeText.text = Qt.formatTime(new Date(), config.settings.clock12h ? "hh:mm AP" : "hh:mm")
134133
}
135134
}
136135

@@ -139,7 +138,7 @@ Item {
139138
Text { // time in the middle
140139
id: timeText
141140
color: Style.color.text
142-
text: "22:00"
141+
text: ""
143142
verticalAlignment: Text.AlignVCenter
144143
height: parent.height
145144
anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }

basic_ui/settings/System.qml

+32
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,38 @@ Rectangle {
177177
color: Style.color.background
178178
}
179179

180+
ButtonGroup { id: clockRadioGroup }
181+
182+
Item {
183+
width: parent.width; height: childrenRect.height + 40
184+
185+
Text {
186+
id: clockTypeText
187+
color: Style.color.text
188+
text: qsTr("24-hour clock") + translateHandler.emptyString
189+
anchors { left: parent.left; leftMargin: 20; top: parent.top; topMargin: 20 }
190+
font: Style.font.button
191+
}
192+
193+
BasicUI.CustomSwitch {
194+
id: clockTypeButton
195+
196+
anchors { right: parent.right; rightMargin: 20; verticalCenter: clockTypeText.verticalCenter }
197+
198+
checked: !config.settings.clock12h
199+
mouseArea.onClicked: {
200+
var tmp = config.settings;
201+
tmp.clock12h = !tmp.clock12h;
202+
config.settings = tmp;
203+
}
204+
}
205+
}
206+
207+
Rectangle {
208+
width: parent.width; height: 2
209+
color: Style.color.background
210+
}
211+
180212
Item {
181213
width: parent.width; height: childrenRect.height + 40
182214

config-schema.json

+6
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,12 @@
799799
"title": "Enable Bluetooth area beacons",
800800
"default": false
801801
},
802+
"clock12h": {
803+
"$id": "#/properties/settings/properties/clock12h",
804+
"type": "boolean",
805+
"title": "Use 12-hour clock",
806+
"default": false
807+
},
802808
"language": {
803809
"$id": "#/properties/settings/properties/language",
804810
"type": "string",

config.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"settings": {
55
"autobrightness": true,
66
"bluetootharea": false,
7+
"clock12h": false,
78
"language": "en_US",
89
"logging": {
910
"console": true,

sources/hardware/mock/batteryfuelgauge_mock.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BatteryFuelGaugeMock : public BatteryFuelGauge {
3434

3535
// BatteryFuelGauge interface
3636
public:
37-
void begin() override {}
37+
void begin() override { emit isChargingChanged(); }
3838
int getVoltage() override { return 5000; }
3939
int getFullChargeCapacity() override { return 2500; }
4040
int getAverageCurrent() override { return -1600; }
@@ -48,6 +48,6 @@ class BatteryFuelGaugeMock : public BatteryFuelGauge {
4848
void changeCapacity(int newCapacity) override { Q_UNUSED(newCapacity) }
4949
int getLevel() override { return 100; }
5050
int getHealth() override { return 100; }
51-
bool getIsCharging() override { return false; }
51+
bool getIsCharging() override { return false; } // to test charging screen: return true
5252
float remainingLife() override { return 2; }
5353
};

translations/en_US.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -1192,32 +1192,37 @@ YIO remote %1</source>
11921192
<translation type="unfinished"></translation>
11931193
</message>
11941194
<message>
1195-
<location filename="../basic_ui/settings/System.qml" line="186"/>
1195+
<location filename="../basic_ui/settings/System.qml" line="188"/>
1196+
<source>24-hour clock</source>
1197+
<translation type="unfinished"></translation>
1198+
</message>
1199+
<message>
1200+
<location filename="../basic_ui/settings/System.qml" line="218"/>
11961201
<source>Uptime</source>
11971202
<translation type="unfinished"></translation>
11981203
</message>
11991204
<message>
1200-
<location filename="../basic_ui/settings/System.qml" line="214"/>
1205+
<location filename="../basic_ui/settings/System.qml" line="246"/>
12011206
<source>CPU temperature</source>
12021207
<translation type="unfinished"></translation>
12031208
</message>
12041209
<message>
1205-
<location filename="../basic_ui/settings/System.qml" line="241"/>
1210+
<location filename="../basic_ui/settings/System.qml" line="273"/>
12061211
<source>CPU load</source>
12071212
<translation type="unfinished"></translation>
12081213
</message>
12091214
<message>
1210-
<location filename="../basic_ui/settings/System.qml" line="267"/>
1215+
<location filename="../basic_ui/settings/System.qml" line="299"/>
12111216
<source>Used memory</source>
12121217
<translation type="unfinished"></translation>
12131218
</message>
12141219
<message>
1215-
<location filename="../basic_ui/settings/System.qml" line="291"/>
1220+
<location filename="../basic_ui/settings/System.qml" line="323"/>
12161221
<source>Reboot</source>
12171222
<translation type="unfinished"></translation>
12181223
</message>
12191224
<message>
1220-
<location filename="../basic_ui/settings/System.qml" line="305"/>
1225+
<location filename="../basic_ui/settings/System.qml" line="337"/>
12211226
<source>Shutdown</source>
12221227
<translation type="unfinished"></translation>
12231228
</message>

0 commit comments

Comments
 (0)