Skip to content

Commit 48d3f9c

Browse files
refactor: add tune field to be sent to the API
1 parent 59efe94 commit 48d3f9c

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

mawaqit/Main.qml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Item {
4040
readonly property string city: cfg.city ?? defaults.city ?? "London"
4141
readonly property string country: cfg.country ?? defaults.country ?? "UK"
4242
readonly property int method: cfg.method ?? defaults.method ?? 3
43+
readonly property string tune: cfg.tune ?? defaults.tune ?? ""
4344
readonly property int school: cfg.school ?? defaults.school ?? 0
4445
readonly property bool showNotifications: cfg.showNotifications ?? defaults.showNotifications ?? true
4546
readonly property bool playAzan: cfg.playAzan ?? defaults.playAzan ?? false
@@ -56,6 +57,7 @@ Item {
5657
onCityChanged: if (lastFetchDate) Qt.callLater(forceRefresh)
5758
onCountryChanged: if (lastFetchDate) Qt.callLater(forceRefresh)
5859
onMethodChanged: if (lastFetchDate) Qt.callLater(forceRefresh)
60+
onTuneChanged: if (lastFetchDate) Qt.callLater(forceRefresh)
5961
onSchoolChanged: if (lastFetchDate) Qt.callLater(forceRefresh)
6062

6163
readonly property var prayerKeys: {
@@ -251,7 +253,7 @@ Item {
251253
const from = Qt.formatDate(today, "dd-MM-yyyy")
252254
const toD = new Date(today); toD.setDate(toD.getDate() + 6)
253255
const to = Qt.formatDate(toD, "dd-MM-yyyy")
254-
const url = `https://api.aladhan.com/v1/timingsByCity/${from}?city=${encodeURIComponent(city)}&country=${encodeURIComponent(country)}&method=${method}&school=${school}&days=7`
256+
const url = `https://api.aladhan.com/v1/timingsByCity/${from}?city=${encodeURIComponent(city)}&country=${encodeURIComponent(country)}&method=${method}&school=${school}&days=7&tune=${encodeURIComponent(tune)}`
255257
Logger.d("Mawaqit", "Fetching week from", from, "to", to)
256258

257259
const xhr = new XMLHttpRequest()
@@ -297,7 +299,7 @@ Item {
297299

298300
function fetchSingleDay() {
299301
if (_xhr) return
300-
const url = `https://api.aladhan.com/v1/timingsByCity?city=${encodeURIComponent(city)}&country=${encodeURIComponent(country)}&method=${method}&school=${school}`
302+
const url = `https://api.aladhan.com/v1/timingsByCity?city=${encodeURIComponent(city)}&country=${encodeURIComponent(country)}&method=${method}&school=${school}&tune=${encodeURIComponent(tune)}`
301303
const xhr = new XMLHttpRequest()
302304
_xhr = xhr
303305
xhr.onreadystatechange = function() {

mawaqit/Settings.qml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ColumnLayout {
3636
return !match || match.key === "99"
3737
}
3838
property string valueMethodCustomInput: valueMethodCustom ? String(root.valueMethod) : ""
39+
property string valueTune: cfg.tune ?? defaults.tune ?? ""
3940
property int valueSchool: cfg.school ?? defaults.school ?? 0
4041
property bool valueShowCountdown: cfg.showCountdown ?? defaults.showCountdown ?? true
4142
property bool valueShowNotifications: cfg.showNotifications ?? defaults.showNotifications ?? true
@@ -133,6 +134,15 @@ ColumnLayout {
133134
onSelected: key => root.valueHijriDayOffset = parseInt(key)
134135
}
135136

137+
NTextInput {
138+
Layout.fillWidth: true
139+
label: pluginApi?.tr("settings.tune.label")
140+
description: pluginApi?.tr("settings.tune.desc")
141+
placeholderText: "0,0,0,0,0,0,0,0,0"
142+
text: root.valueTune
143+
onTextChanged: root.valueTune = text
144+
}
145+
136146
NDivider { Layout.fillWidth: true }
137147

138148
// ── Calendar ──────────────────────────────────────────────────────────────
@@ -284,6 +294,7 @@ ColumnLayout {
284294
pluginApi.pluginSettings.school = root.valueSchool
285295
pluginApi.pluginSettings.hijriDayOffset = root.valueHijriDayOffset
286296
pluginApi.pluginSettings.weekStartDay = root.valueWeekStartDay
297+
pluginApi.pluginSettings.tune = root.valueTune.trim()
287298
pluginApi.saveSettings()
288299
Logger.d("Mawaqit", "Settings saved")
289300
}

mawaqit/i18n/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"methodCustom": {
106106
"label": "Custom Method ID",
107107
"desc": "Enter the numeric method ID from the Aladhan API (e.g. 19 for Algeria / MESRS)."
108+
},
109+
"tune": {
110+
"label": "Timing Offsets (tune)",
111+
"desc": "Comma-separated minute offsets for: Imsak, Fajr, Sunrise, Dhuhr, Asr, Maghrib, Sunset, Isha, Midnight. Leave blank for no adjustment. Example: 0,2,0,0,0,1,0,0,0"
108112
}
109113
},
110114
"error": {

0 commit comments

Comments
 (0)