Index: sources/gui/qml/components/TextEntry.qml =================================================================== diff -u -r9048646630717f980a852df54349805ba63773e0 -r3738eb975493a36efae6b1a060624abab72c6871 --- sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 9048646630717f980a852df54349805ba63773e0) +++ sources/gui/qml/components/TextEntry.qml (.../TextEntry.qml) (revision 3738eb975493a36efae6b1a060624abab72c6871) @@ -38,6 +38,7 @@ property alias lengthMax : _input.maximumLength property bool useQtNumPad : true property bool showPlaceHolderText: false + property bool showDisabledColor :false // only show greyed text if allowed. readonly property alias isValid : _input.acceptableInput @@ -101,7 +102,10 @@ width : TextEntry.InputWidth text : "" font.pixelSize : Fonts.fontPixelTextRectExtra - color : acceptableInput ? Colors.textMain : Colors.red + color : acceptableInput ? _root.showDisabledColor && + enabled ? + Colors.textMain : Colors.borderDisableButton : + Colors.red selectionColor : Colors.borderButtonHalfDarker selectedTextColor : acceptableInput ? Colors.textMain : Colors.red anchors.left : _separator.right Index: sources/gui/qml/pages/settings/SettingsDateTime.qml =================================================================== diff -u -r3d5bd682a4dc4bd36e26ca17067bafd489fa970b -r3738eb975493a36efae6b1a060624abab72c6871 --- sources/gui/qml/pages/settings/SettingsDateTime.qml (.../SettingsDateTime.qml) (revision 3d5bd682a4dc4bd36e26ca17067bafd489fa970b) +++ sources/gui/qml/pages/settings/SettingsDateTime.qml (.../SettingsDateTime.qml) (revision 3738eb975493a36efae6b1a060624abab72c6871) @@ -41,16 +41,18 @@ _hours .textInput.acceptableInput && _minutes.textInput.acceptableInput + readonly property color entryTextColor : _ntpSwitch.checked ? Colors.borderDisableButton : Colors.textMain + confirmEnabled : isValid - firstFocusInput : _hours notificationText: vDateTime.status onConfirmClicked: { vDateTime.doConfirm( _year .textInput.text , _month .textInput.text , _day .textInput.text , _hours .textInput.text , - _minutes.textInput.text ) + _minutes.textInput.text , + _ntpSwitch.checked ) } onVisibleChanged: { // it seems entering in the TextInput by keyboard breaks the binding @@ -64,12 +66,26 @@ contentItem: Column { id: _container spacing : 25 + LabelUnitContainer { id: _ntpSettings + anchors.horizontalCenter : parent.horizontalCenter + width : Variables.adjustmentLabelUnitContainerWidth + height : Variables.adjustmentLabelUnitContainerHeight + unitText : qsTr("Network Time Protocol") + text : qsTr("NTP") + contentArea.anchors.leftMargin : width * 0.75 + + contentItem: BaseSwitch { id: _ntpSwitch + checked : vDateTime.ntp + } + } + LabelUnitContainer { id: _timeContainer anchors.horizontalCenter : parent.horizontalCenter width : Variables.adjustmentLabelUnitContainerWidth height : Variables.adjustmentLabelUnitContainerHeight text : qsTr("Time") unitText : qsTr("HH:MM") + enabled : ! _ntpSwitch.checked contentItem: Row { // time spacing : 10 @@ -80,6 +96,7 @@ line.visible : false width : entryWidth showPlaceHolderText : true + showDisabledColor : true validator : IntValidator { bottom : 0 top : 23 @@ -89,6 +106,7 @@ Label { text : qsTr(":") + color : _root.entryTextColor width : 10 } @@ -97,6 +115,7 @@ line.visible : false width : entryWidth showPlaceHolderText : true + showDisabledColor : true validator : IntValidator { bottom : 0 top : 59 @@ -112,6 +131,7 @@ height : Variables.adjustmentLabelUnitContainerHeight text : qsTr("Date") unitText : qsTr("MM/DD/YYYY") + enabled : ! _ntpSwitch.checked contentItem: Row { // time spacing : 10 @@ -122,6 +142,7 @@ line.visible : false width : entryWidth showPlaceHolderText : true + showDisabledColor : true validator : IntValidator { bottom : 1 top : 12 @@ -131,14 +152,16 @@ Label { id : _slashMonthDay text : qsTr(":") - width : 10 + color : _root.entryTextColor + width : 5 } TextEntry { id: _day nextInput : _year line.visible : false width : entryWidth showPlaceHolderText : true + showDisabledColor : true validator : IntValidator { bottom : 1 top : 31 @@ -148,13 +171,15 @@ Label { id : _slashDayYear text : qsTr(":") - width : 10 + color : _root.entryTextColor + width : 5 } TextEntry { id: _year line.visible : false width : entryWidth showPlaceHolderText : true + showDisabledColor : true validator : IntValidator { bottom : 1970 top : 2100 // seems date command is not accepting more than 2100 Index: sources/view/settings/VDateTime.cpp =================================================================== diff -u -r3d5bd682a4dc4bd36e26ca17067bafd489fa970b -r3738eb975493a36efae6b1a060624abab72c6871 --- sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 3d5bd682a4dc4bd36e26ca17067bafd489fa970b) +++ sources/view/settings/VDateTime.cpp (.../VDateTime.cpp) (revision 3738eb975493a36efae6b1a060624abab72c6871) @@ -84,20 +84,22 @@ const QString &vMonth , const QString &vDay , const QString &vHour , - const QString &vMinute ) + const QString &vMinute , + const bool &vNTP ) { year ( vYear ); month ( vMonth ); day ( vDay ); hour ( vHour ); minute ( vMinute ); + ntp ( vNTP ); const QDateTime currentDateTimeLocal ( QDate(_year .toInt() , _month .toInt() , _day .toInt()) , QTime(_hour .toInt() , _minute .toInt())); - const QString dateTimeLocalStr = currentDateTimeLocal.toString(_Settings.getDatetimeFormat()); + const QString dateTimeLocalStr = currentDateTimeLocal.toString("yyyy-MM-dd HH:mm:ss"); // sudo date -s requires this format // Get the current UTC datetime const QDateTime currentDateTimeUTC = currentDateTimeLocal.toUTC(); @@ -106,9 +108,9 @@ LOG_DEBUG(tr("SetDateTime %1").arg(dateTimeLocalStr)); status("Setting date and time ..."); - dateTimeUI(dateTimeLocalStr ); - dateTimeHD(epochUTC_sec ); // ??? TODO - dateTimeDG(epochUTC_sec ); // ??? TODO + dateTimeUI(dateTimeLocalStr, vNTP ); + dateTimeHD(epochUTC_sec ); // ??? TODO + dateTimeDG(epochUTC_sec ); // ??? TODO } /*! @@ -183,12 +185,15 @@ * \brief VDateTime::dateTimeUI * \details starts the shell script in a process defined in Storage::Date_Time_Set_Sh to update the device date/time */ -void VDateTime::dateTimeUI(const QString &vDateTime) +void VDateTime::dateTimeUI(const QString &vDateTime, const bool &vNTP) { if ( _process.state() != QProcess::NotRunning ) { return; } QString mScript = Storage::Scripts_Path_Name(); mScript += Storage::Date_Time_Set_Sh; - _process.start(mScript, QStringList() << vDateTime); + QStringList arguments; + arguments << vDateTime << (vNTP ? "true" : "false"); + + _process.start(mScript, arguments); } /*! @@ -274,7 +279,7 @@ hdRTCTime_localZone.setSecsSinceEpoch(vData.mEpoch); const QString newDateTimeString = hdRTCTime_localZone.toString(_Settings.getDatetimeFormat()); - dateTimeUI(newDateTimeString); + dateTimeUI(newDateTimeString, false); _hasDoneHDSyncRTC = true; // indicate HD-UI RTC sync'd Index: sources/view/settings/VDateTime.h =================================================================== diff -u -r2ad0fc5c1215088ee0e4ea7f9b2bc367c4ed2fd9 -r3738eb975493a36efae6b1a060624abab72c6871 --- sources/view/settings/VDateTime.h (.../VDateTime.h) (revision 2ad0fc5c1215088ee0e4ea7f9b2bc367c4ed2fd9) +++ sources/view/settings/VDateTime.h (.../VDateTime.h) (revision 3738eb975493a36efae6b1a060624abab72c6871) @@ -77,7 +77,8 @@ void dateTimeHD(quint32 epoch); void dateTimeDG(quint32 epoch); - void dateTimeUI(const QString &vDateTime); + void dateTimeUI(const QString &vDateTime, + const bool &vNTP ); QString status(DateTimeSetStatus vStatus, quint8 vReason); void updateStatus(); @@ -88,6 +89,7 @@ TRIGGER (QString, hour , "00" ) TRIGGER (QString, minute , "00" ) TRIGGER (QString, second , "00" ) + TRIGGER (bool , ntp , false ) PROPERTY(QString, status , "" ) PROPERTY(QString, current , "" ) @@ -115,7 +117,8 @@ const QString &vMonth , const QString &vDay , const QString &vHour , - const QString &vMinute); + const QString &vMinute, + const bool &vNTP ); void onSetDateUIErrored(QProcess::ProcessError error); signals: