blob: 61f70e43c26f7b9fde50449062af4fbee8f8121b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// SPDX-License-Identifier: Unlicense
// If text contains key, make it stand out; otherwise, append [key] to text.
function addShortcut(text, key) {
if (!key)
return text
else if (text.indexOf(key) < 0)
return `${text} [<b>${key}</b>]`
else
return text.replace(new RegExp('\(' + key + '\)'), '<b>$1</b>')
}
// Set alpha value for color.
function alphize(color, alpha) {
return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha)
}
// Return the last event in list with property not greater than value.
function find(list, property, value) {
var low = 0
var high = list.count - 1
while (low <= high) {
var mid = Math.floor((low + high) / 2)
if (list.get(mid)[property] <= value)
low = mid + 1
else
high = mid - 1
}
return low
}
|