Prompt user before removing server list entry
This commit is contained in:
parent
67ed9e21ad
commit
92228e9553
|
@ -3,6 +3,7 @@ ServerList = {}
|
|||
-- private variables
|
||||
local serverListWindow = nil
|
||||
local serverTextList = nil
|
||||
local removeWindow = nil
|
||||
local servers = {}
|
||||
|
||||
-- public functions
|
||||
|
@ -69,8 +70,28 @@ function ServerList.add(host, port, protocol, load)
|
|||
return true
|
||||
end
|
||||
|
||||
function ServerList.remove(host)
|
||||
function ServerList.remove(widget)
|
||||
local host = widget:getId()
|
||||
|
||||
if removeWindow then
|
||||
return
|
||||
end
|
||||
|
||||
local yesCallback = function()
|
||||
widget:destroy()
|
||||
servers[host] = nil
|
||||
removeWindow:destroy()
|
||||
removeWindow=nil
|
||||
end
|
||||
local noCallback = function()
|
||||
removeWindow:destroy()
|
||||
removeWindow=nil
|
||||
end
|
||||
|
||||
removeWindow = displayGeneralBox(tr('Remove'), tr('Remove '..host..'?'), {
|
||||
{ text=tr('Yes'), callback=yesCallback },
|
||||
{ text=tr('No'), callback=noCallback },
|
||||
anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
|
||||
end
|
||||
|
||||
function ServerList.destroy()
|
||||
|
|
|
@ -51,10 +51,7 @@ ServerWidget < UIWidget
|
|||
anchors.right: parent.right
|
||||
margin-right: 4
|
||||
margin-top: 1
|
||||
@onClick: |
|
||||
local parent = self:getParent()
|
||||
ServerList.remove(parent:getId())
|
||||
parent:destroy()
|
||||
@onClick: ServerList.remove(self:getParent())
|
||||
|
||||
MainWindow
|
||||
id: serverListWindow
|
||||
|
|
Loading…
Reference in New Issue