mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
SortWidget: More tweaks
* Support cancelling individual moves. Coopt the cancel button to actually do just that, cancel, instead of close. * Don't close when hitting the accept button, allowing to chain multiple moves. Changes are still propagated to the caller on each individual move, though. * Update the new icons to match our usual stroke width.
This commit is contained in:
@@ -542,9 +542,9 @@ function ReaderDictionary:showDictionariesMenu(changed_callback)
|
||||
self.dicts_disabled = dicts_disabled
|
||||
G_reader_settings:saveSetting("dicts_disabled", self.dicts_disabled)
|
||||
|
||||
-- Write back the sorted items to dicts_order
|
||||
-- Write back the sorted items array to dicts_order
|
||||
local dicts_order = {}
|
||||
for i, sort_item in pairs(sort_items) do
|
||||
for i, sort_item in ipairs(sort_items) do
|
||||
dicts_order[sort_item.ifo.file] = i
|
||||
end
|
||||
self.dicts_order = dicts_order
|
||||
|
||||
@@ -61,7 +61,7 @@ local InfoMessage = InputContainer:new{
|
||||
icon = "notice-info",
|
||||
alpha = nil, -- if image or icon have an alpha channel (default to true for icons, false for images
|
||||
dismiss_callback = nil,
|
||||
-- Passed to TextBoxWidget
|
||||
-- Passed to TextBoxWidget
|
||||
alignment = "left",
|
||||
-- In case we'd like to use it to display some text we know a few more things about:
|
||||
lang = nil,
|
||||
|
||||
@@ -20,6 +20,7 @@ local UIManager = require("ui/uimanager")
|
||||
local VerticalGroup = require("ui/widget/verticalgroup")
|
||||
local VerticalSpan = require("ui/widget/verticalspan")
|
||||
local Screen = Device.screen
|
||||
local util = require("util")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -149,12 +150,15 @@ local SortWidget = InputContainer:new{
|
||||
-- index for the first item to show
|
||||
show_page = 1,
|
||||
-- table of items to sort
|
||||
item_table = nil, -- mandatory
|
||||
item_table = nil, -- mandatory (array)
|
||||
callback = nil,
|
||||
}
|
||||
|
||||
function SortWidget:init()
|
||||
self.marked = 0 -- no item is selected on start
|
||||
-- no item is selected on start
|
||||
self.marked = 0
|
||||
self.orig_item_table = nil
|
||||
|
||||
self.dimen = Geom:new{
|
||||
w = self.width or Screen:getWidth(),
|
||||
h = self.height or Screen:getHeight(),
|
||||
@@ -234,7 +238,7 @@ function SortWidget:init()
|
||||
show_parent = self,
|
||||
}
|
||||
self.footer_cancel = Button:new{
|
||||
icon = "cancel",
|
||||
icon = "exit",
|
||||
width = self.footer_button_width,
|
||||
callback = function() self:onClose() end,
|
||||
bordersize = 0,
|
||||
@@ -369,6 +373,10 @@ end
|
||||
function SortWidget:moveItem(diff)
|
||||
local move_to = self.marked + diff
|
||||
if move_to > 0 and move_to <= #self.item_table then
|
||||
-- Remember the original state to support Cancel
|
||||
if not self.orig_item_table then
|
||||
self.orig_item_table = util.tableDeepCopy(self.item_table)
|
||||
end
|
||||
table.insert(self.item_table, move_to, table.remove(self.item_table, self.marked))
|
||||
self.show_page = math.ceil(move_to / self.items_per_page)
|
||||
self.marked = move_to
|
||||
@@ -412,16 +420,17 @@ function SortWidget:_populateItems()
|
||||
end
|
||||
local chevron_first = "chevron.first"
|
||||
local chevron_last = "chevron.last"
|
||||
local move_up = "move.up"
|
||||
local move_down = "move.down"
|
||||
if BD.mirroredUILayout() then
|
||||
chevron_first, chevron_last = chevron_last, chevron_first
|
||||
move_up, move_down = move_down, move_up
|
||||
end
|
||||
if self.marked > 0 then
|
||||
self.footer_first_up:setIcon(move_up, self.footer_button_width)
|
||||
self.footer_last_down:setIcon(move_down, self.footer_button_width)
|
||||
self.footer_cancel:setIcon("cancel", self.footer_button_width)
|
||||
self.footer_cancel.callback = function() self:onCancel() end
|
||||
self.footer_first_up:setIcon("move.up", self.footer_button_width)
|
||||
self.footer_last_down:setIcon("move.down", self.footer_button_width)
|
||||
else
|
||||
self.footer_cancel:setIcon("exit", self.footer_button_width)
|
||||
self.footer_cancel.callback = function() self:onClose() end
|
||||
self.footer_first_up:setIcon(chevron_first, self.footer_button_width)
|
||||
self.footer_last_down:setIcon(chevron_last, self.footer_button_width)
|
||||
end
|
||||
@@ -475,9 +484,41 @@ function SortWidget:onClose()
|
||||
return true
|
||||
end
|
||||
|
||||
function SortWidget:onCancel()
|
||||
self.marked = 0
|
||||
if self.orig_item_table then
|
||||
-- We can't break the reference to self.item_table, as that's what the callback uses to update the original data...
|
||||
-- So, do this in two passes: empty it, then re-fill it from the copy.
|
||||
for i = #self.item_table, 1, -1 do
|
||||
self.item_table[i] = nil
|
||||
end
|
||||
|
||||
for __, item in ipairs(self.orig_item_table) do
|
||||
table.insert(self.item_table, item)
|
||||
end
|
||||
|
||||
self.orig_item_table = nil
|
||||
end
|
||||
|
||||
self:goToPage(self.show_page)
|
||||
return true
|
||||
end
|
||||
|
||||
function SortWidget:onReturn()
|
||||
UIManager:close(self)
|
||||
if self.callback then self:callback() end
|
||||
-- The callback we were passed is usually responsible for passing along the re-ordered table itself,
|
||||
-- as well as items' enabled flag, if any, meaning we have to honor it even if nothing was moved.
|
||||
if self.callback then
|
||||
self:callback()
|
||||
end
|
||||
|
||||
-- If we're not in the middle of moving stuff around, just exit.
|
||||
if self.marked == 0 then
|
||||
return self:onClose()
|
||||
end
|
||||
|
||||
self.marked = 0
|
||||
self.orig_item_table = nil
|
||||
self:goToPage(self.show_page)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="24" height="24" viewBox="0 0 24.00 24.00" enable-background="new 0 0 24.00 24.00" xml:space="preserve">
|
||||
<path fill="#000000" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 11.503,22C 6.25634,22 2.00305,17.7467 2.00305,12.5C 2.00305,7.25329 6.25634,2.99999 11.503,2.99999C 16.7497,2.99999 21.003,7.25329 21.003,12.5C 21.003,17.7467 16.7498,22 11.503,22 Z M 11.5031,21C 16.1975,21 20.003,17.1944 20.003,12.5C 20.003,10.3319 19.1913,8.35344 17.8552,6.85187L 5.85494,18.8522C 7.35651,20.1883 9.33499,21 11.5031,21 Z M 11.5031,3.99999C 6.80863,3.99999 3.00305,7.80557 3.00305,12.5C 3.00305,14.6665 3.81361,16.6437 5.14801,18.1449L 17.1479,6.14495C 15.6468,4.81054 13.6696,3.99999 11.5031,3.99999 Z "/>
|
||||
</svg>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24.00 24.00"
|
||||
enable-background="new 0 0 24.00 24.00"
|
||||
xml:space="preserve"
|
||||
id="svg4"
|
||||
sodipodi:docname="cancel.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"><metadata
|
||||
id="metadata10"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs8" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1381"
|
||||
id="namedview6"
|
||||
showgrid="true"
|
||||
inkscape:zoom="42"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4"
|
||||
inkscape:document-rotation="0"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid855" /></sodipodi:namedview>
|
||||
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 18,6 5,19"
|
||||
id="path834" /><circle
|
||||
style="fill:none;fill-opacity:0.5;stroke:#000000;stroke-width:1.5"
|
||||
id="path837"
|
||||
cx="11.5"
|
||||
cy="12.5"
|
||||
r="8.5" /></svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 1.8 KiB |
@@ -1,5 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="24" height="24" viewBox="0 0 24.00 24.00" enable-background="new 0 0 24.00 24.00" xml:space="preserve">
|
||||
<path fill="#000000" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 18.8995,8.1005L 9,18L 4.05025,13.0503L 4.75736,12.3431L 9,16.5858L 18.1924,7.3934L 18.8995,8.1005 Z "/>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24.00 24.00"
|
||||
enable-background="new 0 0 24.00 24.00"
|
||||
xml:space="preserve"
|
||||
id="svg4"
|
||||
sodipodi:docname="check.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"><metadata
|
||||
id="metadata10"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs8" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1381"
|
||||
id="namedview6"
|
||||
showgrid="true"
|
||||
inkscape:zoom="42"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid835" /></sodipodi:namedview>
|
||||
<path
|
||||
fill="#000000"
|
||||
fill-opacity="1"
|
||||
stroke-width="0.2"
|
||||
stroke-linejoin="round"
|
||||
d="M 19,8 9,18 4,13.0503 5,12 9,16 18,7 Z"
|
||||
id="path2"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 1.6 KiB |
53
resources/icons/mdlight/exit.svg
Normal file
53
resources/icons/mdlight/exit.svg
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24.00 24.00"
|
||||
enable-background="new 0 0 24.00 24.00"
|
||||
xml:space="preserve"
|
||||
id="svg4"
|
||||
sodipodi:docname="exit.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"><metadata
|
||||
id="metadata10"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs8" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1381"
|
||||
id="namedview6"
|
||||
showgrid="true"
|
||||
inkscape:zoom="42"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4"
|
||||
inkscape:document-rotation="0"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid855" /></sodipodi:namedview>
|
||||
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 18,6 5,19"
|
||||
id="path834" /><path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 5,6 18,19"
|
||||
id="path836"
|
||||
sodipodi:nodetypes="cc" /></svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user