irc: replace per-item channel list with 'Switch channel' popup menu
Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
68
main.lua
68
main.lua
@@ -489,34 +489,56 @@ function IrcChatView:onClose()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Extend the hamburger menu to add a list of joined channels/targets.
|
-- Extend the hamburger menu to add a list of joined channels/targets.
|
||||||
|
function IrcChatView:showChannelSwitcher()
|
||||||
|
local Menu = require("ui/widget/menu")
|
||||||
|
local items = {}
|
||||||
|
local targets = self._ordered_targets or {}
|
||||||
|
for _, tgt in ipairs(targets) do
|
||||||
|
local label = (tgt == "*" and _("Server console")) or tgt
|
||||||
|
table.insert(items, {
|
||||||
|
text_func = function()
|
||||||
|
local n = self._unread[tgt] or 0
|
||||||
|
if n > 0 then
|
||||||
|
return string.format("%s (%d)", label, n)
|
||||||
|
else
|
||||||
|
return label
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
checked_func = function() return self._current_target == tgt end,
|
||||||
|
callback = function(item)
|
||||||
|
self:switchTarget(tgt)
|
||||||
|
UIManager:close(self._switcher_menu)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
self._switcher_menu = Menu:new{
|
||||||
|
title = _("Switch channel"),
|
||||||
|
item_table = items,
|
||||||
|
covers_fullscreen = true,
|
||||||
|
is_borderless = true,
|
||||||
|
is_popout = false,
|
||||||
|
close_callback = function()
|
||||||
|
UIManager:close(self._switcher_menu)
|
||||||
|
self._switcher_menu = nil
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
UIManager:show(self._switcher_menu)
|
||||||
|
end
|
||||||
|
|
||||||
function IrcChatView:onShowMenu()
|
function IrcChatView:onShowMenu()
|
||||||
local ButtonDialog = require("ui/widget/buttondialog")
|
local ButtonDialog = require("ui/widget/buttondialog")
|
||||||
local SpinWidget = require("ui/widget/spinwidget")
|
local SpinWidget = require("ui/widget/spinwidget")
|
||||||
local buttons = {}
|
local buttons = {}
|
||||||
|
|
||||||
-- Channels/Targets section
|
table.insert(buttons, {
|
||||||
if self._ordered_targets and #self._ordered_targets > 0 then
|
{
|
||||||
for _, tgt in ipairs(self._ordered_targets) do
|
text = _("Switch channel"),
|
||||||
table.insert(buttons, {
|
enabled_func = function() return self._ordered_targets and #self._ordered_targets > 0 end,
|
||||||
{
|
callback = function()
|
||||||
text_func = function()
|
self:showChannelSwitcher()
|
||||||
local n = self._unread[tgt] or 0
|
end,
|
||||||
if n > 0 then
|
}
|
||||||
return string.format("%s (%d)", tgt, n)
|
})
|
||||||
else
|
|
||||||
return tgt
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
checked_func = function() return self._current_target == tgt end,
|
|
||||||
callback = function()
|
|
||||||
self:switchTarget(tgt)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
-- separator row
|
|
||||||
table.insert(buttons, { { text = "—", enabled = false, callback = function() end } })
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Font size
|
-- Font size
|
||||||
table.insert(buttons, {
|
table.insert(buttons, {
|
||||||
|
|||||||
Reference in New Issue
Block a user