Commit a4f84ca9 authored by Amy spark's avatar Amy spark 👉
Browse files

Fix naming of MyPaint brushes on versioned serialization

Before this commit, versioned .myb files would apply the .kpp suffix,
only to be overridden by the save preset dialog.

CCBUG: 439817
BUG: 445281
BUG: 445282
(cherry picked from commit 14e8cd88)
parent a5930478
......@@ -168,9 +168,9 @@ void KisPresetSaveWidget::savePreset()
presetFileName = presetFileName.replace(' ', '_').replace('.', '_');
QString extension = curPreset->defaultFileExtension();
// Make sure of the extension
if (!presetFileName.endsWith(".kpp")) {
presetFileName += ".kpp";
// Ensure the filename has the corresponding extension
if (!presetFileName.endsWith(extension)) {
presetFileName.append(extension);
}
bool success = true;
......@@ -178,9 +178,6 @@ void KisPresetSaveWidget::savePreset()
if (m_useNewBrushDialog) {
KisPaintOpPresetSP newPreset = curPreset->clone().dynamicCast<KisPaintOpPreset>();
newPreset->setResourceId(-1); // so it won't confuse anything into overwriting
if (!presetFileName.endsWith(extension)) {
presetFileName.append(extension);
}
newPreset->setFilename(presetFileName);
newPreset->setName(m_useNewBrushDialog ? newBrushNameTexField->text() : curPreset->name());
newPreset->setImage(brushPresetThumbnailWidget->cutoutOverlay());
......@@ -197,6 +194,8 @@ void KisPresetSaveWidget::savePreset()
else { // saving a preset that is replacing an existing one
curPreset->setName(m_useNewBrushDialog ? newBrushNameTexField->text() : curPreset->name());
curPreset->setImage(brushPresetThumbnailWidget->cutoutOverlay());
// Ensure it has the updated name (for mypaint serialization) -- BUG 445282
curPreset->setFilename(presetFileName);
if (!KisResourceUserOperations::updateResourceWithUserInput(this, curPreset)) {
success = false;
......
......@@ -36,8 +36,9 @@ public:
};
KisMyPaintPaintOpPreset::KisMyPaintPaintOpPreset(const QString &fileName)
: KisPaintOpPreset (fileName), d(new Private) {
: KisPaintOpPreset(fileName)
, d(new Private)
{
d->brush = mypaint_brush_new();
mypaint_brush_from_defaults(d->brush);
}
......@@ -135,8 +136,9 @@ bool KisMyPaintPaintOpPreset::loadFromDevice(QIODevice *dev, KisResourcesInterfa
if (KisPaintOpPreset::loadFromDevice(dev, resourcesInterface)) {
apply(settings());
// correct filename
if (filename().endsWith(".myb")) {
setFilename(name().split(" ").join("_") + KisPaintOpPreset::defaultFileExtension());
const QString f = filename();
if (f.endsWith(".myb")) {
setFilename(QFileInfo(f).completeBaseName().append(KisPaintOpPreset::defaultFileExtension()));
}
return true;
} else {
......
......@@ -38,11 +38,6 @@ public:
return QPair<QString, QString>(ResourceType::PaintOpPresets, ResourceSubType::MyPaintPaintOpPresets);
}
QString defaultFileExtension() const override
{
return ".myb";
}
void updateThumbnail() override;
QString thumbnailPath() const override;
......@@ -54,10 +49,8 @@ public:
float isEraser();
private:
class Private;
Private* const d;
bool firstLoad = true;
};
#endif // KIS_MYPAINT_BRUSH_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment