improve audio badges heuristics

--added one more heuristic for app name comparison
for audio badges based on the launcher name
e.g firefox from firefox.desktop
pull/2/head
Michail Vourlakos 7 years ago
parent 2d89f1c84e
commit d5df98d5aa

@ -58,7 +58,8 @@ QtObject {
var streams = []
for (var i = 0, length = instantiator.count; i < length; ++i) {
var stream = instantiator.objectAt(i);
if (stream[key] == value) {
if (stream[key] === value
|| (key==="appName" && stream[key].toLowerCase() === value.toLowerCase())) {
streams.push(stream);
}
}

@ -140,13 +140,27 @@ MouseArea{
property string modelLauncherUrlWithIcon: (LauncherUrl !== null) ? LauncherUrl : ""
property string launcherUrl: ""
property string launcherUrlWithIcon: ""
property string launcherName: ""
property Item tooltipVisualParent: wrapper.titleTooltipVisualParent
onModelLauncherUrlChanged: {
if (modelLauncherUrl !== "")
if (modelLauncherUrl !== ""){
launcherUrl = modelLauncherUrl;
//!extract the launcherName if possible
var nameStarts = launcherUrl.lastIndexOf("/");
if (nameStarts === -1){
nameStarts = launcherUrl.lastIndexOf(":");
}
var nameEnds = launcherUrl.lastIndexOf(".desktop");
if (nameStarts!==-1 && nameEnds!==-1 && nameStarts<nameEnds) {
launcherName = launcherUrl.substring(nameStarts+1,nameEnds);
}
}
if (parabolicManager.isSeparator(modelLauncherUrl)){
isSeparator = true;
} else {
@ -1077,7 +1091,12 @@ MouseArea{
// an application, one playing and the other not, it will look up appName
// for the non-playing instance and erroneously show an indicator on both.
if (!pa.hasPidMatch(mainItemContainer.appName)) {
streams = pa.streamsForAppName(mainItemContainer.appName);
var streams_result;
streams_result = pa.streamsForAppName(mainItemContainer.appName);
if (streams_result.length===0 && launcherName !== "") {
streams_result = pa.streamsForAppName(launcherName);
}
streams = streams_result;
}
}

Loading…
Cancel
Save