-
-
Save yacuken/b4e1e95320d4bd8b1d3e5f5ad669bb97 to your computer and use it in GitHub Desktop.
fallback config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/settings/settings.pro b/settings/settings.pro | |
index b4dc60b..d9c8f10 100644 | |
--- a/settings/settings.pro | |
+++ b/settings/settings.pro | |
@@ -4,7 +4,7 @@ entries.path = /usr/share/jolla-settings/entries | |
entries.files = camera-settings.json | |
pages.path = /usr/share/jolla-settings/pages/camera-settings-plugin | |
-pages.files = settings.qml | |
+pages.files = settings.qml camera-resolutions.json | |
translations.path = /usr/share/translations | |
translations.files = i18n/*.qm | |
@@ -15,7 +15,8 @@ system(lrelease -idbased $$PWD/i18n/*.ts) | |
OTHER_FILES += \ | |
camera-settings.json \ | |
settings.qml \ | |
- i18n/*.ts | |
+ i18n/*.ts \ | |
+ camera-resolutions.json | |
TRANSLATIONS += i18n/*.ts | |
diff --git a/settings/settings.qml b/settings/settings.qml | |
index a698004..423c8a7 100644 | |
--- a/settings/settings.qml | |
+++ b/settings/settings.qml | |
@@ -7,6 +7,7 @@ Page | |
{ | |
id: page | |
+ property string settingsConfig: "/etc/camera-settings/camera-resolutions.json" | |
property string viewfinderResolution_4_3: "1440x1080" | |
property string viewfinderResolution_16_9: "1920x1080" | |
@@ -203,7 +204,14 @@ Page | |
Component.onCompleted: | |
{ | |
- request("/etc/camera-settings/camera-resolutions.json", function(o) | |
+ doesFileExist(settingsConfig, function(o) | |
+ { | |
+ if(!o.responseText) | |
+ var settings_config = "./camera-resolutions.json"; | |
+ else | |
+ var settings_config = settingsConfig; | |
+ | |
+ request(settings_config, function(o) | |
{ | |
var data = JSON.parse(o.responseText) | |
@@ -230,7 +238,7 @@ Page | |
viewfinderResolution_4_3 = data.viewfinder.viewfinderResolution_4_3 | |
viewfinderResolution_16_9 = data.viewfinder.viewfinderResolution_16_9 | |
- }) | |
+ })}) | |
} | |
function set(model, index, combo, confval, vfconfval) | |
@@ -273,5 +281,19 @@ Page | |
xhr.open('GET', url, true); | |
xhr.send(''); | |
} | |
+ | |
+ function doesFileExist(url, callback) | |
+ { | |
+ var xhr = new XMLHttpRequest(); | |
+ xhr.open('GET', url, true); | |
+ xhr.send(''); | |
+ xhr.onreadystatechange = (function(myxhr) | |
+ { | |
+ return function() | |
+ { | |
+ if(myxhr.readyState === 4) callback(myxhr); | |
+ } | |
+ })(xhr); | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment