Skip to content

Commit cb8c978

Browse files
authored
fixed user plugins more tools automatic rearrangement
1 parent 11b034c commit cb8c978

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

main.lua

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,7 @@ function MenuDisabler:generateWorkingList(menu_type, filename)
394394
end
395395
end
396396

397-
if not enabled_map.more_tools then enabled_map.more_tools = {} end
398-
for p_name, _ in pairs(plugins) do
399-
local found = false
400-
for section, items in pairs(enabled_map) do
401-
if items[p_name] ~= nil then found = true break end
402-
end
403-
if not found then enabled_map.more_tools[p_name] = true end
404-
end
405-
397+
406398
if user_struct["KOMenu:disabled"] then
407399
for _, disabled_item in ipairs(user_struct["KOMenu:disabled"]) do
408400
for section, items in pairs(enabled_map) do
@@ -679,10 +671,7 @@ function MenuDisabler:saveChanges()
679671
end
680672
end
681673

682-
-- RESTORED: Write the section lists. This is required for customization to work.
683-
-- To avoid "NEW" labels, we rely on the logic above to ensure all known items
684-
-- are included in the lists. "NEW" labels on core items were mainly caused
685-
-- by the corrupt 'copySettings' function, which this update also fixes below.
674+
686675
for key, val in pairs(output_table) do
687676
if not key:match("^KOMenu:") then
688677
f:write(" [\"" .. key .. "\"] = {\n")
@@ -722,10 +711,9 @@ function MenuDisabler:confirmResetEverything()
722711
end
723712

724713
function MenuDisabler:copySettings()
725-
-- FIX: Intelligent copy that maps disabled items without breaking structure.
726714
-- This prevents the "NEW" label bug caused by overwriting the Reader config with FM structure.
727715

728-
-- 1. Get the DISABLED items from the user's File Manager settings
716+
items from the user's File Manager settings
729717
local fm_custom = self:getUserCustomStructure("filemanager_menu_order.lua")
730718
if not fm_custom or not fm_custom["KOMenu:disabled"] then
731719
UIManager:show(InfoMessage:new{text=_("No disabled items in File Manager to copy.")})
@@ -735,25 +723,21 @@ function MenuDisabler:copySettings()
735723
local disabled_lookup = {}
736724
for _, item in ipairs(disabled_items) do disabled_lookup[item] = true end
737725

738-
-- 2. Load the valid Reader structure from defaults
739726
local reader_def = self:getSystemDefaultStructure("reader")
740727
if not reader_def or next(reader_def) == nil then
741728
UIManager:show(InfoMessage:new{text=_("Error: Could not load Reader defaults.")})
742729
return
743730
end
744731

745-
-- 3. Apply the disabled status to the Reader structure
746732
local output_table = {}
747733
local final_disabled_list = {}
748734

749-
-- Copy over any existing disabled items from reader defaults if any
750735
if reader_def["KOMenu:disabled"] then
751736
for _, item in ipairs(reader_def["KOMenu:disabled"]) do
752737
table.insert(final_disabled_list, item)
753738
end
754739
end
755740

756-
-- Process sections: if item is disabled in FM, move it to disabled list in Reader
757741
for section, items in pairs(reader_def) do
758742
if type(items) == "table" and not section:match("^KOMenu:") then
759743
output_table[section] = {}
@@ -775,12 +759,10 @@ function MenuDisabler:copySettings()
775759

776760
output_table["KOMenu:disabled"] = final_disabled_list
777761

778-
-- Preserve KOMenu:menu_buttons if present in defaults
779762
if reader_def["KOMenu:menu_buttons"] then
780763
output_table["KOMenu:menu_buttons"] = util.tableDeepCopy(reader_def["KOMenu:menu_buttons"])
781764
end
782765

783-
-- 4. Write the clean Reader file
784766
local dst_path = self.settings_path .. "/reader_menu_order.lua"
785767
local f = io.open(dst_path, "w")
786768
if not f then
@@ -815,5 +797,4 @@ function MenuDisabler:safeRestart()
815797
ok_text = _("OK"),
816798
})
817799
end
818-
819-
return MenuDisabler
800+
return MenuDisabler

0 commit comments

Comments
 (0)