diff --git a/src/Settings.cpp b/src/Settings.cpp index 5328eab..08df473 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include -#define DCONF_PATH_(x) "/apps/harbour-barcode/" x +#define DCONF_PATH_(x) SETTINGS_DCONF_PATH_(x) // New keys (the ones that have only been in dconf) #define KEY_BUZZ_ON_SCAN "buzz_on_scan" diff --git a/src/Settings.h b/src/Settings.h index 396adfa..e1364d9 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -30,6 +30,8 @@ THE SOFTWARE. #include +#define SETTINGS_DCONF_PATH_(x) "/apps/harbour-barcode/" x + // Old keys (the ones that may need to be imported from the database) #define KEY_SOUND "sound" diff --git a/src/harbour-barcode.cpp b/src/harbour-barcode.cpp index 92c1177..dfee882 100644 --- a/src/harbour-barcode.cpp +++ b/src/harbour-barcode.cpp @@ -104,10 +104,15 @@ int main(int argc, char *argv[]) QScopedPointer app(SailfishApp::application(argc, argv)); bool torchSupported = false; - // Parse Qt version to find out what's supported and what's not const char* qver = qVersion(); HDEBUG("Qt version" << qver); - if (qver) { + + if (qgetenv("HARBOUR_BARCODE_ENABLE_TORCH").toInt() > 0 || + MGConfItem(SETTINGS_DCONF_PATH_("enableTorch")).value().toBool()) { + torchSupported = true; + HDEBUG("Torch support is enabled"); + } else if (qver) { + // Figure out what's supported and what's not const QStringList s(QString(qver).split('.')); if (s.size() >= 3) { int v = QT_VERSION_CHECK(s[0].toInt(), s[1].toInt(), s[2].toInt()); @@ -120,6 +125,11 @@ int main(int argc, char *argv[]) if (flashValues.size() == 1 && flashValues.at(0).toInt() == QCameraExposure::FlashOff) { HDEBUG("Flash disabled by" << qPrintable(flashValuesKey)); + } else if (flashValues.isEmpty()) { + // If this DConf key is missing, assume that the torch + // mode is not supported + HDEBUG("DConf entry" << qPrintable(flashValuesKey) << + "is missing, disabling the torch"); } else { torchSupported = true; HDEBUG("Torch supported");