@@ -45,15 +45,13 @@ local dtsys = require "lib/dtutils.system"
4545local dd = require " lib/dtutils.debug"
4646local gettext = dt .gettext .gettext
4747
48- local namespace = " module_ultrahdr "
48+ local namespace <const> = " ultrahdr "
4949
50- local LOG_LEVEL = log .info
50+ local LOG_LEVEL <const> = log .info
5151
5252-- works with darktable API version from 4.8.0 on
5353du .check_min_api_version (" 9.3.0" , " ultrahdr" )
5454
55- dt .gettext .bindtextdomain (namespace , dt .configuration .config_dir .. " /lua/locale/" )
56-
5755local function _ (msgid )
5856 return gettext (msgid )
5957end
@@ -96,31 +94,32 @@ flags.module_installed = false -- keep track of whether the module is module_ins
9694local script_data = {}
9795
9896script_data .metadata = {
99- name = " ultrahdr " ,
97+ name = _ ( " UltraHDR " ) ,
10098 purpose = _ (" generate UltraHDR images" ),
10199 author = " Krzysztof Kotowicz"
102100}
103101
104- local PS = dt .configuration .running_os == " windows" and " \\ " or " /"
105- local ENCODING_VARIANT_SDR_AND_GAINMAP = 1
106- local ENCODING_VARIANT_SDR_AND_HDR = 2
107- local ENCODING_VARIANT_SDR_AUTO_GAINMAP = 3
108- local ENCODING_VARIANT_HDR_ONLY = 4
102+ local PS <const> = dt .configuration .running_os == " windows" and " \\ " or " /"
103+
104+ local ENCODING_VARIANT_SDR_AND_GAINMAP <const> = 1
105+ local ENCODING_VARIANT_SDR_AND_HDR <const> = 2
106+ local ENCODING_VARIANT_SDR_AUTO_GAINMAP <const> = 3
107+ local ENCODING_VARIANT_HDR_ONLY <const> = 4
109108
110- local SELECTION_TYPE_ONE_STACK = 1
111- local SELECTION_TYPE_GROUP_BY_FNAME = 2
109+ local SELECTION_TYPE_ONE_STACK <const> = 1
110+ local SELECTION_TYPE_GROUP_BY_FNAME <const> = 2
112111
113112-- Values are defined in darktable/src/common/colorspaces.h
114- local DT_COLORSPACE_PQ_P3 = 24
115- local DT_COLORSPACE_DISPLAY_P3 = 26
113+ local DT_COLORSPACE_PQ_P3 <const> = 24
114+ local DT_COLORSPACE_DISPLAY_P3 <const> = 26
116115
117116-- 1-based position of a colorspace in export profile combobox.
118- local COLORSPACE_TO_GUI_ACTION = {
117+ local COLORSPACE_TO_GUI_ACTION <const> = {
119118 [DT_COLORSPACE_PQ_P3 ] = 9 ,
120119 [DT_COLORSPACE_DISPLAY_P3 ] = 11
121120}
122121
123- local UI_SLEEP_MS = 50 -- How many ms to sleep after UI action.
122+ local UI_SLEEP_MS <const> = 50 -- How many ms to sleep after UI action.
124123
125124local function set_log_level (level )
126125 local old_log_level = log .log_level ()
@@ -179,7 +178,7 @@ local function save_preferences()
179178end
180179
181180local function default_to (value , default )
182- if value == 0 then
181+ if value == 0 or value == " " then
183182 return default
184183 end
185184 return value
@@ -193,7 +192,8 @@ local function load_preferences()
193192 GUI .optionwidgets .selection_type_combo .selected = math.max (
194193 dt .preferences .read (namespace , " selection_type" , " integer" ), SELECTION_TYPE_ONE_STACK )
195194
196- GUI .optionwidgets .output_filepath_widget .text = dt .preferences .read (namespace , " output_filepath_pattern" , " string" )
195+ GUI .optionwidgets .output_filepath_widget .text = default_to (dt .preferences .read (namespace , " output_filepath_pattern" , " string" ),
196+ " $(FILE_FOLDER)/$(FILE_NAME)_ultrahdr" )
197197 GUI .optionwidgets .overwrite_on_conflict .value = dt .preferences .read (namespace , " overwrite_on_conflict" , " bool" )
198198 GUI .optionwidgets .import_to_darktable .value = dt .preferences .read (namespace , " import_to_darktable" , " bool" )
199199 GUI .optionwidgets .copy_exif .value = dt .preferences .read (namespace , " copy_exif" , " bool" )
@@ -247,11 +247,11 @@ local function set_combobox(path, instance, config_name, new_config_value)
247247 dt .gui .action (path , 0 , " selection" , " next" , 1.0 )
248248 dt .control .sleep (UI_SLEEP_MS )
249249 if dt .preferences .read (" darktable" , config_name , " integer" ) == new_config_value then
250- log .msg (log .debug , string.format (_ ( " Changed %s from %d to %d" ) , config_name , pref , new_config_value ))
250+ log .msg (log .debug , string.format (" Changed %s from %d to %d" , config_name , pref , new_config_value ))
251251 return pref
252252 end
253253 end
254- log .msg (log .error , string.format (_ ( " Could not change %s from %d to %d" ) , config_name , pref , new_config_value ))
254+ log .msg (log .error , string.format (" Could not change %s from %d to %d" , config_name , pref , new_config_value ))
255255 restore_log_level (old_log_level )
256256end
257257
@@ -494,7 +494,7 @@ local function generate_ultrahdr(encoding_variant, images, settings, step, total
494494 return cleanup (), errors
495495 end
496496 end
497- log .msg (log .debug , string.format (_ ( " Exported files: %s, %s" ) , sdr , gainmap ))
497+ log .msg (log .debug , string.format (" Exported files: %s, %s" , sdr , gainmap ))
498498 update_job_progress ()
499499 -- Strip EXIFs
500500 table.insert (remove_files , sdr .. " .noexif" )
@@ -721,9 +721,8 @@ local function generate_ultrahdr(encoding_variant, images, settings, step, total
721721 end
722722 cleanup ()
723723 update_job_progress ()
724- local msg = string.format (_ (" Generated %s." ), df .get_filename (output_file ))
725- log .msg (log .info , msg )
726- dt .print (msg )
724+ log .msg (log .info , string.format (" Generated %s." , df .get_filename (output_file )))
725+ dt .print (string.format (_ (" Generated %s." ), df .get_filename (output_file )))
727726 restore_log_level (old_log_level )
728727 return true , nil
729728end
@@ -769,9 +768,8 @@ local function main()
769768 job .valid = false
770769 end
771770
772- msg = string.format (_ (" Generated %d UltraHDR image(s)." ), count )
773- log .msg (log .info , msg )
774- dt .print (msg )
771+ log .msg (log .info , string.format (" Generated %d UltraHDR image(s)." , count ))
772+ dt .print (string.format (_ (" Generated %d UltraHDR image(s)." ), count ))
775773 restore_log_level (old_log_level )
776774end
777775
0 commit comments