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

Implement Reference Tool selection detection

While commit 6e8224c5 implemented the
correct logic, it is only valid if the current tool is the Reference
Image tool.

There's a method for just this purpose, KoToolBase::hasSelection(), but
the existing flow stems from SelectionHandler::hasSelection, which
operates only with shapes. So this commit implements the
corresponding override and changes the check to query the current tool

BUG: 454515

(cherry picked from commit df76bd6c)
parent ff115ccb
Pipeline #196226 passed with stage
in 50 minutes and 38 seconds
......@@ -269,17 +269,16 @@ void KisCutCopyActionFactory::run(bool willCut, bool makeSharpClip, KisViewManag
// Reference layers is a fake node, so it isn't added to the layer stack, this results in KisSelectedShapesProxy not
// being aware of the active shapeManager and its selected shapes.
const auto hasReferenceImageSelected = [&]() {
KisReferenceImagesLayerSP refLayer = view->document()->referenceImagesLayer();
return refLayer && refLayer->shapeManager()->selection()->count();
const auto currentToolHasSelection =
const bool haveShapesSelected = view->selectionManager()->haveShapesSelected() || hasReferenceImageSelected();
const bool haveShapesSelected =
KisNodeSP node = view->activeNode();
KisSelectionSP selection = view->selection();
if (!makeSharpClip && haveShapesSelected) {
if (!makeSharpClip && (haveShapesSelected || currentToolHasSelection)) {
// XXX: "Add saving of XML data for Cut/Copy of shapes"
KisImageBarrierLocker locker(image);
......@@ -81,6 +81,12 @@ void ToolReferenceImages::setReferenceImageLayer(KisSharedPtr<KisReferenceImages
connect(layer->shapeManager(), SIGNAL(selectionContentChanged()), this, SLOT(repaintDecorations()));
bool ToolReferenceImages::hasSelection()
const KoShapeManager *manager = shapeManager();
return manager && manager->selection()->count() != 0;
void ToolReferenceImages::addReferenceImage()
auto kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
......@@ -37,6 +37,8 @@ public:
void mouseDoubleClickEvent(KoPointerEvent */*event*/) override {}
bool hasSelection() override;
void deleteSelection() override;
QMenu* popupActionsMenu() override;
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