parent
b81590f297
commit
2f9e2c3e33
|
@ -88,6 +88,23 @@ function isHiddingOffline()
|
||||||
return settings['hideOffline']
|
return settings['hideOffline']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getSortedBy()
|
||||||
|
local settings = g_settings.getNode('VipList')
|
||||||
|
if not settings then
|
||||||
|
return 'status'
|
||||||
|
end
|
||||||
|
return settings['sortedBy']
|
||||||
|
end
|
||||||
|
|
||||||
|
function sortBy(state)
|
||||||
|
settings = {}
|
||||||
|
settings['sortedBy'] = state
|
||||||
|
g_settings.mergeNode('VipList', settings)
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function onAddVip(id, name, state)
|
function onAddVip(id, name, state)
|
||||||
local vipList = vipWindow:getChildById('contentsPanel')
|
local vipList = vipWindow:getChildById('contentsPanel')
|
||||||
|
|
||||||
|
@ -118,13 +135,13 @@ function onAddVip(id, name, state)
|
||||||
|
|
||||||
for i=1,childrenCount do
|
for i=1,childrenCount do
|
||||||
local child = vipList:getChildByIndex(i)
|
local child = vipList:getChildByIndex(i)
|
||||||
if state == VipState.Online and child.vipState ~= VipState.Online then
|
if state == VipState.Online and child.vipState ~= VipState.Online and getSortedBy() == 'status' then
|
||||||
vipList:insertChild(i, label)
|
vipList:insertChild(i, label)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (state ~= VipState.Online and child.vipState ~= VipState.Online)
|
if ((state ~= VipState.Online and child.vipState ~= VipState.Online)
|
||||||
or (state == VipState.Online and child.vipState == VipState.Online) then
|
or (state == VipState.Online and child.vipState == VipState.Online)) or getSortedBy() == 'name' then
|
||||||
|
|
||||||
local childText = child:getText():lower()
|
local childText = child:getText():lower()
|
||||||
local length = math.min(childText:len(), nameLower:len())
|
local length = math.min(childText:len(), nameLower:len())
|
||||||
|
@ -168,6 +185,14 @@ function onVipListMousePress(widget, mousePos, mouseButton)
|
||||||
menu:addOption(tr('Show Offline'), function() hideOffline(false) end)
|
menu:addOption(tr('Show Offline'), function() hideOffline(false) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not(getSortedBy() == 'name') then
|
||||||
|
menu:addOption(tr('Sort by name'), function() sortBy('name') end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not(getSortedBy() == 'status') then
|
||||||
|
menu:addOption(tr('Sort by status'), function() sortBy('status') end)
|
||||||
|
end
|
||||||
|
|
||||||
menu:display(mousePos)
|
menu:display(mousePos)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -196,6 +221,15 @@ function onVipListLabelMousePress(widget, mousePos, mouseButton)
|
||||||
else
|
else
|
||||||
menu:addOption(tr('Show Offline'), function() hideOffline(false) end)
|
menu:addOption(tr('Show Offline'), function() hideOffline(false) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not(getSortedBy() == 'name') then
|
||||||
|
menu:addOption(tr('Sort by name'), function() sortBy('name') end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not(getSortedBy() == 'status') then
|
||||||
|
menu:addOption(tr('Sort by status'), function() sortBy('status') end)
|
||||||
|
end
|
||||||
|
|
||||||
menu:display(mousePos)
|
menu:display(mousePos)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue