@@ -45,15 +45,13 @@ local dtsys = require "lib/dtutils.system"
45
45
local dd = require " lib/dtutils.debug"
46
46
local gettext = dt .gettext .gettext
47
47
48
- local namespace = " module_ultrahdr "
48
+ local namespace <const> = " ultrahdr "
49
49
50
- local LOG_LEVEL = log .info
50
+ local LOG_LEVEL <const> = log .info
51
51
52
52
-- works with darktable API version from 4.8.0 on
53
53
du .check_min_api_version (" 9.3.0" , " ultrahdr" )
54
54
55
- dt .gettext .bindtextdomain (namespace , dt .configuration .config_dir .. " /lua/locale/" )
56
-
57
55
local function _ (msgid )
58
56
return gettext (msgid )
59
57
end
@@ -96,31 +94,32 @@ flags.module_installed = false -- keep track of whether the module is module_ins
96
94
local script_data = {}
97
95
98
96
script_data .metadata = {
99
- name = " ultrahdr " ,
97
+ name = _ ( " UltraHDR " ) ,
100
98
purpose = _ (" generate UltraHDR images" ),
101
99
author = " Krzysztof Kotowicz"
102
100
}
103
101
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
109
108
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
112
111
113
112
-- 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
116
115
117
116
-- 1-based position of a colorspace in export profile combobox.
118
- local COLORSPACE_TO_GUI_ACTION = {
117
+ local COLORSPACE_TO_GUI_ACTION <const> = {
119
118
[DT_COLORSPACE_PQ_P3 ] = 9 ,
120
119
[DT_COLORSPACE_DISPLAY_P3 ] = 11
121
120
}
122
121
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.
124
123
125
124
local function set_log_level (level )
126
125
local old_log_level = log .log_level ()
@@ -179,7 +178,7 @@ local function save_preferences()
179
178
end
180
179
181
180
local function default_to (value , default )
182
- if value == 0 then
181
+ if value == 0 or value == " " then
183
182
return default
184
183
end
185
184
return value
@@ -193,7 +192,8 @@ local function load_preferences()
193
192
GUI .optionwidgets .selection_type_combo .selected = math.max (
194
193
dt .preferences .read (namespace , " selection_type" , " integer" ), SELECTION_TYPE_ONE_STACK )
195
194
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" )
197
197
GUI .optionwidgets .overwrite_on_conflict .value = dt .preferences .read (namespace , " overwrite_on_conflict" , " bool" )
198
198
GUI .optionwidgets .import_to_darktable .value = dt .preferences .read (namespace , " import_to_darktable" , " bool" )
199
199
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)
247
247
dt .gui .action (path , 0 , " selection" , " next" , 1.0 )
248
248
dt .control .sleep (UI_SLEEP_MS )
249
249
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 ))
251
251
return pref
252
252
end
253
253
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 ))
255
255
restore_log_level (old_log_level )
256
256
end
257
257
@@ -494,7 +494,7 @@ local function generate_ultrahdr(encoding_variant, images, settings, step, total
494
494
return cleanup (), errors
495
495
end
496
496
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 ))
498
498
update_job_progress ()
499
499
-- Strip EXIFs
500
500
table.insert (remove_files , sdr .. " .noexif" )
@@ -721,9 +721,8 @@ local function generate_ultrahdr(encoding_variant, images, settings, step, total
721
721
end
722
722
cleanup ()
723
723
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 )))
727
726
restore_log_level (old_log_level )
728
727
return true , nil
729
728
end
@@ -769,9 +768,8 @@ local function main()
769
768
job .valid = false
770
769
end
771
770
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 ))
775
773
restore_log_level (old_log_level )
776
774
end
777
775
0 commit comments