diff --git a/libs/ui/kis_paintop_box.cc b/libs/ui/kis_paintop_box.cc --- a/libs/ui/kis_paintop_box.cc +++ b/libs/ui/kis_paintop_box.cc @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -943,7 +944,35 @@ void KisPaintopBox::slotSetupDefaultPreset() { - KisPaintOpPresetSP preset = defaultPreset(m_resourceProvider->currentPreset()->paintOp()); + // This function is mostly used for when new brush engines are added. There are no presets that exist, + // so this is a convenience to help with creating the first preset as a base using the brush editor + // To accomplish this, we will need to get the new brush engine, then force the existing preset to act + // like it is part of the new brush engine by setting its paintOp ID. + + // get the full name of the selected brush engine filter to get the ID + // the ID is passed around a lot, but the full name isn't + QString brushEngineFullName = ""; + for (int i = 0; i < m_presetsPopup->brushEngineList().length(); i++) { + KisPaintOpInfo brushEngine = m_presetsPopup->brushEngineList().at(i); + + if (brushEngine.id == m_presetsPopup->currentFilterPaintOpId() ) { + brushEngineFullName = brushEngine.name; + } + } + const KoID currentBrushEngineFilterId(m_presetsPopup->currentFilterPaintOpId(), brushEngineFullName); + + // "All" option might be selected for the brush engine filter, which doesn't have "default" settings + if (currentBrushEngineFilterId.id() == "") { + return; + } + + // the part where we force the existing preset to act like it is part of a different brush engine + slotSetPaintop(m_presetsPopup->currentFilterPaintOpId()); + + m_optionWidget = m_paintopOptionWidgets[currentBrushEngineFilterId]; // the settings area on the right + m_presetsPopup->setPaintOpSettingsWidget(m_optionWidget); + + KisPaintOpPresetSP preset = defaultPreset(currentBrushEngineFilterId); // forcing the preset to the fake brush engine preset->setOptionsWidget(m_optionWidget); m_resourceProvider->setPaintOpPreset(preset); } diff --git a/libs/ui/widgets/kis_paintop_presets_popup.h b/libs/ui/widgets/kis_paintop_presets_popup.h --- a/libs/ui/widgets/kis_paintop_presets_popup.h +++ b/libs/ui/widgets/kis_paintop_presets_popup.h @@ -63,6 +63,11 @@ /// returns the internal ID for the paint op (brush engine) QString currentPaintOpId(); + + QString currentFilterPaintOpId(); + + QList brushEngineList(); + ///fill the cutoutOverlay rect with the cotent of an image, used to get the image back when selecting a preset ///@param image image that will be used, should be image of an existing preset resource diff --git a/libs/ui/widgets/kis_paintop_presets_popup.cpp b/libs/ui/widgets/kis_paintop_presets_popup.cpp --- a/libs/ui/widgets/kis_paintop_presets_popup.cpp +++ b/libs/ui/widgets/kis_paintop_presets_popup.cpp @@ -37,6 +37,8 @@ #include #include +#include +#include #include #include @@ -489,6 +491,9 @@ } +QList KisPaintOpPresetsPopup::brushEngineList() { + return sortedBrushEnginesList; +} void KisPaintOpPresetsPopup::setCurrentPaintOpId(const QString& paintOpId) { @@ -550,17 +555,32 @@ m_d->uiWdgPaintOpPresetSettings.presetsContainer->setVisible(visible); } -void KisPaintOpPresetsPopup::slotUpdatePaintOpFilter() { +QString KisPaintOpPresetsPopup::currentFilterPaintOpId() +{ QVariant userData = m_d->uiWdgPaintOpPresetSettings.brushEgineComboBox->currentData(); // grab paintOpID from data - QString filterPaintOpId = userData.toString(); + QString filterPaintOpId = userData.toString(); if (filterPaintOpId == "all_options") { filterPaintOpId = ""; } - m_d->uiWdgPaintOpPresetSettings.presetWidget->setPresetFilter(filterPaintOpId); + + return filterPaintOpId; } +void KisPaintOpPresetsPopup::slotUpdatePaintOpFilter() { + + + m_d->uiWdgPaintOpPresetSettings.presetWidget->setPresetFilter(currentFilterPaintOpId()); + + // if the brush engine doesn't have any presets, load the default engine settings so it is easier to make presets + if (m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser->itemChooser()->itemView()->rowAt(0) == -1){ + emit defaultPresetClicked(); + } + +} + + void KisPaintOpPresetsPopup::updateViewSettings() { m_d->uiWdgPaintOpPresetSettings.presetWidget->smallPresetChooser->updateViewSettings();