Skip to content

Commit

Permalink
Fix the way metadata export preferences work
Browse files Browse the repository at this point in the history
Metadata export preferences now work the same way as all other export
settings.  They are stored on a per-format basis, with last-used
settings automatically saved/loaded on each invocation.

This means there is now just one metadata export preference in the Tools
> Options dialog: marking PD as the last-used software.  (Note that even
if this setting is enabled, it will be ignored if the "anonymize
metadata" setting is clicked at export time.)
  • Loading branch information
tannerhelland committed Sep 10, 2016
1 parent f869488 commit a39cf03
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Classes/pdMetadata.cls
Expand Up @@ -1356,7 +1356,7 @@ Public Function WriteAllMetadata(ByVal outputPath As String, ByRef srcImage As p
Dim forciblyAnonymize As Boolean
forciblyAnonymize = cParams.GetBool("MetadataAnonymize", True)

If forciblyAnonymize And Me.HasMetadata Then
If (forciblyAnonymize And Me.HasMetadata) Then

Message "Removing metadata with potential privacy concerns..."

Expand Down
2 changes: 0 additions & 2 deletions Classes/pdPreferences.cls
Expand Up @@ -508,8 +508,6 @@ Private Sub CreateNewPreferencesFile()
xmlEngine.WriteTag "ConfirmClosingUnsaved", "True"
xmlEngine.WriteTag "OverwriteOrCopy", "0"
xmlEngine.WriteTag "SuggestedFormat", "0"
xmlEngine.WriteTag "PreserveMetadata", "True"
xmlEngine.WriteTag "AnonymizeMetadata", "False"
xmlEngine.WriteTag "MetadataListPD", "True"
xmlEngine.CloseTag "Saving"
xmlEngine.WriteBlankLine
Expand Down
6 changes: 3 additions & 3 deletions Controls/pdCommandBar.ctl
Expand Up @@ -657,7 +657,7 @@ Private Sub ResetSettings()
eControl.Text = "0"

'A metadata management control has its own "reset" function
Case "pdMetadata"
Case "pdMetadataExport"
eControl.Reset

End Select
Expand Down Expand Up @@ -911,7 +911,7 @@ Private Sub StorePreset(Optional ByVal presetName As String = "last-used setting
controlValue = BuildParams(eControl.ResizeWidth, eControl.ResizeHeight, eControl.LockAspectRatio, eControl.UnitOfMeasurement, eControl.ResizeDPI, eControl.UnitOfResolution)

'Metadata management controls provide their own XML string
Case "pdMetadata"
Case "pdMetadataExport"
controlValue = eControl.GetMetadataSettings

End Select
Expand Down Expand Up @@ -1123,7 +1123,7 @@ Private Function LoadPreset(Optional ByVal presetName As String = "last-used set
eControl.ResizeHeight = cParam.GetDouble(2, 1080)

'Metadata management controls handle their own XML string parsing
Case "pdMetadata"
Case "pdMetadataExport"
eControl.SetMetadataSettings controlValue, True

End Select
Expand Down
11 changes: 1 addition & 10 deletions Controls/pdMetadataExport.ctl
Expand Up @@ -397,20 +397,11 @@ End Sub
'If the parent image has metadata, we provide a bold notification to the user. (We also retrieve the metadata presets,
' if any, from the parent image.)
Private Sub EvaluatePresenceOfMetadata()
If Not (m_ImageCopy Is Nothing) Then
If (Not (m_ImageCopy Is Nothing)) Then
If m_ImageCopy.imgMetadata.HasMetadata Then
lblTitle.Caption = g_Language.TranslateMessage("This image contains metadata.")
lblTitle.FontBold = True
hplReviewMetadata.Caption = g_Language.TranslateMessage("click to review this image's metadata")

Dim cParams As pdParamXML
Set cParams = New pdParamXML
cParams.SetParamString m_ImageCopy.imgStorage.GetEntry_String("MetadataSettings")

If cParams.GetBool("MetadataExportAllowed", True) Then chkMetadata.Value = vbChecked Else chkMetadata.Value = vbUnchecked
If cParams.GetBool("MetadataAnonymize", False) Then chkAnonymize.Value = vbChecked Else chkAnonymize.Value = vbUnchecked
If cParams.GetBool("MetadataEmbedThumbnail", False) Then chkThumbnail.Value = vbChecked Else chkThumbnail.Value = vbUnchecked

Else
lblTitle.Caption = g_Language.TranslateMessage("This image does not contain metadata.")
lblTitle.FontBold = False
Expand Down
65 changes: 9 additions & 56 deletions Forms/Tools_Options.frm
Expand Up @@ -597,16 +597,6 @@ Begin VB.Form FormPreferences
Width = 8295
_ExtentX = 0
_ExtentY = 0
Begin PhotoDemon.pdCheckBox chkSaveMetadata
Height = 375
Left = 240
TabIndex = 43
Top = 4560
Width = 7935
_ExtentX = 13996
_ExtentY = 661
Caption = "copy any relevant metadata to the new file"
End
Begin PhotoDemon.pdCheckBox chkConfirmUnsaved
Height = 330
Left = 240
Expand Down Expand Up @@ -635,17 +625,6 @@ Begin VB.Form FormPreferences
_ExtentX = 14076
_ExtentY = 582
End
Begin PhotoDemon.pdLabel lblSubheader
Height = 240
Index = 3
Left = 240
Top = 4140
Width = 7950
_ExtentX = 14023
_ExtentY = 503
Caption = "default metadata behavior on first save:"
ForeColor = 4210752
End
Begin PhotoDemon.pdLabel lblInterfaceTitle
Height = 285
Index = 1
Expand Down Expand Up @@ -716,22 +695,11 @@ Begin VB.Form FormPreferences
FontSize = 12
ForeColor = 5263440
End
Begin PhotoDemon.pdCheckBox chkAnonymizeMetadata
Height = 375
Left = 240
TabIndex = 44
Top = 4920
Width = 7935
_ExtentX = 13996
_ExtentY = 661
Caption = "erase tags that might be personal (GPS, camera details, etc)"
Value = 0
End
Begin PhotoDemon.pdCheckBox chkMetadataListPD
Height = 375
Left = 240
TabIndex = 49
Top = 5280
TabIndex = 47
Top = 4200
Width = 7935
_ExtentX = 13996
_ExtentY = 661
Expand Down Expand Up @@ -837,7 +805,7 @@ Begin VB.Form FormPreferences
Begin PhotoDemon.pdCheckBox chkMetadataBinary
Height = 330
Left = 240
TabIndex = 45
TabIndex = 43
Top = 2400
Width = 7920
_ExtentX = 13970
Expand All @@ -848,7 +816,7 @@ Begin VB.Form FormPreferences
Begin PhotoDemon.pdCheckBox chkMetadataJPEG
Height = 330
Left = 240
TabIndex = 46
TabIndex = 44
Top = 1680
Width = 7920
_ExtentX = 13970
Expand All @@ -858,7 +826,7 @@ Begin VB.Form FormPreferences
Begin PhotoDemon.pdCheckBox chkMetadataUnknown
Height = 330
Left = 240
TabIndex = 47
TabIndex = 45
Top = 2040
Width = 7920
_ExtentX = 13970
Expand All @@ -869,7 +837,7 @@ Begin VB.Form FormPreferences
Begin PhotoDemon.pdCheckBox chkMetadataDuplicates
Height = 330
Left = 240
TabIndex = 48
TabIndex = 46
Top = 1320
Width = 7920
_ExtentX = 13970
Expand Down Expand Up @@ -1199,15 +1167,6 @@ Private Sub cboMonitors_Click()

End Sub

Private Sub chkAnonymizeMetadata_Click()
If CBool(chkAnonymizeMetadata.Value) Then
chkMetadataListPD.Value = vbUnchecked
chkMetadataListPD.Enabled = False
Else
chkMetadataListPD.Enabled = True
End If
End Sub

Private Sub cmdBarMini_OKClick()

'Start by auto-validating any controls that accept user input
Expand Down Expand Up @@ -1347,11 +1306,8 @@ Private Sub cmdBarMini_OKClick()

'END prompt on unsaved images

'START metadata-related options
g_UserPreferences.SetPref_Boolean "Saving", "PreserveMetadata", CBool(chkSaveMetadata.Value)
g_UserPreferences.SetPref_Boolean "Saving", "AnonymizeMetadata", CBool(chkAnonymizeMetadata.Value)
'START/END metadata-related options
g_UserPreferences.SetPref_Boolean "Saving", "MetadataListPD", CBool(chkMetadataListPD.Value)
'END metadata-related options

'START/END Save behavior (overwrite or copy)
g_UserPreferences.SetPref_Long "Saving", "Overwrite Or Copy", cboSaveBehavior.ListIndex
Expand Down Expand Up @@ -1673,12 +1629,9 @@ Private Sub LoadAllPreferences()
cboSaveBehavior.AssignTooltip "In most photo editors, the ""Save"" command saves the image over its original version, erasing that copy forever. PhotoDemon provides a ""safer"" option, where each save results in a new copy of the file."
'END overwrite vs copy when saving

'START metadata export
If g_UserPreferences.GetPref_Boolean("Saving", "PreserveMetadata", True) Then chkSaveMetadata.Value = vbChecked Else chkSaveMetadata.Value = vbUnchecked
If g_UserPreferences.GetPref_Boolean("Saving", "AnonymizeMetadata", False) Then chkAnonymizeMetadata.Value = vbChecked Else chkAnonymizeMetadata.Value = vbUnchecked
'START/END metadata export
If g_UserPreferences.GetPref_Boolean("Saving", "MetadataListPD", True) Then chkMetadataListPD.Value = vbChecked Else chkMetadataListPD.Value = vbUnchecked
'END metadata export


'END Saving preferences

'***************************************************************************
Expand Down
9 changes: 0 additions & 9 deletions Modules/VBP_MDIWindow.bas
Expand Up @@ -58,17 +58,8 @@ End Function
' Note that this function *does not touch* the main pdImages object, and as such, the created image will not yet have
' an imageID value. That values is assigned when the object is added to the main pdImages() collection.
Public Sub GetDefaultPDImageObject(ByRef dstImage As pdImage)

If (dstImage Is Nothing) Then Set dstImage = New pdImage
dstImage.currentZoomValue = g_Zoom.GetZoom100Index

'Also, set default metadata handling values (which vary according to user preference)
Dim cParams As pdParamXML
Set cParams = New pdParamXML
cParams.AddParam "MetadataExportAllowed", g_UserPreferences.GetPref_Boolean("Saving", "PreserveMetadata", True)
cParams.AddParam "MetadataAnonymize", g_UserPreferences.GetPref_Boolean("Saving", "AnonymizeMetadata", False)
dstImage.imgStorage.AddEntry "MetadataSettings", cParams.GetParamString

End Sub

'When loading an image file, there's a chance we won't be able to load the image correctly. Because of that, we start
Expand Down
2 changes: 1 addition & 1 deletion PhotoDemon.vbp
Expand Up @@ -360,7 +360,7 @@ Description="PhotoDemon Photo Editor"
CompatibleMode="0"
MajorVer=6
MinorVer=7
RevisionVer=1891
RevisionVer=1893
AutoIncrementVer=1
ServerSupportFiles=0
VersionComments="Copyright 2000-2016 Tanner Helland - photodemon.org"
Expand Down

0 comments on commit a39cf03

Please sign in to comment.