diff --git a/daemon/src/services/mibandservice.cpp b/daemon/src/services/mibandservice.cpp index 3005f9f9..a77c3dd2 100644 --- a/daemon/src/services/mibandservice.cpp +++ b/daemon/src/services/mibandservice.cpp @@ -433,11 +433,21 @@ void MiBandService::setAlertFitnessGoal() void MiBandService::setEnableDisplayOnLiftWrist() { - auto value = AmazfishConfig::instance()->profileDisplayOnLiftWrist() - ? COMMAND_ENABLE_DISPLAY_ON_LIFT_WRIST - : COMMAND_DISABLE_DISPLAY_ON_LIFT_WRIST; + QByteArray cmd; - writeValue(UUID_CHARACTERISTIC_MIBAND_CONFIGURATION, UCHARARR_TO_BYTEARRAY(value)); + if (AmazfishConfig::instance()->profileDisplayOnLiftWrist() == AmazfishConfig::DisplayLiftWristOff) { + cmd = UCHARARR_TO_BYTEARRAY(COMMAND_DISABLE_DISPLAY_ON_LIFT_WRIST); + } else if (AmazfishConfig::instance()->profileDisplayOnLiftWrist() == AmazfishConfig::DisplayLiftWristOn) { + cmd = UCHARARR_TO_BYTEARRAY(COMMAND_ENABLE_DISPLAY_ON_LIFT_WRIST); + } else { + cmd = UCHARARR_TO_BYTEARRAY(COMMAND_SCHEDULE_DISPLAY_ON_LIFT_WRIST); + cmd[4] = AmazfishConfig::instance()->profileWristScheduleStart().time().hour(); + cmd[5] = AmazfishConfig::instance()->profileWristScheduleStart().time().minute(); + cmd[6] = AmazfishConfig::instance()->profileWristScheduleEnd().time().hour(); + cmd[7] = AmazfishConfig::instance()->profileWristScheduleEnd().time().minute(); + } + + writeValue(UUID_CHARACTERISTIC_MIBAND_CONFIGURATION, cmd); } void MiBandService::setDisplayItems() diff --git a/lib/src/amazfishconfig.cpp b/lib/src/amazfishconfig.cpp index cccec9ed..b5976188 100644 --- a/lib/src/amazfishconfig.cpp +++ b/lib/src/amazfishconfig.cpp @@ -1,67 +1,67 @@ -#include "amazfishconfig.h" - -#include - -#ifdef MER_EDITION_SAILFISH -#include -#endif - -#include - - -AmazfishConfig::AmazfishConfig(QObject *parent) - : QObject(parent) -#ifdef MER_EDITION_SAILFISH - , m_group(new MDConfGroup(QStringLiteral("/uk/co/piggz/amazfish"), this)) -#endif -{ - -} - -AmazfishConfig *AmazfishConfig::instance() -{ - static AmazfishConfig *inst = nullptr; - if (!inst) { - inst = new AmazfishConfig(qApp); - } - return inst; -} - -QVariant AmazfishConfig::value(const QString &key, const QVariant &def) const -{ -#ifdef MER_EDITION_SAILFISH - return m_group->value(key, def); -#else - QSettings settings; - return settings.value(key, def); -#endif -} - -void AmazfishConfig::setValue(const QString &key, const QVariant &value) -{ -#ifdef MER_EDITION_SAILFISH - m_group->setValue(key, value); -#else - QSettings settings; - settings.setValue(key, value); -#endif -} - -void AmazfishConfig::setValue(const QString &key, const QVariant &value, signal_ptr signal) -{ -#ifdef MER_EDITION_SAILFISH - auto prev = m_group->value(key); -#else - QSettings settings; - auto prev = settings.value(key); -#endif - - if (value != prev) { -#ifdef MER_EDITION_SAILFISH - m_group->setValue(key, value); -#else - settings.setValue(key, value); -#endif - emit std::bind(signal, this)(); - } -} +#include "amazfishconfig.h" + +#include + +#ifdef MER_EDITION_SAILFISH +#include +#endif + +#include + + +AmazfishConfig::AmazfishConfig(QObject *parent) + : QObject(parent) +#ifdef MER_EDITION_SAILFISH + , m_group(new MDConfGroup(QStringLiteral("/uk/co/piggz/amazfish"), this)) +#endif +{ + +} + +AmazfishConfig *AmazfishConfig::instance() +{ + static AmazfishConfig *inst = nullptr; + if (!inst) { + inst = new AmazfishConfig(qApp); + } + return inst; +} + +QVariant AmazfishConfig::value(const QString &key, const QVariant &def) const +{ +#ifdef MER_EDITION_SAILFISH + return m_group->value(key, def); +#else + QSettings settings; + return settings.value(key, def); +#endif +} + +void AmazfishConfig::setValue(const QString &key, const QVariant &value) +{ +#ifdef MER_EDITION_SAILFISH + m_group->setValue(key, value); +#else + QSettings settings; + settings.setValue(key, value); +#endif +} + +void AmazfishConfig::setValue(const QString &key, const QVariant &value, signal_ptr signal) +{ +#ifdef MER_EDITION_SAILFISH + auto prev = m_group->value(key); +#else + QSettings settings; + auto prev = settings.value(key); +#endif + + if (value != prev) { +#ifdef MER_EDITION_SAILFISH + m_group->setValue(key, value); +#else + settings.setValue(key, value); +#endif + emit std::bind(signal, this)(); + } +} diff --git a/lib/src/amazfishconfig.h b/lib/src/amazfishconfig.h index 4ba68da8..6e60d170 100644 --- a/lib/src/amazfishconfig.h +++ b/lib/src/amazfishconfig.h @@ -1,189 +1,198 @@ -#ifndef AMAZFISHCONFIG_H -#define AMAZFISHCONFIG_H - -#include -#include -#include - -#ifdef MER_EDITION_SAILFISH -class MDConfGroup; -#else -#include -#endif -class QQmlEngine; -class QJSEngine; - -#define OPTION(key, name, setter, def, type, gettertype, settertype) \ - Q_PROPERTY(type name READ name WRITE setter NOTIFY name##Changed) \ - type name() const \ - { return value(key, def).gettertype(); } \ - void setter(settertype value) \ - { setValue(key, value, &AmazfishConfig::name##Changed); } \ - Q_SIGNAL void name##Changed(); - -#define BOOL_OPTION(key, name, setter, def) \ - OPTION(key, name, setter, def, bool, toBool, bool) - -#define INT_OPTION(key, name, setter, def) \ - OPTION(key, name, setter, def, int, toInt, int) - -#define UINT_OPTION(key, name, setter, def) \ - OPTION(key, name, setter, def, uint, toInt, uint) - -#define INT64_OPTION(key, name, setter, def) \ - OPTION(key, name, setter, def, qint64, toLongLong, qint64) - -#define STRING_OPTION(key, name, setter, def) \ - OPTION(key, name, setter, def, QString, toString, const QString &) - -#define ENUM_OPTION(key, name, setter, type, def) \ - Q_PROPERTY(type name READ name WRITE setter NOTIFY name##Changed) \ - type name() const \ - { return static_cast(value(key, def).toInt()); } \ - void setter(type value) \ - { setValue(key, static_cast(value), &AmazfishConfig::name##Changed); } \ - Q_SIGNAL void name##Changed(); - -#define ALARM_OPTION(key, name, setter, type, def, gettertype) \ - Q_INVOKABLE type name(quint8 n) const \ - { return value(key.arg(n), def).gettertype(); } \ - Q_INVOKABLE void setter(quint8 n, type value) \ - { setValue(key.arg(n), value); } - - -class AmazfishConfig : public QObject -{ - Q_OBJECT - - AmazfishConfig(QObject *parent = nullptr); - -public: - enum DeviceLanguage { - DeviceLanguageEnUs, - DeviceLanguageEsEs, - DeviceLanguageZhCn, - DeviceLanguageZhTw, - DeviceLanguageRuRu, - DeviceLanguageDeDe, - DeviceLanguageItIt, - DeviceLanguageFrFr, - DeviceLanguageTrTr, - }; - Q_ENUM(DeviceLanguage) - - enum DeviceDateFormat { - DeviceDateFormatTime, - DeviceDateFormatDateTime, - }; - Q_ENUM(DeviceDateFormat) - - enum DeviceTimeFormat { - DeviceTimeFormat24H, - DeviceTimeFormat12H, - }; - Q_ENUM(DeviceTimeFormat) - - enum DeviceDistanceUnit { - DeviceDistanceUnitMetric, - DeviceDistanceUnitImperial, - }; - Q_ENUM(DeviceDistanceUnit) - - enum ProfileGender { - ProfileGenderMale, - ProfileGenderFemale, - }; - Q_ENUM(ProfileGender) - - enum WearLocation { - WearLocationLeftWrist, - WearLocationRightWrist, - }; - Q_ENUM(WearLocation) - - static AmazfishConfig *instance(); - static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) - { - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - return instance(); - } - - QVariant value(const QString &key, const QVariant &def = QVariant()) const; - void setValue(const QString &key, const QVariant &value); - - STRING_OPTION(QStringLiteral("pairedAddress"), pairedAddress, setPairedAddress, QString()) - STRING_OPTION(QStringLiteral("pairedName"), pairedName, setPairedName, QString()) - - BOOL_OPTION(QStringLiteral("app/notifyconnect"), appNotifyConnect, setAppNotifyConnect, true) - BOOL_OPTION(QStringLiteral("app/autosyncdata"), appAutoSyncData, setAppAutoSyncData, true) - BOOL_OPTION(QStringLiteral("app/notifylowbattery"), appNotifyLowBattery, setAppNotifyLowBattery, true) - BOOL_OPTION(QStringLiteral("app/overridefwcheck"), appOverrideFwCheck, setAppOverrideFwCheck, false) - BOOL_OPTION(QStringLiteral("app/navigationnotification"), appNavigationNotification, setAppNavigationNotification, false) - BOOL_OPTION(QStringLiteral("app/simulateevents"), appSimulateEventSupport, setSimulateEventSupport, false) - BOOL_OPTION(QStringLiteral("app/transliterate"), appTransliterate, setTransliterate, false) - - STRING_OPTION(QStringLiteral("app/button-double-action"), appButtonDoublePressAction, setAppButtonDoublePressAction, "action-none") - STRING_OPTION(QStringLiteral("app/button-triple-action"), appButtonTriplePressAction, setAppButtonTriplePressAction, "action-none") - STRING_OPTION(QStringLiteral("app/button-quad-action"), appButtonQuadPressAction, setAppButtonQuadPressAction, "action-none") - - STRING_OPTION(QStringLiteral("localAdapter"), localAdapter, setLocalAdapter, "/org/bluez/hci0") - - INT_OPTION(QStringLiteral("app/refreshweather"), appRefreshWeather, setAppRefreshWeather, 80) - INT_OPTION(QStringLiteral("app/refreshcalendar"), appRefreshCalendar, setAppRefreshCalendar, 60) - - BOOL_OPTION(QStringLiteral("device/disconnectnotification"), deviceDisconnectNotification, setDeviceDisconnectNotification, false) - BOOL_OPTION(QStringLiteral("device/displayweathershortcut"), deviceDisplayWeatherShortcut, setDeviceDisplayWeatherShortcut, true) - BOOL_OPTION(QStringLiteral("device/displayalipayshortcut"), deviceDisplayAliPayShortcut, setDeviceDisplayAliPayShortcut, true) - STRING_OPTION(QStringLiteral("device/displayitems"), deviceDisplayItems, setDeviceDisplayItems, "") - - ENUM_OPTION(QStringLiteral("device/language"), deviceLanguage, setDeviceLanguage, DeviceLanguage, DeviceLanguageEnUs) - ENUM_OPTION(QStringLiteral("device/dateformat"), deviceDateFormat, setDeviceDateFormat, DeviceDateFormat, DeviceDateFormatTime) - ENUM_OPTION(QStringLiteral("device/timeformat"), deviceTimeFormat, setDeviceTimeFormat, DeviceTimeFormat, DeviceTimeFormat24H) - ENUM_OPTION(QStringLiteral("device/distanceunit"), deviceDistanceUnit, setDeviceDistanceUnit, DeviceDistanceUnit, DeviceDistanceUnitMetric) - - INT64_OPTION(QStringLiteral("device/lastactivitysyncmillis"), lastActivitySync, setLastActivitySync, 0) - INT64_OPTION(QStringLiteral("device/lastsportsyncmillis"), lastSportSync, setLastSportSync, 0) - - STRING_OPTION(QStringLiteral("device/authkey"), deviceAuthKey, setDeviceAuthKey, QString()) - - STRING_OPTION(QStringLiteral("profile/name"), profileName, setProfileName, QString()) - OPTION(QStringLiteral("profile/dob"), profileDOB, setProfileDOB, QDateTime(), QDateTime, toDateTime, const QDateTime &) - - ENUM_OPTION(QStringLiteral("profile/gender"), profileGender, setProfileGender, ProfileGender, ProfileGenderMale) - ENUM_OPTION(QStringLiteral("profile/wearlocation"), profileWearLocation, setProfileWearLocation, WearLocation, WearLocationLeftWrist) - - UINT_OPTION(QStringLiteral("profile/height"), profileHeight, setProfileHeight, 200) - UINT_OPTION(QStringLiteral("profile/weight"), profileWeight, setProfileWeight, 70) - UINT_OPTION(QStringLiteral("profile/alldayhrm"), profileAllDayHRM, setProfileAllDayHRM, 0) - UINT_OPTION(QStringLiteral("profile/fitnessgoal"), profileFitnessGoal, setProfileFitnessGoal, 10000) - - BOOL_OPTION(QStringLiteral("profile/alertfitnessgoal"), profileAlertFitnessGoal, setProfileAlertFitnessGoal, false) - BOOL_OPTION(QStringLiteral("profile/hrmsleepsupport"), profileHRMSleepSupport, setProfileHRMSleepSupport, true) - BOOL_OPTION(QStringLiteral("profile/displayonliftwrist"), profileDisplayOnLiftWrist, setProfileDisplayOnLiftWrist, false) - - ALARM_OPTION(QStringLiteral("alarms/alarm%1/enabled"), alarmEnabled, setAlarmEnabled, bool, false, toBool) - ALARM_OPTION(QStringLiteral("alarms/alarm%1/repeat"), alarmRepeatMask, setAlarmRepeatMask, int, 0, toInt) - ALARM_OPTION(QStringLiteral("alarms/alarm%1/hour"), alarmHour, setAlarmHour, int, 0, toInt) - ALARM_OPTION(QStringLiteral("alarms/alarm%1/minute"), alarmMinute, setAlarmMinute, int, 0, toInt) - -private: - using signal_ptr = void(AmazfishConfig::*)(); - - void setValue(const QString &key, const QVariant &value, signal_ptr signal); - -#ifdef MER_EDITION_SAILFISH - MDConfGroup *m_group; -#endif -}; - -#undef ALARM_OPTION -#undef ENUM_OPTION -#undef STRING_OPTION -#undef INT64_OPTION -#undef UINT_OPTION -#undef INT_OPTION -#undef BOOL_OPTION -#undef OPTION - -#endif // AMAZFISHCONFIG_H +#ifndef AMAZFISHCONFIG_H +#define AMAZFISHCONFIG_H + +#include +#include +#include + +#ifdef MER_EDITION_SAILFISH +class MDConfGroup; +#else +#include +#endif +class QQmlEngine; +class QJSEngine; + +#define OPTION(key, name, setter, def, type, gettertype, settertype) \ + Q_PROPERTY(type name READ name WRITE setter NOTIFY name##Changed) \ + type name() const \ + { return value(key, def).gettertype(); } \ + void setter(settertype value) \ + { setValue(key, value, &AmazfishConfig::name##Changed); } \ + Q_SIGNAL void name##Changed(); + +#define BOOL_OPTION(key, name, setter, def) \ + OPTION(key, name, setter, def, bool, toBool, bool) + +#define INT_OPTION(key, name, setter, def) \ + OPTION(key, name, setter, def, int, toInt, int) + +#define UINT_OPTION(key, name, setter, def) \ + OPTION(key, name, setter, def, uint, toInt, uint) + +#define INT64_OPTION(key, name, setter, def) \ + OPTION(key, name, setter, def, qint64, toLongLong, qint64) + +#define STRING_OPTION(key, name, setter, def) \ + OPTION(key, name, setter, def, QString, toString, const QString &) + +#define ENUM_OPTION(key, name, setter, type, def) \ + Q_PROPERTY(type name READ name WRITE setter NOTIFY name##Changed) \ + type name() const \ + { return static_cast(value(key, def).toInt()); } \ + void setter(type value) \ + { setValue(key, static_cast(value), &AmazfishConfig::name##Changed); } \ + Q_SIGNAL void name##Changed(); + +#define ALARM_OPTION(key, name, setter, type, def, gettertype) \ + Q_INVOKABLE type name(quint8 n) const \ + { return value(key.arg(n), def).gettertype(); } \ + Q_INVOKABLE void setter(quint8 n, type value) \ + { setValue(key.arg(n), value); } + + +class AmazfishConfig : public QObject +{ + Q_OBJECT + + AmazfishConfig(QObject *parent = nullptr); + +public: + enum DeviceLanguage { + DeviceLanguageEnUs, + DeviceLanguageEsEs, + DeviceLanguageZhCn, + DeviceLanguageZhTw, + DeviceLanguageRuRu, + DeviceLanguageDeDe, + DeviceLanguageItIt, + DeviceLanguageFrFr, + DeviceLanguageTrTr, + }; + Q_ENUM(DeviceLanguage) + + enum DeviceDateFormat { + DeviceDateFormatTime, + DeviceDateFormatDateTime, + }; + Q_ENUM(DeviceDateFormat) + + enum DeviceTimeFormat { + DeviceTimeFormat24H, + DeviceTimeFormat12H, + }; + Q_ENUM(DeviceTimeFormat) + + enum DeviceDistanceUnit { + DeviceDistanceUnitMetric, + DeviceDistanceUnitImperial, + }; + Q_ENUM(DeviceDistanceUnit) + + enum ProfileGender { + ProfileGenderMale, + ProfileGenderFemale, + }; + Q_ENUM(ProfileGender) + + enum WearLocation { + WearLocationLeftWrist, + WearLocationRightWrist, + }; + Q_ENUM(WearLocation) + + enum DisplayLiftWrist { + DisplayLiftWristOff, + DisplayLiftWristOn, + DisplayLiftWristSchedule + }; + Q_ENUM(DisplayLiftWrist) + + static AmazfishConfig *instance(); + static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) + { + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + return instance(); + } + + QVariant value(const QString &key, const QVariant &def = QVariant()) const; + void setValue(const QString &key, const QVariant &value); + + STRING_OPTION(QStringLiteral("pairedAddress"), pairedAddress, setPairedAddress, QString()) + STRING_OPTION(QStringLiteral("pairedName"), pairedName, setPairedName, QString()) + + BOOL_OPTION(QStringLiteral("app/notifyconnect"), appNotifyConnect, setAppNotifyConnect, true) + BOOL_OPTION(QStringLiteral("app/autosyncdata"), appAutoSyncData, setAppAutoSyncData, true) + BOOL_OPTION(QStringLiteral("app/notifylowbattery"), appNotifyLowBattery, setAppNotifyLowBattery, true) + BOOL_OPTION(QStringLiteral("app/overridefwcheck"), appOverrideFwCheck, setAppOverrideFwCheck, false) + BOOL_OPTION(QStringLiteral("app/navigationnotification"), appNavigationNotification, setAppNavigationNotification, false) + BOOL_OPTION(QStringLiteral("app/simulateevents"), appSimulateEventSupport, setSimulateEventSupport, false) + BOOL_OPTION(QStringLiteral("app/transliterate"), appTransliterate, setTransliterate, false) + + STRING_OPTION(QStringLiteral("app/button-double-action"), appButtonDoublePressAction, setAppButtonDoublePressAction, "action-none") + STRING_OPTION(QStringLiteral("app/button-triple-action"), appButtonTriplePressAction, setAppButtonTriplePressAction, "action-none") + STRING_OPTION(QStringLiteral("app/button-quad-action"), appButtonQuadPressAction, setAppButtonQuadPressAction, "action-none") + + STRING_OPTION(QStringLiteral("localAdapter"), localAdapter, setLocalAdapter, "/org/bluez/hci0") + + INT_OPTION(QStringLiteral("app/refreshweather"), appRefreshWeather, setAppRefreshWeather, 80) + INT_OPTION(QStringLiteral("app/refreshcalendar"), appRefreshCalendar, setAppRefreshCalendar, 60) + + BOOL_OPTION(QStringLiteral("device/disconnectnotification"), deviceDisconnectNotification, setDeviceDisconnectNotification, false) + BOOL_OPTION(QStringLiteral("device/displayweathershortcut"), deviceDisplayWeatherShortcut, setDeviceDisplayWeatherShortcut, true) + BOOL_OPTION(QStringLiteral("device/displayalipayshortcut"), deviceDisplayAliPayShortcut, setDeviceDisplayAliPayShortcut, true) + STRING_OPTION(QStringLiteral("device/displayitems"), deviceDisplayItems, setDeviceDisplayItems, "") + + ENUM_OPTION(QStringLiteral("device/language"), deviceLanguage, setDeviceLanguage, DeviceLanguage, DeviceLanguageEnUs) + ENUM_OPTION(QStringLiteral("device/dateformat"), deviceDateFormat, setDeviceDateFormat, DeviceDateFormat, DeviceDateFormatTime) + ENUM_OPTION(QStringLiteral("device/timeformat"), deviceTimeFormat, setDeviceTimeFormat, DeviceTimeFormat, DeviceTimeFormat24H) + ENUM_OPTION(QStringLiteral("device/distanceunit"), deviceDistanceUnit, setDeviceDistanceUnit, DeviceDistanceUnit, DeviceDistanceUnitMetric) + + INT64_OPTION(QStringLiteral("device/lastactivitysyncmillis"), lastActivitySync, setLastActivitySync, 0) + INT64_OPTION(QStringLiteral("device/lastsportsyncmillis"), lastSportSync, setLastSportSync, 0) + + STRING_OPTION(QStringLiteral("device/authkey"), deviceAuthKey, setDeviceAuthKey, QString()) + + STRING_OPTION(QStringLiteral("profile/name"), profileName, setProfileName, QString()) + OPTION(QStringLiteral("profile/dob"), profileDOB, setProfileDOB, QDateTime(), QDateTime, toDateTime, const QDateTime &) + + ENUM_OPTION(QStringLiteral("profile/gender"), profileGender, setProfileGender, ProfileGender, ProfileGenderMale) + ENUM_OPTION(QStringLiteral("profile/wearlocation"), profileWearLocation, setProfileWearLocation, WearLocation, WearLocationLeftWrist) + + UINT_OPTION(QStringLiteral("profile/height"), profileHeight, setProfileHeight, 200) + UINT_OPTION(QStringLiteral("profile/weight"), profileWeight, setProfileWeight, 70) + UINT_OPTION(QStringLiteral("profile/alldayhrm"), profileAllDayHRM, setProfileAllDayHRM, 0) + UINT_OPTION(QStringLiteral("profile/fitnessgoal"), profileFitnessGoal, setProfileFitnessGoal, 10000) + + BOOL_OPTION(QStringLiteral("profile/alertfitnessgoal"), profileAlertFitnessGoal, setProfileAlertFitnessGoal, false) + BOOL_OPTION(QStringLiteral("profile/hrmsleepsupport"), profileHRMSleepSupport, setProfileHRMSleepSupport, true) + ENUM_OPTION(QStringLiteral("profile/displayonliftwrist"), profileDisplayOnLiftWrist, setProfileDisplayOnLiftWrist, DisplayLiftWrist, DisplayLiftWristOn) + OPTION(QStringLiteral("profile/wristScheduleStart"), profileWristScheduleStart, setProfileWristScheduleStart, QTime(), QDateTime, toDateTime, const QDateTime &) + OPTION(QStringLiteral("profile/wristScheduleEnd"), profileWristScheduleEnd, setProfileWristScheduleEnd, QTime(), QDateTime, toDateTime, const QDateTime &) + + ALARM_OPTION(QStringLiteral("alarms/alarm%1/enabled"), alarmEnabled, setAlarmEnabled, bool, false, toBool) + ALARM_OPTION(QStringLiteral("alarms/alarm%1/repeat"), alarmRepeatMask, setAlarmRepeatMask, int, 0, toInt) + ALARM_OPTION(QStringLiteral("alarms/alarm%1/hour"), alarmHour, setAlarmHour, int, 0, toInt) + ALARM_OPTION(QStringLiteral("alarms/alarm%1/minute"), alarmMinute, setAlarmMinute, int, 0, toInt) + +private: + using signal_ptr = void(AmazfishConfig::*)(); + + void setValue(const QString &key, const QVariant &value, signal_ptr signal); + +#ifdef MER_EDITION_SAILFISH + MDConfGroup *m_group; +#endif +}; + +#undef ALARM_OPTION +#undef ENUM_OPTION +#undef STRING_OPTION +#undef INT64_OPTION +#undef UINT_OPTION +#undef INT_OPTION +#undef BOOL_OPTION +#undef OPTION + +#endif // AMAZFISHCONFIG_H diff --git a/ui/qml/pages/Settings-profile.qml b/ui/qml/pages/Settings-profile.qml index 7eb5d2b8..1bf418bb 100644 --- a/ui/qml/pages/Settings-profile.qml +++ b/ui/qml/pages/Settings-profile.qml @@ -8,6 +8,8 @@ PagePL { title: qsTr("Profile Settings") property string dob + property date wristScheduleStart + property date wristScheduleEnd Column { id: column @@ -97,11 +99,74 @@ PagePL { } } + /* TextSwitchPL { id: swDisplayOnLiftWrist width: parent.width text: qsTr("Display on lift wrist") } + */ + + ComboBoxPL { + id: cboDisplayLiftWrist + width: parent.width + label: qsTr("Display on lift wrist") + + model: ListModel { + ListElement { itemText: qsTr("Off") } + ListElement { itemText: qsTr("On")} + ListElement { itemText: qsTr("Schedule")} + } + } + + Row { + anchors.horizontalCenter: parent.horizontalCenter + spacing: styler.themePaddingSmall + ButtonPL { + id: btnLiftWristScheduleStart + text: new Date(page.wristScheduleStart).toTimeString(); + enabled: cboDisplayLiftWrist.currentIndex === 2 + + onClicked: { + var profile_lift_start = new Date(AmazfishConfig.profileWristScheduleStart); + var dialog = app.pages.push(pickerComponentScheduleStart, { + hour: profile_lift_start.getHours(), + minute: profile_lift_start.getMinutes() + }); + dialog.accepted.connect(function() { + console.log(dialog.timeText, dialog.time, dialog.hour, dialog.minute); + page.wristScheduleStart = dialog.time; + }) + } + + Component { + id: pickerComponentScheduleStart + TimePickerDialogPL {} + } + } + + ButtonPL { + id: btnLiftWristScheduleEnd + text: new Date(page.wristScheduleEnd).toTimeString(); + enabled: cboDisplayLiftWrist.currentIndex === 2 + + onClicked: { + var profile_lift_end = new Date(AmazfishConfig.profileWristScheduleEnd); + var dialog = app.pages.push(pickerComponentScheduleEnd, { + hour: profile_lift_end.getHours(), + minute: profile_lift_end.getMinutes() + }); + dialog.accepted.connect(function() { + page.wristScheduleEnd = dialog.time; + }) + } + + Component { + id: pickerComponentScheduleEnd + TimePickerDialogPL {} + } + } + } SliderPL { id: sldFitnessGoal @@ -174,8 +239,10 @@ PagePL { sldFitnessGoal.value = AmazfishConfig.profileFitnessGoal; swAlertOnGoal.checked = AmazfishConfig.profileAlertFitnessGoal; sldAllDayHRM.value = AmazfishConfig.profileAllDayHRM; - swDisplayOnLiftWrist.checked = AmazfishConfig.profileDisplayOnLiftWrist; + cboDisplayLiftWrist.currentIndex = AmazfishConfig.profileDisplayOnLiftWrist; swHRMSleepSupport.checked = AmazfishConfig.profileHRMSleepSupport; + wristScheduleStart = AmazfishConfig.profileWristScheduleStart; + wristScheduleEnd = AmazfishConfig.profileWristScheduleEnd; } function saveProfile() { AmazfishConfig.profileName = fldName.text; @@ -187,7 +254,9 @@ PagePL { AmazfishConfig.profileFitnessGoal = sldFitnessGoal.value; AmazfishConfig.profileAlertFitnessGoal = swAlertOnGoal.checked; AmazfishConfig.profileAllDayHRM = sldAllDayHRM.value; - AmazfishConfig.profileDisplayOnLiftWrist = swDisplayOnLiftWrist.checked; + AmazfishConfig.profileDisplayOnLiftWrist = cboDisplayLiftWrist.currentIndex; + AmazfishConfig.profileWristScheduleStart = wristScheduleStart; + AmazfishConfig.profileWristScheduleEnd = wristScheduleEnd; AmazfishConfig.profileHRMSleepSupport = swHRMSleepSupport.checked; tmrSetDelay.start();