Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 6708ac8e authored by Boudewijn Rempt's avatar Boudewijn Rempt

Merge layer: only ask for the metadata merge strategy if there is metadata

parent 63c46d12
......@@ -59,6 +59,8 @@
#include <kis_transform_visitor.h>
#include <kis_undo_adapter.h>
#include <kis_painter.h>
#include <metadata/kis_meta_data_store.h>
#include <metadata/kis_meta_data_merge_strategy_registry.h>
#include "kis_config.h"
#include "kis_cursor.h"
......@@ -83,6 +85,7 @@
#include "kis_node_commands_adapter.h"
#include "kis_node_manager.h"
KisLayerManager::KisLayerManager(KisView2 * view, KisDoc2 * doc)
: m_view(view)
, m_doc(doc)
......@@ -146,7 +149,7 @@ void KisLayerManager::setup(KActionCollection * actionCollection)
m_rasterizeLayer = new KAction(i18n("Rasterize Layer"), this);
actionCollection->addAction("rasterize_layer", m_rasterizeLayer);
connect(m_rasterizeLayer, SIGNAL(triggered()), this, SLOT(rasterizeLayer()));
m_layerSaveAs = new KAction(KIcon("document-save"), i18n("Save Layer as Image..."), this);
actionCollection->addAction("save_layer_as_image", m_layerSaveAs);
connect(m_layerSaveAs, SIGNAL(triggered()), this, SLOT(saveLayerAsImage()));
......@@ -572,7 +575,7 @@ void KisLayerManager::layerBack()
void KisLayerManager::mirrorLayerX()
{
KisLayerSP layer = activeLayer();
if (layer->inherits("KisShapeLayer")) {
m_view->image()->undoAdapter()->beginMacro(i18n("Mirror Layer X"));
......@@ -599,7 +602,7 @@ void KisLayerManager::mirrorLayerX()
void KisLayerManager::mirrorLayerY()
{
KisLayerSP layer = activeLayer();
if (layer->inherits("KisShapeLayer")) {
m_view->image()->undoAdapter()->beginMacro(i18n("Mirror Layer Y"));
......@@ -721,10 +724,18 @@ void KisLayerManager::mergeLayer()
KisLayerSP layer = activeLayer();
if (!layer) return;
const KisMetaData::MergeStrategy* strategy = KisMetaDataMergeStrategyChooserWidget::showDialog(m_view);
if (!strategy) return;
if (layer->metaData()->isEmpty() && layer->prevSibling() && dynamic_cast<KisLayer*>(layer->prevSibling().data())->metaData()->isEmpty()) {
const KisMetaData::MergeStrategy* strategy = KisMetaData::MergeStrategyRegistry::instance()->get("Drop");
image->mergeDown(layer, strategy);
}
else {
const KisMetaData::MergeStrategy* strategy = KisMetaDataMergeStrategyChooserWidget::showDialog(m_view);
if (!strategy) return;
image->mergeDown(layer, strategy);
}
KisLayerSP newLayer = image->mergeDown(layer, strategy);
m_view->updateGUI();
}
......@@ -750,15 +761,15 @@ void KisLayerManager::rasterizeLayer()
KisLayerSP layer = activeLayer();
if (!layer) return;
KisPaintLayerSP paintLayer = new KisPaintLayer(image, layer->name(), layer->opacity());
KisPainter gc(paintLayer->paintDevice());
QRect rc = layer->projection()->exactBounds();
gc.bitBlt(rc.topLeft(), layer->projection(), rc);
m_commandsAdapter->beginMacro(i18n("Rasterize Layer"));
m_commandsAdapter->addNode(paintLayer.data(), layer->parent().data(), layer.data());
int childCount = layer->childCount();
for (int i = 0; i < childCount; i++) {
m_commandsAdapter->moveNode(layer->firstChild(), paintLayer, paintLayer->lastChild());
......
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