diff --git a/src/app/app_brushes.cpp b/src/app/app_brushes.cpp index a3a2addfb..0cdba53bf 100644 --- a/src/app/app_brushes.cpp +++ b/src/app/app_brushes.cpp @@ -77,6 +77,15 @@ BrushRef AppBrushes::getCustomBrush(slot_id slot) const return BrushRef(); } +void AppBrushes::setCustomBrush(slot_id slot, const doc::BrushRef& brush) +{ + --slot; + if (slot >= 0 && slot < (int)m_slots.size()) { + m_slots[slot].setBrush(brush); + ItemsChange(); + } +} + Brushes AppBrushes::getCustomBrushes() { Brushes brushes; diff --git a/src/app/app_brushes.h b/src/app/app_brushes.h index 12662ed20..aa011035d 100644 --- a/src/app/app_brushes.h +++ b/src/app/app_brushes.h @@ -32,6 +32,7 @@ namespace app { bool hasCustomBrush(slot_id slot) const; const doc::Brushes& getStandardBrushes() { return m_standard; } doc::BrushRef getCustomBrush(slot_id slot) const; + void setCustomBrush(slot_id slot, const doc::BrushRef& brush); doc::Brushes getCustomBrushes(); void lockCustomBrush(slot_id slot); diff --git a/src/app/ui/brush_popup.cpp b/src/app/ui/brush_popup.cpp index 42d7e3c64..fa2c8f5c0 100644 --- a/src/app/ui/brush_popup.cpp +++ b/src/app/ui/brush_popup.cpp @@ -121,12 +121,16 @@ private: void onClick() override { Menu menu; + AppMenuItem save("Save Brush Here"); AppMenuItem lockItem(m_delegate->onIsBrushSlotLocked(m_slot) ? "Unlock Brush": "Lock Brush"); AppMenuItem deleteItem("Delete"); AppMenuItem deleteAllItem("Delete All"); + save.Click.connect(&BrushOptionsItem::onSaveBrush, this); lockItem.Click.connect(&BrushOptionsItem::onLockBrush, this); deleteItem.Click.connect(&BrushOptionsItem::onDeleteBrush, this); deleteAllItem.Click.connect(&BrushOptionsItem::onDeleteAllBrushes, this); + menu.addChild(&save); + menu.addChild(new MenuSeparator); menu.addChild(&lockItem); menu.addChild(&deleteItem); menu.addChild(new MenuSeparator); @@ -142,6 +146,13 @@ private: private: + void onSaveBrush() { + AppBrushes& brushes = App::instance()->brushes(); + brushes.setCustomBrush( + m_slot, ContextBar::createBrushFromPreferences()); + brushes.lockCustomBrush(m_slot); + } + void onLockBrush() { if (m_delegate->onIsBrushSlotLocked(m_slot)) m_delegate->onUnlockBrushSlot(m_slot);