Prompt user before removing server list entry
This commit is contained in:
parent
67ed9e21ad
commit
92228e9553
|
@ -3,6 +3,7 @@ ServerList = {}
|
||||||
-- private variables
|
-- private variables
|
||||||
local serverListWindow = nil
|
local serverListWindow = nil
|
||||||
local serverTextList = nil
|
local serverTextList = nil
|
||||||
|
local removeWindow = nil
|
||||||
local servers = {}
|
local servers = {}
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
|
@ -69,8 +70,28 @@ function ServerList.add(host, port, protocol, load)
|
||||||
return true
|
return true
|
||||||
end
|
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
|
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
|
end
|
||||||
|
|
||||||
function ServerList.destroy()
|
function ServerList.destroy()
|
||||||
|
|
|
@ -51,10 +51,7 @@ ServerWidget < UIWidget
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
margin-right: 4
|
margin-right: 4
|
||||||
margin-top: 1
|
margin-top: 1
|
||||||
@onClick: |
|
@onClick: ServerList.remove(self:getParent())
|
||||||
local parent = self:getParent()
|
|
||||||
ServerList.remove(parent:getId())
|
|
||||||
parent:destroy()
|
|
||||||
|
|
||||||
MainWindow
|
MainWindow
|
||||||
id: serverListWindow
|
id: serverListWindow
|
||||||
|
|
Loading…
Reference in New Issue