D11352: [RFC] Auto ordered systray

Wojciech Stachurski noreply at phabricator.kde.org
Tue Mar 20 11:19:18 UTC 2018


wsdfhjxc added a comment.


  Unfortunately, comparing by `item.text` with a non-US language enabled makes the result worse than on previous screenshot (especially the order of items within the `Hardware` group is very odd). To get it consistent regardless of system's language setting it might be better to compare by `item.itemId`. Although `StatusNotifierItem` may have it undefined initially, it can be fixed with a timer hack and waiting till a proper `Id` is available, then updating the `itemId` property and calling `updateItemVisibility()` function.
  
  Modifying the comparing function to look at `item.itemId` instead of `item.text` makes the result no better than it was originally. However, if compared strings are slightly altered in a specific way, the result might be better (something like a seed to get the most satisfying pattern). For example:
  
    function compareItems(a, b) {
        var categoryDiff = indexForItemCategory(a) - indexForItemCategory(b)
        var altA = a.itemId ? a.itemId.replace("org.kde.", "").replace("plasma.", "") : ""
        var altB = b.itemId ? b.itemId.replace("org.kde.", "").replace("plasma.", "") : ""
        altA = altA.substring(altA.length / 2, altA.length)        
        altB = altB.substring(altB.length / 2, altB.length)
        return categoryDiff != 0 ? categoryDiff : altA.localeCompare(altB)
    }
  
  Screenshot below presents the item ordering result after this modification, which is consistent regardless of system's language setting and which looks nicer in my opinion.
  F5759917: Items.png <https://phabricator.kde.org/F5759917>
  
  I don't really have any other ideas on further improvements, so forgive me if you find this one utterly stupid, I promise there will bo no more of them :)

REPOSITORY
  R120 Plasma Workspace

REVISION DETAIL
  https://phabricator.kde.org/D11352

To: Pitel
Cc: wsdfhjxc, mart, plasma-devel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20180320/60e77e4d/attachment-0001.html>


More information about the Plasma-devel mailing list