Automatic filename renames for imported and added resources
Before this commit, multiple operations done by the user would end up with error, often silent error. This commit ensures that the resource file will be imported or the resource will be added even if the original filename is already taken.
Note: it would be best to first ask the user. However we're in the string freeze. Better to have a working default than not.
Test Plan
Test 1.
- Rename
pattern_A.png
to bepattern.png
. Import as Brush Tip. - Rename
pattern_B.png
to bepattern.png
. Import as Brush Tip. - Both should be visible in Resource Manager. (Before this MR, it would fail).
- Rename
pattern_A.png
to bepattern.png
. Import as Brush Tip. - The last one won't show up, because it has the same MD5 as the original pattern.png. (Before this MR, it would fail).
Test 2.
- Rename
pattern_A.png
to bepattern.png
. Import as Brush Tip. - Rename
pattern_B.png
to bepattern.png
. Import as Brush Tip. - Both should be visible in Resource Manager. (Before this MR, it would fail).
- Rename
pattern_B.png
to bepattern.png
. Import as Brush Tip. - The last one will show up, because it doesn't have the same MD5 as the original
pattern.png
. This is an unfortunate event and it would be best to get it fixed. (Doesn't need to be in this MR though, I guess). (Before this MR, it would fail).
Test 3.
- Open Brush Editor, take some Pixel Brush as template.
- Use Save New Brush Preset, use name "Test A".
- Use Save New Brush Preset again, use the same name.
- Before this MR: it would fail. After this MR: it will succeed.
Test 3.
- Open Brush Editor, take some Pixel Brush as template.
- Use Save New Brush Preset, use name "Test B".
- Delete the "Test B" brush preset using any method.
- Use Save New Brush Preset again, use the same name.
- Before this MR: it would fail. After this MR: it will succeed.
https://bugs.kde.org/show_bug.cgi?id=439128 Also relevant: https://krita-artists.org/t/resource-bugs-in-krita-5/23235/25?u=tiar
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.