chore: style cleanup for infomessage

pull/2870/head
Qingping Hou 7 years ago committed by Frans de Jonge
parent 0b47c81b1a
commit 23c2955500

@ -122,7 +122,7 @@ function CloudStorage:openCloudServer(url)
table.remove(self.paths) table.remove(self.paths)
return false return false
else else
UIManager:show(InfoMessage:new{text = _("Empty folder") }) UIManager:show(InfoMessage:new{ text = _("Empty folder") })
return false return false
end end
end end

@ -27,7 +27,7 @@ function DropBox:downloadFile(item, password, path, close)
}) })
else else
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _("Could not save file to:\n") .. path, text = T(_("Could not save file to:\n%1"), path),
timeout = 3, timeout = 3,
}) })
end end
@ -81,7 +81,7 @@ function DropBox:config(item, callback)
{ {
text = _("Info"), text = _("Info"),
callback = function() callback = function()
UIManager:show(InfoMessage:new{text = text_info }) UIManager:show(InfoMessage:new{ text = text_info })
end end
}, },
{ {
@ -99,7 +99,9 @@ function DropBox:config(item, callback)
self.settings_dialog:onClose() self.settings_dialog:onClose()
UIManager:close(self.settings_dialog) UIManager:close(self.settings_dialog)
else else
UIManager:show(InfoMessage:new{text = "Please fill in all fields." }) UIManager:show(InfoMessage:new{
text = _("Please fill in all fields.")
})
end end
end end
}, },

@ -48,7 +48,7 @@ function Ftp:downloadFile(item, address, user, pass, path, close)
}) })
else else
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _("Could not save file to:\n") .. path, text = T(_("Could not save file to:\n%1"), path),
timeout = 3, timeout = 3,
}) })
end end
@ -114,7 +114,7 @@ function Ftp:config(item, callback)
{ {
text = _("Info"), text = _("Info"),
callback = function() callback = function()
UIManager:show(InfoMessage:new{text = text_info }) UIManager:show(InfoMessage:new{ text = text_info })
end end
}, },
{ {
@ -132,7 +132,9 @@ function Ftp:config(item, callback)
self.settings_dialog:onClose() self.settings_dialog:onClose()
UIManager:close(self.settings_dialog) UIManager:close(self.settings_dialog)
else else
UIManager:show(InfoMessage:new{text = "Please fill in all fields." }) UIManager:show(InfoMessage:new{
text = _("Please fill in all fields.")
})
end end
end end
}, },

@ -482,16 +482,16 @@ function FileManager:renameFile(file)
}) })
else else
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = util.template(_( text = util.template(
"Failed to move history data of %1 to %2.\n" .. _("Failed to move history data of %1 to %2.\nThe reading history may be lost."),
"The reading history may be lost."), file, dest), file, dest),
}) })
end end
end end
else else
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = util.template( text = util.template(
_("Failed to rename from %1 to %2"), file, dest), _("Failed to rename from %1 to %2"), file, dest),
}) })
end end
end end

@ -98,7 +98,8 @@ function FileSearcher:close()
else else
UIManager:show( UIManager:show(
InfoMessage:new{ InfoMessage:new{
text = util.template(_("Found no files matching '%1'."), self.search_value) text = util.template(_("Found no files matching '%1'."),
self.search_value)
} }
) )
end end

@ -209,7 +209,11 @@ function Search:ShowSearch()
UIManager:show(self.search_dialog) UIManager:show(self.search_dialog)
else else
if self.error then if self.error then
UIManager:show(InfoMessage:new{text = self.error .. ("\n") .. _( "Unable to find a calibre metadata file."),}) UIManager:show(InfoMessage:new{
text = ("%s\n%s"):format(
self.error,
_("Unable to find a calibre metadata file.")),
})
end end
end end
@ -472,38 +476,39 @@ function Search:find(option)
self:browse(option,1) self:browse(option,1)
end end
else else
UIManager:show(InfoMessage:new{text = T(_("No match for %1."), self.search_value)}) UIManager:show(InfoMessage:new{
text = T(_("No match for %1."), self.search_value)
})
end end
end end
function Search:onMenuHold(item) function Search:onMenuHold(item)
if string.len(item.info or "") > 0 then if not item.info or item.info:len() <= 0 then return end
if item.notchecked then
item.info = item.info .. item.path
local f = io.open(item.path)
if f == nil then
item.info = item.info .. "\n" .. _("File not found!")
else
item.info = item.info .. "\n" .. _("Size:") .. " " .. string.format("%4.1fM",lfs.attributes(item.path, "size")/1024/1024)
f:close()
end
item.notchecked = false
end
local thumbnail = nil
local doc = DocumentRegistry:openDocument(item.path)
if doc then
thumbnail = doc:getCoverPageImage()
doc:close()
end
local thumbwidth = math.min(240, Screen:getWidth()/3)
UIManager:show(InfoMessage:new{
text = item.info,
image = thumbnail,
image_width = thumbwidth,
image_height = thumbwidth/2*3
})
if item.notchecked then
item.info = item.info .. item.path
local f = io.open(item.path)
if f == nil then
item.info = item.info .. "\n" .. _("File not found!")
else
item.info = item.info .. "\n" .. _("Size:") .. " " .. string.format("%4.1fM",lfs.attributes(item.path, "size")/1024/1024)
f:close()
end
item.notchecked = false
end
local thumbnail
local doc = DocumentRegistry:openDocument(item.path)
if doc then
thumbnail = doc:getCoverPageImage()
doc:close()
end end
local thumbwidth = math.min(240, Screen:getWidth()/3)
UIManager:show(InfoMessage:new{
text = item.info,
image = thumbnail,
image_width = thumbwidth,
image_height = thumbwidth/2*3
})
end end
function Search:showresults() function Search:showresults()

@ -232,7 +232,8 @@ function ReaderDictionary:onUpdateDefaultDict(dict)
logger.dbg("make default dictionary:", dict) logger.dbg("make default dictionary:", dict)
self.default_dictionary = dict self.default_dictionary = dict
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = T(_("%1 is now the default dictionary for this document."), dict), text = T(_("%1 is now the default dictionary for this document."),
dict),
timeout = 2, timeout = 2,
}) })
return true return true

@ -268,9 +268,7 @@ function MenuItem:onUnfocus()
end end
function MenuItem:onShowItemDetail() function MenuItem:onShowItemDetail()
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{ text = self.detail, })
text=self.detail,
})
return true return true
end end

Loading…
Cancel
Save