Commit ba809512 authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Remove extraneous items in reference images tool context menu

BUG: 393584
parent 40d8fa30
......@@ -1567,24 +1567,6 @@ void DefaultTool::updateActions()
action("object_align_vertical_center")->setEnabled(alignmentEnabled);
action("object_align_vertical_bottom")->setEnabled(alignmentEnabled);
action("object_group")->setEnabled(multipleSelected);
action("object_unite")->setEnabled(multipleSelected);
action("object_intersect")->setEnabled(multipleSelected);
action("object_subtract")->setEnabled(multipleSelected);
bool hasShapesWithMultipleSegments = false;
Q_FOREACH (KoShape *shape, editableShapes) {
KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
if (pathShape && pathShape->subpathCount() > 1) {
hasShapesWithMultipleSegments = true;
break;
}
}
action("object_split")->setEnabled(hasShapesWithMultipleSegments);
const bool distributionEnabled = editableShapes.size() > 2;
action("object_distribute_horizontal_left")->setEnabled(distributionEnabled);
......@@ -1597,19 +1579,42 @@ void DefaultTool::updateActions()
action("object_distribute_vertical_bottom")->setEnabled(distributionEnabled);
action("object_distribute_vertical_gaps")->setEnabled(distributionEnabled);
updateDistinctiveActions(editableShapes);
emit selectionChanged(editableShapes.size());
}
void DefaultTool::updateDistinctiveActions(const QList<KoShape*> &editableShapes) {
const bool multipleSelected = editableShapes.size() > 1;
action("object_group")->setEnabled(multipleSelected);
action("object_unite")->setEnabled(multipleSelected);
action("object_intersect")->setEnabled(multipleSelected);
action("object_subtract")->setEnabled(multipleSelected);
bool hasShapesWithMultipleSegments = false;
Q_FOREACH (KoShape *shape, editableShapes) {
KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
if (pathShape && pathShape->subpathCount() > 1) {
hasShapesWithMultipleSegments = true;
break;
}
}
action("object_split")->setEnabled(hasShapesWithMultipleSegments);
bool hasGroupShape = false;
foreach (KoShape *shape, editableShapes) {
if (dynamic_cast<KoShapeGroup *>(shape)) {
hasGroupShape = true;
break;
foreach (KoShape *shape, editableShapes) {
if (dynamic_cast<KoShapeGroup *>(shape)) {
hasGroupShape = true;
break;
}
}
}
action("object_ungroup")->setEnabled(hasGroupShape);
emit selectionChanged(editableShapes.size());
}
KoToolSelection *DefaultTool::selection()
{
return m_selectionHandler;
......@@ -1667,6 +1672,17 @@ QMenu* DefaultTool::popupActionsMenu()
return m_contextMenu.data();
}
void DefaultTool::addTransformActions(QMenu *menu) const {
menu->addAction(action("object_transform_rotate_90_cw"));
menu->addAction(action("object_transform_rotate_90_ccw"));
menu->addAction(action("object_transform_rotate_180"));
menu->addSeparator();
menu->addAction(action("object_transform_mirror_horizontally"));
menu->addAction(action("object_transform_mirror_vertically"));
menu->addSeparator();
menu->addAction(action("object_transform_reset"));
}
void DefaultTool::explicitUserStrokeEndRequest()
{
QList<KoShape *> shapes = koSelection()->selectedEditableShapesAndDelegates();
......
......@@ -114,6 +114,7 @@ private Q_SLOTS:
void slotActivateEditFillGradient(bool value);
void slotActivateEditStrokeGradient(bool value);
protected Q_SLOTS:
/// Update actions on selection change
void updateActions();
......@@ -138,6 +139,14 @@ protected:
virtual KoShapeManager *shapeManager() const;
virtual KoSelection *koSelection() const;
/**
* Enable/disable actions specific to the tool (vector vs. reference images)
*/
virtual void updateDistinctiveActions(const QList<KoShape*> &editableShapes);
void addTransformActions(QMenu *menu) const;
QScopedPointer<QMenu> m_contextMenu;
private:
class MoveGradientHandleInteractionFactory;
......@@ -173,7 +182,6 @@ private:
qreal m_angle;
KoToolSelection *m_selectionHandler;
friend class SelectionHandler;
QScopedPointer<QMenu> m_contextMenu;
DefaultToolTabbedWidget *m_tabbedOptionWidget;
};
......
......@@ -19,6 +19,7 @@
#include <QDesktopServices>
#include <QLayout>
#include <QMenu>
#include <KoShapeRegistry.h>
#include <KoShapeManager.h>
......@@ -97,6 +98,7 @@ void ToolReferenceImages::slotSelectionChanged()
{
KisReferenceImagesLayer *layer = getOrCreteReferenceImagesLayer();
m_optionsWidget->selectionChanged(layer->shapeManager()->selection());
updateActions();
}
QList<QPointer<QWidget>> ToolReferenceImages::createOptionWidgets()
......@@ -150,3 +152,13 @@ KoSelection *ToolReferenceImages::koSelection() const
auto manager = shapeManager();
return manager ? manager->selection() : nullptr;
}
void ToolReferenceImages::updateDistinctiveActions(const QList<KoShape*> &)
{
action("object_group")->setEnabled(false);
action("object_unite")->setEnabled(false);
action("object_intersect")->setEnabled(false);
action("object_subtract")->setEnabled(false);
action("object_split")->setEnabled(false);
action("object_ungroup")->setEnabled(false);
}
......@@ -55,6 +55,8 @@ protected:
KoShapeManager *shapeManager() const override;
KoSelection *koSelection() const override;
void updateDistinctiveActions(const QList<KoShape*> &editableShapes) override;
public Q_SLOTS:
void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes) override;
void deactivate() override;
......
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