Commit c420a2c4 authored by Sven Langkamp's avatar Sven Langkamp
Browse files

move more layer actions to new action system

BUG:303311
parent 2ef1b9ea
......@@ -55,6 +55,8 @@
#include <kis_paint_device.h>
#include <widgets/kis_cmb_idlist.h>
#include <widgets/squeezedcombobox.h>
#include <kis_action.h>
#include <kis_action_manager.h>
#include <kis_group_layer.h>
#include "dlg_colorspaceconversion.h"
......@@ -74,9 +76,12 @@ ColorSpaceConversion::ColorSpaceConversion(QObject *parent, const QVariantList &
KAction *action = new KAction(i18n("&Convert Image Type..."), this);
actionCollection()->addAction("imagecolorspaceconversion", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotImageColorSpaceConversion()));
action = new KAction(i18n("&Convert Layer Type..."), this);
actionCollection()->addAction("layercolorspaceconversion", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotLayerColorSpaceConversion()));
KisAction* convertLayer = new KisAction(i18n("&Convert Layer Type..."), this);
convertLayer->setActivationFlags(KisAction::ACTIVE_LAYER);
convertLayer->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("layercolorspaceconversion", convertLayer, actionCollection());
connect(convertLayer, SIGNAL(triggered()), this, SLOT(slotLayerColorSpaceConversion()));
}
}
......
......@@ -20,14 +20,6 @@
#include "histogram.h"
#include <math.h>
#include <stdlib.h>
#include <QSlider>
#include <QPoint>
#include <klocale.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
......@@ -49,6 +41,8 @@
#include "KoColorSpace.h"
#include "kis_histogram.h"
#include "kis_node_manager.h"
#include <kis_action.h>
#include <kis_action_manager.h>
K_PLUGIN_FACTORY(HistogramFactory, registerPlugin<Histogram>();)
K_EXPORT_PLUGIN(HistogramFactory("krita"))
......@@ -60,20 +54,12 @@ Histogram::Histogram(QObject *parent, const QVariantList &)
setXMLFile(KStandardDirs::locate("data", "kritaplugins/histogram.rc"),
true);
m_action = new KAction(i18n("&Histogram..."), this);
actionCollection()->addAction("histogram", m_action);
connect(m_action, SIGNAL(triggered()), this, SLOT(slotActivated()));
m_view = (KisView2*) parent;
m_image = m_view->image();
if (m_image) {
connect(m_image, SIGNAL(sigLayersChangedAsync()), SLOT(slotLayersChanged()));
connect(m_image, SIGNAL(sigNodeAddedAsync(KisNodeSP)), SLOT(slotLayersChanged()));
connect(m_image, SIGNAL(sigRemoveNodeAsync(KisNodeSP)), SLOT(slotLayersChanged()));
connect(m_view->nodeManager(), SIGNAL(sigLayerActivated(KisLayerSP)), SLOT(slotLayersChanged()));
}
KisAction* action = new KisAction(i18n("&Histogram..."), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
m_view->actionManager()->addAction("histogram", action, actionCollection());
connect(action, SIGNAL(triggered()), this, SLOT(slotActivated()));
}
}
......@@ -81,11 +67,6 @@ Histogram::~Histogram()
{
}
void Histogram::slotLayersChanged()
{
m_action->setEnabled(m_image && m_view->nodeManager()->activeLayer());
}
void Histogram::slotActivated()
{
DlgHistogram * dlgHistogram = new DlgHistogram(m_view, "Histogram");
......
......@@ -28,7 +28,7 @@
class KisView2;
class KisImage;
class KisPainter;
class Histogram : public KParts::Plugin
{
Q_OBJECT
......@@ -38,14 +38,9 @@ public:
private slots:
void slotActivated();
void slotLayersChanged();
private:
KisImageWSP m_image;
KisView2 * m_view;
KisPainter * m_painter;
QAction * m_action;
};
#endif // HISTOGRAM_H
......@@ -73,6 +73,8 @@ ImageSize::ImageSize(QObject *parent, const QVariantList &)
if (parent->inherits("KisView2")) {
setXMLFile(KStandardDirs::locate("data", "kritaplugins/imagesize.rc"), true);
m_view = (KisView2*) parent;
KAction *action = new KAction(i18n("Scale To New Size..."), this);
actionCollection()->addAction("imagesize", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotImageSize()));
......@@ -81,20 +83,18 @@ ImageSize::ImageSize(QObject *parent, const QVariantList &)
actionCollection()->addAction("canvassize", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotCanvasSize()));
m_scaleLayerAction = new KAction(i18n("Scale &Layer..."), this);
actionCollection()->addAction("layersize", m_scaleLayerAction);
m_scaleLayerAction = new KisAction(i18n("Scale &Layer..."), this);
m_scaleLayerAction->setActivationFlags(KisAction::ACTIVE_LAYER);
m_scaleLayerAction->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("layersize", m_scaleLayerAction, actionCollection());
connect(m_scaleLayerAction, SIGNAL(triggered()), this, SLOT(slotLayerSize()));
m_view = (KisView2*) parent;
m_scaleSelectionAction = new KisAction(i18n("&Scale..."), this);
m_scaleSelectionAction->setActivationFlags(KisAction::PIXELS_SELECTED);
m_scaleSelectionAction->setActivationConditions(KisAction::SELECTION_EDITABLE);
m_view->actionManager()->addAction("selectionscale", m_scaleSelectionAction, actionCollection());
Q_CHECK_PTR(m_scaleSelectionAction);
connect(m_scaleSelectionAction, SIGNAL(triggered()), this, SLOT(slotSelectionScale()));
connect(m_view->resourceProvider(), SIGNAL(sigNodeChanged(const KisNodeSP)), SLOT(slotNodeChanged(KisNodeSP)));
}
}
......@@ -226,11 +226,4 @@ void ImageSize::slotSelectionScale()
delete dlgSize;
}
void ImageSize::slotNodeChanged(const KisNodeSP node)
{
Q_UNUSED(node);
m_scaleLayerAction->setEnabled(m_view->activeLayer());
}
#include "imagesize.moc"
......@@ -43,13 +43,11 @@ private slots:
void slotCanvasSize();
void slotLayerSize();
void slotSelectionScale();
void slotNodeChanged(const KisNodeSP);
private:
KisView2 * m_view;
KisPainter * m_painter;
KAction* m_scaleLayerAction;
KisAction* m_scaleLayerAction;
KisAction* m_scaleSelectionAction;
};
......
......@@ -37,6 +37,8 @@
#include "kis_node_manager.h"
#include "kis_types.h"
#include "kis_view2.h"
#include "kis_action.h"
#include "kis_action_manager.h"
#include "kis_image.h"
#include <kis_meta_data_store.h>
......@@ -58,8 +60,10 @@ metadataeditorPlugin::metadataeditorPlugin(QObject *parent, const QVariantList &
setXMLFile(KStandardDirs::locate("data", "kritaplugins/metadataeditor.rc"), true);
KAction *action = new KAction(i18n("&Edit metadata..."), this);
actionCollection()->addAction("EditLayerMetaData", action);
KisAction *action = new KisAction(i18n("&Edit metadata..."), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("EditLayerMetaData", action, actionCollection());
connect(action, SIGNAL(triggered()), this, SLOT(slotEditLayerMetaData()));
QStringList runtimeVersion = QString(qVersion()).split('.');
......
......@@ -20,14 +20,6 @@
#include "rotateimage.h"
#include <math.h>
#include <stdlib.h>
#include <QSlider>
#include <QPoint>
#include <klocale.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
......@@ -47,6 +39,8 @@
#include <kis_node_manager.h>
#include <kis_canvas_resource_provider.h>
#include <kis_group_layer.h>
#include <kis_action.h>
#include <kis_action_manager.h>
#include "dlg_rotateimage.h"
......@@ -87,20 +81,28 @@ RotateImage::RotateImage(QObject *parent, const QVariantList &)
connect(action, SIGNAL(triggered()), this, SLOT(slotMirrorImageVertical()));
m_rotateLayerAction = new KAction(i18n("&Rotate Layer..."), this);
actionCollection()->addAction("rotatelayer", m_rotateLayerAction);
m_rotateLayerAction = new KisAction(i18n("&Rotate Layer..."), this);
m_rotateLayerAction->setActivationFlags(KisAction::ACTIVE_LAYER);
m_rotateLayerAction->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("rotatelayer", m_rotateLayerAction, actionCollection());
connect(m_rotateLayerAction, SIGNAL(triggered()), this, SLOT(slotRotateLayer()));
m_rotate90LayerAction = new KAction(i18nc("rotate the layer 180 degrees", "Rotate Layer 180°"), this);
actionCollection()->addAction("rotateLayer180", m_rotate90LayerAction);
m_rotate90LayerAction = new KisAction(i18nc("rotate the layer 180 degrees", "Rotate Layer 180°"), this);
m_rotate90LayerAction->setActivationFlags(KisAction::ACTIVE_LAYER);
m_rotate90LayerAction->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("rotateLayer180", m_rotate90LayerAction, actionCollection());
connect(m_rotate90LayerAction, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotate180()));
m_rotate180LayerAction = new KAction(koIcon("object-rotate-right"), i18nc("rotate the layer 90 degrees to the right", "Rotate Layer 90° to the Right"), this);
actionCollection()->addAction("rotateLayerCW90", m_rotate180LayerAction);
m_rotate180LayerAction = new KisAction(koIcon("object-rotate-right"), i18nc("rotate the layer 90 degrees to the right", "Rotate Layer 90° to the Right"), this);
m_rotate180LayerAction->setActivationFlags(KisAction::ACTIVE_LAYER);
m_rotate180LayerAction->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("rotateLayerCW90", m_rotate180LayerAction, actionCollection());
connect(m_rotate180LayerAction, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotateRight90()));
m_rotate270LayerAction = new KAction(koIcon("object-rotate-left"), i18nc("rotate the layer 90 degrees to the left", "Rotate Layer 90° to the Left"), this);
actionCollection()->addAction("rotateLayerCCW90", m_rotate270LayerAction);
m_rotate270LayerAction = new KisAction(koIcon("object-rotate-left"), i18nc("rotate the layer 90 degrees to the left", "Rotate Layer 90° to the Left"), this);
m_rotate270LayerAction->setActivationFlags(KisAction::ACTIVE_LAYER);
m_rotate270LayerAction->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("rotateLayerCCW90", m_rotate270LayerAction, actionCollection());
connect(m_rotate270LayerAction, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotateLeft90()));
connect(m_view->resourceProvider(), SIGNAL(sigNodeChanged(const KisNodeSP)), SLOT(slotNodeChanged(KisNodeSP)));
......@@ -179,13 +181,4 @@ void RotateImage::slotRotateLayer()
delete dlgRotateImage;
}
void RotateImage::slotNodeChanged(const KisNodeSP node)
{
Q_UNUSED(node);
m_rotateLayerAction->setEnabled(m_view->activeLayer());
m_rotate90LayerAction->setEnabled(m_view->activeLayer());
m_rotate180LayerAction->setEnabled(m_view->activeLayer());
m_rotate270LayerAction->setEnabled(m_view->activeLayer());
}
#include "rotateimage.moc"
......@@ -26,7 +26,8 @@
#include "kis_types.h"
class KisView2;
class KisPainter;
class KisAction;
class RotateImage : public KParts::Plugin
{
Q_OBJECT
......@@ -43,16 +44,14 @@ private slots:
void slotMirrorImageVertical();
void slotMirrorImageHorizontal();
void slotRotateLayer();
void slotNodeChanged(const KisNodeSP);
private:
KisView2 * m_view;
KisPainter * m_painter;
KAction* m_rotateLayerAction;
KAction* m_rotate90LayerAction;
KAction* m_rotate180LayerAction;
KAction* m_rotate270LayerAction;
KisAction* m_rotateLayerAction;
KisAction* m_rotate90LayerAction;
KisAction* m_rotate180LayerAction;
KisAction* m_rotate270LayerAction;
};
......
......@@ -20,14 +20,6 @@
#include "shearimage.h"
#include <math.h>
#include <stdlib.h>
#include <QSlider>
#include <QPoint>
#include <klocale.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
......@@ -43,7 +35,8 @@
#include <kis_view2.h>
#include <kis_node_manager.h>
#include <kis_image_manager.h>
#include <kis_action.h>
#include <kis_action_manager.h>
#include "dlg_shearimage.h"
......@@ -58,15 +51,17 @@ ShearImage::ShearImage(QObject *parent, const QVariantList &)
setXMLFile(KStandardDirs::locate("data", "kritaplugins/shearimage.rc"),
true);
m_view = (KisView2*) parent;
KAction *action = new KAction(i18n("&Shear Image..."), this);
actionCollection()->addAction("shearimage", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotShearImage()));
action = new KAction(i18n("&Shear Layer..."), this);
actionCollection()->addAction("shearlayer", action);
KisAction *shearLayer = new KisAction(i18n("&Shear Layer..."), this);
shearLayer->setActivationFlags(KisAction::ACTIVE_LAYER);
shearLayer->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("shearlayer", shearLayer, actionCollection());
connect(action, SIGNAL(triggered()), this, SLOT(slotShearLayer()));
m_view = (KisView2*) parent;
}
}
......
......@@ -292,8 +292,10 @@ void KisLayerManager::setup(KActionCollection * actionCollection)
actionCollection->addAction("flatten_layer", m_flattenLayer);
connect(m_flattenLayer, SIGNAL(triggered()), this, SLOT(flattenLayer()));
m_rasterizeLayer = new KAction(i18n("Rasterize Layer"), this);
actionCollection->addAction("rasterize_layer", m_rasterizeLayer);
m_rasterizeLayer = new KisAction(i18n("Rasterize Layer"), this);
m_rasterizeLayer->setActivationFlags(KisAction::ACTIVE_SHAPE_LAYER);
m_rasterizeLayer->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
m_view->actionManager()->addAction("rasterize_layer", m_rasterizeLayer, actionCollection);
connect(m_rasterizeLayer, SIGNAL(triggered()), this, SLOT(rasterizeLayer()));
m_layerSaveAs = new KisAction(koIcon("document-save"), i18n("Save Layer as Image..."), this);
......@@ -340,7 +342,6 @@ void KisLayerManager::updateGUI()
m_imageFlatten->setEnabled(nlayers > 1);
m_imageMergeLayer->setEnabled(nlayers > 1 && layer && layer->prevSibling());
m_flattenLayer->setEnabled(nlayers > 1 && layer && layer->firstChild());
m_rasterizeLayer->setEnabled(enable && layer->inherits("KisShapeLayer"));
if (m_view->statusBar())
m_view->statusBar()->setProfile(image);
......
......@@ -139,7 +139,7 @@ private:
bool m_actLayerVis;
KisAction *m_imageResizeToLayer;
KAction *m_flattenLayer;
KAction *m_rasterizeLayer;
KisAction *m_rasterizeLayer;
KAction *m_addPaintLayer;
KisLayerSP m_activeLayer;
KisNodeCommandsAdapter* m_commandsAdapter;
......
Supports Markdown
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