Profiles: fix New profile with current pdf document settings (#10778)

reviewable/pr10773/r1
hius07 9 months ago committed by GitHub
parent 1544ca28af
commit 0499b5109a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -584,6 +584,12 @@ function Dispatcher:getNameFromItem(item, settings, dont_show_value)
return title
end
-- Converts copt/kopt-options values to args.
function Dispatcher:getArgFromValue(item, value)
local value_num = util.arrayContains(settingsList[item].configurable.values, value)
return settingsList[item].args[value_num]
end
-- Add the item to the end of the execution order.
-- If item or the order is nil all items will be added.
function Dispatcher:_addToOrder(location, settings, item)

@ -337,27 +337,29 @@ function Profiles:getProfileFromCurrentDocument(new_name)
"kopt_quality",
}
end
local setting_needs_arg = {
["view_mode"] = true,
["kopt_trim_page"] = true,
["kopt_zoom_mode_genus"] = true,
["kopt_zoom_mode_type"] = true,
["kopt_page_scroll"] = true,
}
local profile = { settings = { name = new_name, order = document_settings } }
for _, v in ipairs(document_settings) do
profile[v] = self.document.configurable[self.ui.rolling and v or v:sub(6)]
-- document configurable settings do not have prefixes
local value = self.document.configurable[v:gsub("^kopt_", "")]
if setting_needs_arg[v] then
value = Dispatcher:getArgFromValue(v, value)
end
profile[v] = value
end
if self.ui.rolling then
profile["set_font"] = self.ui.font.font_face
profile["sync_t_b_page_margins"] = self.ui.typeset.sync_t_b_page_margins
profile["view_mode"] = self.view.view_mode
profile["embedded_css"] = self.ui.typeset.embedded_css
profile["embedded_fonts"] = self.ui.typeset.embedded_fonts
profile["smooth_scaling"] = self.ui.typeset.smooth_scaling
else
local trim_page_to_mode = { _("manual"), _("auto"), _("semi-auto"), _("none") }
local zoom_genus_to_mode = { _("manual"), _("rows"), _("columns"), _("content"), _("page") }
local zoom_type_to_mode = { _("height"), _("width"), _("full") }
profile["rotation_mode"] = self.document.configurable.rotation_mode
profile["kopt_trim_page"] = trim_page_to_mode[profile["kopt_trim_page"]+1]
profile["kopt_zoom_mode_genus"] = zoom_genus_to_mode[profile["kopt_zoom_mode_genus"]+1]
profile["kopt_zoom_mode_type"] = zoom_type_to_mode[profile["kopt_zoom_mode_type"]+1]
profile["kopt_page_scroll"] = self.view.page_scroll
end
return profile
end

Loading…
Cancel
Save