Commit f5228a44 authored by Halla Rempt's avatar Halla Rempt

Move actions from zoom manager to view manager

The zoommanager is only created when an image is created or opened,
which is too late for xmlgui to add actions to the menus or action
collection.

This restores the show rulers, show guides and zoom to 100% actions,
but the show guides action is hidden, since guiders are still broken.

BUG:342755
parent ec09af95
<?xml version="1.0"?>
<kpartgui xmlns="http://www.kde.org/standards/kxmlgui/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Krita" version="62" xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd">
<kpartgui xmlns="http://www.kde.org/standards/kxmlgui/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Krita" version="64" xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd">
<MenuBar>
<Menu name="file" noMerge="1">
<text>&amp;File</text>
......@@ -63,7 +63,7 @@
<Separator/>
<Action name="view_ruler"/>
<Action name="view_guidelines"/>
<Action name="view_show_guides"/>
<!--Action name="view_show_guides"/-->
<Action name="showStatusBar" />
<Separator/>
<Action name="view_grid"/>
......
......@@ -212,6 +212,16 @@ public:
KisViewManagerPrivate()
: filterManager(0)
, statusBar(0)
, createTemplate(0)
, saveIncremental(0)
, saveIncrementalBackup(0)
, openResourcesDirectory(0)
, rotateCanvasRight(0)
, rotateCanvasLeft(0)
, wrapAroundAction(0)
, showRulersAction(0)
, zoomTo100pct(0)
, showGuidesAction(0)
, selectionManager(0)
, controlFrame(0)
, nodeManager(0)
......@@ -257,6 +267,10 @@ public:
KisAction *rotateCanvasRight;
KisAction *rotateCanvasLeft;
KisAction *wrapAroundAction;
KisAction *showRulersAction;
KisAction *zoomTo100pct;
KisAction *showGuidesAction;
KisSelectionManager *selectionManager;
KisControlFrame *controlFrame;
KisNodeManager *nodeManager;
......@@ -278,6 +292,9 @@ public:
KActionCollection *actionCollection;
KisMirrorManager *mirrorManager;
QPointer<KisInputManager> inputManager;
};
......@@ -374,6 +391,10 @@ void KisViewManager::setCurrentView(KisView *view)
d->rotateCanvasRight->disconnect();
d->rotateCanvasLeft->disconnect();
d->wrapAroundAction->disconnect();
d->showRulersAction->disconnect();
d->zoomTo100pct->disconnect();
d->showGuidesAction->disconnect();
d->currentImageView->canvasController()->disconnect(SIGNAL(toolOptionWidgetsChanged(QList<QPointer<QWidget> >)), mainWindow());
resourceProvider()->disconnect(d->currentImageView->canvasBase());
}
......@@ -397,6 +418,9 @@ void KisViewManager::setCurrentView(KisView *view)
connect(d->wrapAroundAction, SIGNAL(toggled(bool)), dynamic_cast<KisCanvasController*>(d->currentImageView->canvasController()), SLOT(slotToggleWrapAroundMode(bool)));
connect(d->currentImageView->canvasController(), SIGNAL(toolOptionWidgetsChanged(QList<QPointer<QWidget> >)), mainWindow(), SLOT(newOptionWidgets(QList<QPointer<QWidget> >)));
connect(d->currentImageView->image(), SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), d->controlFrame->paintopBox(), SLOT(slotColorSpaceChanged(const KoColorSpace*)));
connect(d->showRulersAction, SIGNAL(triggered(bool)), imageView->zoomManager(), SLOT(toggleShowRulers(bool)));
connect(d->zoomTo100pct, SIGNAL(triggered()), imageView->zoomManager(), SLOT(zoomTo100()));
connect(d->showGuidesAction, SIGNAL(triggered(bool)), imageView->zoomManager(), SLOT(showGuides(bool)));
}
d->filterManager->setView(imageView);
......@@ -684,6 +708,27 @@ void KisViewManager::createActions()
actionManager()->addAction("edit_blacklist_cleanup", a);
connect(a, SIGNAL(triggered()), this, SLOT(slotBlacklistCleanup()));
d->showRulersAction = new KisAction(i18n("Show Rulers"), this);
d->showRulersAction->setCheckable(true);
d->showRulersAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
actionManager()->addAction("view_ruler", d->showRulersAction);
d->showRulersAction->setWhatsThis(i18n("The rulers show the horizontal and vertical positions of the mouse on the image "
"and can be used to position your mouse at the right place on the canvas. <p>Uncheck this to hide the rulers.</p>"));
KisConfig cfg;
d->showRulersAction->setChecked(cfg.showRulers());
d->showGuidesAction = new KisAction(i18n("Show Guides"), this);
d->showGuidesAction->setCheckable(true);
d->showGuidesAction->setCheckable(false);
d->showGuidesAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->showGuidesAction->setToolTip(i18n("Shows or hides guides"));
actionManager()->addAction("view_show_guides", d->showGuidesAction);
d->zoomTo100pct = new KisAction(i18n("Reset zoom"), this);
d->zoomTo100pct->setActivationFlags(KisAction::ACTIVE_IMAGE);
actionManager()->addAction("zoom_to_100pct", d->zoomTo100pct);
d->zoomTo100pct->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_0 ) );
}
......
......@@ -79,15 +79,13 @@ KisZoomManager::KisZoomManager(QPointer<KisView> view, KoZoomHandler * zoomHandl
, m_verticalRuler(0)
, m_zoomAction(0)
, m_zoomActionWidget(0)
, m_100pct(0)
, m_showGuidesAction(0)
{
}
KisZoomManager::~KisZoomManager()
{
KisConfig cfg;
cfg.setShowRulers(m_showRulersAction->isChecked());
cfg.setShowRulers(m_horizontalRuler->isVisible());
delete m_zoomActionWidget;
}
......@@ -107,7 +105,6 @@ void KisZoomManager::setup(KActionCollection * actionCollection)
KisCoordinatesConverter *converter =
dynamic_cast<KisCoordinatesConverter*>(m_zoomHandler);
KisConfig cfg;
m_zoomController = new KisZoomController(m_canvasController, converter, actionCollection, KoZoomAction::AspectMode, this);
m_zoomHandler->setZoomMode(KoZoomMode::ZOOM_PIXELS);
m_zoomHandler->setZoom(1.0);
......@@ -118,22 +115,6 @@ void KisZoomManager::setup(KActionCollection * actionCollection)
m_zoomAction = m_zoomController->zoomAction();
m_zoomActionWidget = m_zoomAction->createWidget(0);
m_showRulersAction = new KToggleAction(i18n("Show Rulers"), this);
actionCollection->addAction("view_ruler", m_showRulersAction);
m_showRulersAction->setWhatsThis(i18n("The rulers show the horizontal and vertical positions of the mouse on the image "
"and can be used to position your mouse at the right place on the canvas. <p>Uncheck this to hide the rulers.</p>"));
connect(m_showRulersAction, SIGNAL(toggled(bool)), SLOT(toggleShowRulers(bool)));
m_showGuidesAction = new KToggleAction(i18n("Show Guides"), this);
m_showGuidesAction->setToolTip(i18n("Shows or hides guides"));
m_showGuidesAction->setChecked(m_view->document()->guidesData().showGuideLines());
connect(m_showGuidesAction, SIGNAL(triggered(bool)), this, SLOT(showGuides()));
actionCollection->addAction("view_show_guides", m_showGuidesAction);
m_100pct = new KAction(i18n("Reset zoom"), this);
actionCollection->addAction("zoom_to_100pct", m_100pct);
m_100pct->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_0 ) );
connect(m_100pct, SIGNAL(triggered()), SLOT(zoomTo100()));
// Put the canvascontroller in a layout so it resizes with us
QGridLayout * layout = new QGridLayout(m_view);
......@@ -141,21 +122,17 @@ void KisZoomManager::setup(KActionCollection * actionCollection)
layout->setMargin(0);
m_view->setLayout(layout);
bool show = cfg.showRulers();
m_view->document()->setUnit(KoUnit(KoUnit::Pixel));
m_horizontalRuler = new KoRuler(m_view, Qt::Horizontal, m_zoomHandler);
m_horizontalRuler->setShowMousePosition(true);
m_horizontalRuler->setVisible(show);
m_horizontalRuler->createGuideToolConnection(m_view->canvasBase());
new KoRulerController(m_horizontalRuler, m_canvasController->canvas()->resourceManager());
m_verticalRuler = new KoRuler(m_view, Qt::Vertical, m_zoomHandler);
m_verticalRuler->setShowMousePosition(true);
m_verticalRuler->setVisible(show);
m_verticalRuler->createGuideToolConnection(m_view->canvasBase());
m_showRulersAction->setChecked(show);
QList<QAction*> unitActions = m_view->createChangeUnitActions(true);
m_horizontalRuler->setPopupActionList(unitActions);
......@@ -185,6 +162,11 @@ void KisZoomManager::setup(KActionCollection * actionCollection)
applyRulersUnit(m_view->document()->unit());
KisConfig cfg;
toggleShowRulers(cfg.showRulers());
}
void KisZoomManager::mousePositionChanged(const QPoint &viewPos)
......@@ -287,9 +269,9 @@ void KisZoomManager::zoomTo100()
m_view->canvasBase()->notifyZoomChanged();
}
void KisZoomManager::showGuides()
void KisZoomManager::showGuides(bool toggle)
{
m_view->document()->guidesData().setShowGuideLines(m_showGuidesAction->isChecked());
m_view->document()->guidesData().setShowGuideLines(toggle);
m_view->canvasBase()->canvasWidget()->update();
}
......
......@@ -61,7 +61,7 @@ public:
QWidget *zoomActionWidget() const;
private slots:
public slots:
void slotZoomChanged(KoZoomMode::Mode mode, qreal zoom);
void slotScrollAreaSizeChanged();
......@@ -70,7 +70,7 @@ private slots:
void changeAspectMode(bool aspectMode);
void pageOffsetChanged();
void zoomTo100();
void showGuides();
void showGuides(bool toggle);
void applyRulersUnit(const KoUnit &baseUnit);
private:
......@@ -81,11 +81,8 @@ private:
KoZoomController *m_zoomController;
KoRuler * m_horizontalRuler;
KoRuler * m_verticalRuler;
QAction *m_showRulersAction;
KoZoomAction * m_zoomAction;
QWidget * m_zoomActionWidget;
KAction *m_100pct;
QAction * m_showGuidesAction;
QPoint m_rulersOffset;
};
......
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