| 1 |
/* GCompris - ClockGameDataDisplay.qml |
| 2 |
* |
| 3 |
* SPDX-FileCopyrightText: 2024 Bruno Anselme <[email protected]> |
| 4 |
* |
| 5 |
* Authors: |
| 6 |
* Bruno Anselme <[email protected]> |
| 7 |
* |
| 8 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 9 |
*/ |
| 10 |
pragma ComponentBehavior: Bound |
| 11 |
import QtQuick |
| 12 |
import "../../components" |
| 13 |
import "../../singletons" |
| 14 |
|
| 15 |
Item { |
| 16 |
id: lineItem |
| 17 |
required property var jsonData |
| 18 |
required property bool resultSuccess |
| 19 |
height: details.height |
| 20 |
|
| 21 |
function formatTime(list) { |
| 22 |
return ('00'+list[0]).slice(-2) + ":" + ('00'+list[1]).slice(-2) + ":" + ('00'+list[2]).slice(-2) |
| 23 |
} |
| 24 |
|
| 25 |
// Used to get longest text for aligned label columns. |
| 26 |
TextMetrics { |
| 27 |
id: expectedLabelSize |
| 28 |
font.pixelSize: Style.textSize |
| 29 |
font.bold: true |
| 30 |
text: qsTr("Expected:") |
| 31 |
} |
| 32 |
TextMetrics { |
| 33 |
id: answerLabelSize |
| 34 |
font.pixelSize: Style.textSize |
| 35 |
font.bold: true |
| 36 |
text: qsTr("Answer:") |
| 37 |
} |
| 38 |
|
| 39 |
Column { |
| 40 |
id: details |
| 41 |
InformationLine { |
| 42 |
id: expectedLine |
| 43 |
width: lineItem.width |
| 44 |
labelWidth: Math.max(expectedLabelSize.advanceWidth, answerLabelSize.advanceWidth) + 1 |
| 45 |
label: expectedLabelSize.text |
| 46 |
info: formatTime(lineItem.jsonData.expected) |
| 47 |
} |
| 48 |
InformationLine { |
| 49 |
id: answerLine |
| 50 |
width: lineItem.width |
| 51 |
labelWidth: expectedLine.labelWidth |
| 52 |
label: answerLabelSize.text |
| 53 |
info: formatTime(lineItem.jsonData.proposal) |
| 54 |
infoText.color: Style.selectedPalette.highlightedText |
| 55 |
showResult: true |
| 56 |
resultSuccess: lineItem.resultSuccess |
| 57 |
} |
| 58 |
} |
| 59 |
} |