Skip to content

Commit cf656b6

Browse files
authored
Merge pull request #2445 from alicevision/dev/sequencePlayerModifs
[ui] Sequence Player UI Modifications
2 parents 204de11 + 3c5e1ad commit cf656b6

File tree

3 files changed

+54
-19
lines changed

3 files changed

+54
-19
lines changed

meshroom/ui/qml/Utils/format.js

+47-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ function intToString(v) {
1010

1111
// Convert a plain text to an html escaped string.
1212
function plainToHtml(t) {
13-
var escaped = t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') // escape text
14-
return escaped.replace(/\n/g, '<br>') // replace line breaks
13+
var escaped = t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;') // escape text
14+
return escaped.replace(/\n/g, '<br>') // replace line breaks
1515
}
1616

1717
function divmod(x, y) {
1818
// Perform the division and get the quotient
19-
const quotient = Math.floor(x / y);
19+
const quotient = Math.floor(x / y)
2020
// Compute the remainder
21-
const remainder = x % y;
22-
return [quotient, remainder];
21+
const remainder = x % y
22+
return [quotient, remainder]
2323
}
2424

2525
function sec2timeHMS(totalSeconds) {
@@ -30,7 +30,7 @@ function sec2timeHMS(totalSeconds) {
3030
hours: hours,
3131
minutes: minutes,
3232
seconds: seconds
33-
};
33+
}
3434
}
3535

3636
function sec2timecode(timeSeconds) {
@@ -43,22 +43,22 @@ function sec2timecode(timeSeconds) {
4343
function sec2timeStr(timeSeconds) {
4444
// Need to decide the rounding precision first
4545
// to propagate the right values
46-
if(timeSeconds >= 60.0) {
46+
if (timeSeconds >= 60.0) {
4747
timeSeconds = Math.round(timeSeconds)
4848
} else {
4949
timeSeconds = parseFloat(timeSeconds.toFixed(2))
5050
}
5151
var timeObj = sec2timeHMS(timeSeconds)
5252
var timeStr = ""
53-
if(timeObj.hours > 0) {
53+
if (timeObj.hours > 0) {
5454
timeStr += timeObj.hours + "h"
5555
}
56-
if(timeObj.hours > 0 || timeObj.minutes > 0) {
56+
if (timeObj.hours > 0 || timeObj.minutes > 0) {
5757
timeStr += timeObj.minutes + "m"
5858
}
59-
if(timeObj.hours === 0) {
59+
if (timeObj.hours === 0) {
6060
// seconds only matter if the elapsed time is less than 1 hour
61-
if(timeObj.minutes === 0) {
61+
if (timeObj.minutes === 0) {
6262
// If less than a minute, keep millisecond precision
6363
timeStr += timeObj.seconds.toFixed(2) + "s"
6464
} else {
@@ -68,3 +68,39 @@ function sec2timeStr(timeSeconds) {
6868
}
6969
return timeStr
7070
}
71+
72+
function GB2GBMBKB(GB) {
73+
// Convert GB to GB, MB, KB
74+
var GBInt = Math.floor(GB)
75+
var MB = Math.floor((GB - GBInt) * 1024)
76+
var KB = Math.floor(((GB - GBInt) * 1024 - MB) * 1024)
77+
return {
78+
GB: GBInt,
79+
MB: MB,
80+
KB: KB
81+
}
82+
}
83+
84+
function GB2SizeStr(GB) {
85+
// Convert GB to a human readable size string
86+
// e.g. 1.23GB, 456MB, 789KB
87+
// We only use one unit at a time
88+
var sizeObj = GB2GBMBKB(GB)
89+
var sizeStr = ""
90+
if (sizeObj.GB > 0) {
91+
sizeStr += sizeObj.GB
92+
if (sizeObj.MB > 0 && sizeObj.GB < 10) {
93+
sizeStr += "." + Math.floor(sizeObj.MB / 1024 * 1000)
94+
}
95+
sizeStr += "GB"
96+
} else if (sizeObj.MB > 0) {
97+
sizeStr = sizeObj.MB
98+
if (sizeObj.KB > 0 && sizeObj.MB < 10) {
99+
sizeStr += "." + Math.floor(sizeObj.KB / 1024 * 1000)
100+
}
101+
sizeStr += "MB"
102+
} else if (sizeObj.GB === 0 && sizeObj.MB === 0) {
103+
sizeStr += sizeObj.KB + "KB"
104+
}
105+
return sizeStr
106+
}

meshroom/ui/qml/Viewer/SequencePlayer.qml

+6-6
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ FloatingPane {
190190

191191
color: palette.text
192192
horizontalAlignment: Text.AlignHCenter
193+
selectByMouse: true
194+
193195
text: m.frame
194196

195197
onEditingFinished: {
@@ -308,6 +310,7 @@ FloatingPane {
308310
id: fpsTextInput
309311

310312
Layout.preferredWidth: fpsMetrics.width
313+
selectByMouse: true
311314

312315
text: !focus ? m.fps + " FPS" : m.fps
313316
color: palette.text
@@ -482,18 +485,15 @@ FloatingPane {
482485
ProgressBar {
483486
id: occupiedCacheProgressBar
484487

488+
property string occupiedCache: viewer.ramInfo ? Format.GB2SizeStr(viewer.ramInfo.y) : 0
489+
485490
width: parent.width
486491

487492
from: 0
488493
to: settings_SequencePlayer.maxCacheMemory
489494
value: viewer && viewer.ramInfo != undefined ? viewer.ramInfo.y : 0
490495

491-
ToolTip.text: {
492-
if (viewer && viewer.ramInfo != undefined) {
493-
return "Occupied cache: "+ viewer.ramInfo.y + " GB" + "\n" + "On max cache memory set: " + settings_SequencePlayer.maxCacheMemory + " GB"
494-
}
495-
return "Unknown occupied cache (max cache memory set: " + settings_SequencePlayer.maxCacheMemory + ")"
496-
}
496+
ToolTip.text: "Occupied cache: " + occupiedCache + "\n" + "On max cache memory set: " + settings_SequencePlayer.maxCacheMemory + " GB"
497497
ToolTip.visible: hovered
498498
ToolTip.delay: 100
499499
}

meshroom/ui/qml/Viewer/Viewer2D.qml

+1-2
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,7 @@ FocusScope {
508508
'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput))) ? getSequence() : []) }),
509509
'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize }),
510510
'useSequence': Qt.binding(function() {
511-
let attr = root.displayedNode ? root.displayedNode.attributes.get(outputAttribute.name) : undefined
512-
return (root.enableSequencePlayer && !useExternal && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput)) && (attr.desc.semantic === "imageList" || attr.desc.semantic === "sequence"))
511+
return (root.enableSequencePlayer && !useExternal && (_reconstruction || (root.displayedNode && root.displayedNode.hasSequenceOutput && (displayedAttr.desc.semantic === "imageList" || displayedAttr.desc.semantic === "sequence"))))
513512
}),
514513
'fetchingSequence': Qt.binding(function() { return sequencePlayer.loading }),
515514
'memoryLimit': Qt.binding(function() { return sequencePlayer.settings_SequencePlayer.maxCacheMemory }),

0 commit comments

Comments
 (0)