Index: sources/gui/qml/components/TimeText.qml =================================================================== diff -u -r94f7349bd073a732dba5295250fc0e26f740743c -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/gui/qml/components/TimeText.qml (.../TimeText.qml) (revision 94f7349bd073a732dba5295250fc0e26f740743c) +++ sources/gui/qml/components/TimeText.qml (.../TimeText.qml) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,20 +1,20 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * \copyright \n - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n - * IN PART OR IN WHOLE, \n - * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n + * Copyright (c) 2020-2024 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file TimeText.qml - * \date 2020/02/03 - * \author Behrouz NematiPour + * \author (last) Behrouz NematiPour + * \date (last) 30-Aug-2022 + * \author (original) Behrouz NematiPour + * \date (original) 04-Feb-2020 * */ // Qt import QtQuick 2.12 -import QtQuick.Controls 2.12 // Project @@ -24,59 +24,83 @@ /*! * \brief Time Text Component converts seconds into hour:minute.second */ -Item { id: _root +Rectangle { id: _root + objectName: "_TimeText" //SquishQt testability property int seconds : 0 - property color color : "white" + property bool secondsVisible : true + + property bool hourZero : true + property bool minuteZero : true + property bool secondZero : true + + property color textColor : Colors.textMain property int textPixelSize : 90 + property int textWeight : Font.ExtraLight property int secsPixelSize : 16 - width : _timeHour.contentWidth + _timeSeparator.contentWidth + _timeMinute.contentWidth + readonly property string time : _private.time + + color : Colors.transparent + width : _hourText.contentWidth + _timeSeparator.contentWidth + _minuteText.contentWidth + _timeSeparator.contentWidth height: _timeSeparator.height QtObject { id: _private - property int hour : Math.floor( seconds / 3600 ) - property int minute : Math.floor((seconds % 3600) / 60); - property int second : seconds % 60 + property int hour : Math.floor( seconds / 3600 ) + property int minute : Math.floor((seconds % 3600) / 60) + property int second : seconds % 60 + + property string separator : ":" + property string hourText : (hour < 10 ? ( _root.hourZero ? "0" : "") + hour : hour ) + property string minuteText : (minute < 10 ? ( _root.minuteZero ? "0" : "") + minute : minute) + property string secondText : (second < 10 ? ( _root.secondZero ? "0" : "") + second : second) + + property string time : hourText + separator + minuteText + (_root.secondsVisible ? (separator + secondText) : "") } Text { id: _timeSeparator - text: ":" + objectName: "_TimeText_timeSeparator" //SquishQt testability + text: _private.separator + font.pixelSize: _root.textPixelSize - font.weight: Font.ExtraLight - color: _root.color + font.weight: _root.textWeight + color: _root.textColor anchors.centerIn: _root } - Text { id: _timeHour - property alias hour: _private.hour + Text { id: _hourText + objectName: "_TimeText_hour" //SquishQt testability + + text: _private.hourText font.pixelSize: _root.textPixelSize - font.weight: Font.ExtraLight - color: _root.color + font.weight: _root.textWeight + color: _root.textColor horizontalAlignment: Text.AlignRight anchors.right : _timeSeparator.left anchors.baseline: _timeSeparator.baseline - - text: (hour < 10 ? "0"+hour : hour) } - Text { id: _timeMinute - property alias minute: _private.minute - text: (minute < 10 ? "0" + minute : minute) + Text { id: _minuteText + objectName: "_TimeText_minute" //SquishQt testability + + text: _private.minuteText font.pixelSize: _root.textPixelSize - font.weight: Font.ExtraLight - color: _root.color + font.weight: _root.textWeight + color: _root.textColor horizontalAlignment: Text.AlignLeft anchors.left: _timeSeparator.right anchors.baseline: _timeSeparator.baseline } - Text { id: _timeSecond - property alias second: _private.second - text: (second < 10 ? "0" + second : second) + Text { id: _secondText + objectName: "_TimeText_second" //SquishQt testability + + visible: _root.secondsVisible + + text: _private.secondText font.pixelSize: _root.secsPixelSize - color: _root.color + color: _root.textColor horizontalAlignment: Text.AlignLeft - anchors.left: _timeMinute.right + anchors.left: _minuteText.right anchors.baseline: _timeSeparator.baseline } }