Commit 18b51ef2 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove the special buttons from KoZoomWidgets

Krita only needs the aspect button, so we can hardcode that. The
other options were only relevant for other KOffice/Calligra
applications.
parent 5e7ac9bc
......@@ -54,8 +54,8 @@
class KisZoomController : public KoZoomController
{
public:
KisZoomController(KoCanvasController *co, KisCoordinatesConverter *zh, KActionCollection *actionCollection, KoZoomAction::SpecialButtons specialButtons, QObject *parent)
: KoZoomController(co, zh, actionCollection, specialButtons, parent),
KisZoomController(KoCanvasController *co, KisCoordinatesConverter *zh, KActionCollection *actionCollection, QObject *parent)
: KoZoomController(co, zh, actionCollection, parent),
m_converter(zh)
{
}
......@@ -101,7 +101,7 @@ void KisZoomManager::setup(KActionCollection * actionCollection)
KisCoordinatesConverter *converter =
dynamic_cast<KisCoordinatesConverter*>(m_zoomHandler);
m_zoomController = new KisZoomController(m_canvasController, converter, actionCollection, KoZoomAction::AspectMode, this);
m_zoomController = new KisZoomController(m_canvasController, converter, actionCollection, this);
m_zoomHandler->setZoomMode(KoZoomMode::ZOOM_PIXELS);
m_zoomHandler->setZoom(1.0);
......
......@@ -61,8 +61,6 @@ public:
qreal effectiveZoom;
KoZoomAction::SpecialButtons specialButtons;
QList<qreal> generateSliderZoomLevels() const;
QList<qreal> filterMenuZoomLevels(const QList<qreal> &zoomLevels) const;
......@@ -119,7 +117,6 @@ KoZoomAction::KoZoomAction(KoZoomMode::Modes zoomModes, const QString& text, QOb
, d(new Private(this))
{
d->zoomModes = zoomModes;
d->specialButtons = 0;
setIcon(koIcon("zoom-original"));
setEditable( true );
setMaxComboViewCount( 15 );
......@@ -270,7 +267,7 @@ void KoZoomAction::zoomOut()
QWidget * KoZoomAction::createWidget(QWidget *parent)
{
KoZoomWidget* zoomWidget = new KoZoomWidget(parent, d->specialButtons, d->sliderLookup.size() - 1);
KoZoomWidget* zoomWidget = new KoZoomWidget(parent, d->sliderLookup.size() - 1);
connect(this, SIGNAL(zoomLevelsChanged(QStringList)), zoomWidget, SLOT(setZoomLevels(QStringList)));
connect(this, SIGNAL(currentZoomLevelChanged(QString)), zoomWidget, SLOT(setCurrentZoomLevel(QString)));
connect(this, SIGNAL(sliderChanged(int)), zoomWidget, SLOT(setSliderValue(int)));
......@@ -303,11 +300,6 @@ void KoZoomAction::setSelectedZoomMode(KoZoomMode::Mode mode)
emit currentZoomLevelChanged(modeString);
}
void KoZoomAction::setSpecialButtons( SpecialButtons buttons )
{
d->specialButtons = buttons;
}
void KoZoomAction::setAspectMode(bool status)
{
emit aspectModeChanged(status);
......
......@@ -54,19 +54,6 @@ public:
*/
QWidget* createWidget(QWidget* parent) override;
enum SpecialButton {
AspectMode = 1, ///< changing aspect mode
ZoomToSelection = 2, ///< zooms to current selection
ZoomToAll = 4 ///< zooms to the whole content of the document
};
Q_DECLARE_FLAGS(SpecialButtons, SpecialButton)
/**
* Enables specified special buttons.
* This should be called immediately after calling the constructor.
* @param buttons mask of the special button flags to enable
*/
void setSpecialButtons( SpecialButtons buttons );
qreal effectiveZoom() const;
......@@ -228,6 +215,4 @@ private:
Private * const d;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KoZoomAction::SpecialButtons)
#endif
......@@ -54,9 +54,9 @@ void KoZoomController::Private::init(KoCanvasController *co,
connect(canvasController->proxyObject, SIGNAL( zoomRelative(const qreal, const QPointF& ) ), parent, SLOT( requestZoomRelative( const qreal, const QPointF& ) ) );
}
KoZoomController::KoZoomController(KoCanvasController *co, KoZoomHandler *zh, KActionCollection *actionCollection, KoZoomAction::SpecialButtons specialButtons, QObject *parent)
KoZoomController::KoZoomController(KoCanvasController *co, KoZoomHandler *zh, KActionCollection *actionCollection, QObject *parent)
: QObject(parent),
d(new Private(this, specialButtons))
d(new Private(this))
{
d->init(co, zh, actionCollection);
}
......
......@@ -66,12 +66,10 @@ public:
* @param controller the canvasController
* @param zoomHandler the zoom handler (viewconverter with setter methods)
* @param actionCollection the action collection where the KoZoomAction is added to
* @param specialButtons controls which special buttons to show
*/
KoZoomController(KoCanvasController *controller,
KoZoomHandler *zoomHandler,
KActionCollection *actionCollection,
KoZoomAction::SpecialButtons specialButtons = 0,
QObject *parent = 0);
/// destructor
......
......@@ -35,11 +35,10 @@
class Q_DECL_HIDDEN KoZoomController::Private
{
public:
Private(KoZoomController *p, KoZoomAction::SpecialButtons specialButtons)
Private(KoZoomController *p)
: canvasController(0), zoomHandler(0), action(0), textMinX(1), textMaxX(600), fitMargin(0), parent(p)
{
action = new KoZoomAction(KoZoomMode::ZOOM_WIDTH | KoZoomMode::ZOOM_PAGE, i18n("Zoom"), p);
action->setSpecialButtons(specialButtons);
}
~Private()
{
......
......@@ -47,7 +47,7 @@ public:
qreal effectiveZoom;
};
KoZoomWidget::KoZoomWidget(QWidget* parent, KoZoomAction::SpecialButtons specialButtons, int maxZoom )
KoZoomWidget::KoZoomWidget(QWidget* parent, int maxZoom )
: QWidget(parent)
, d(new Private)
{
......@@ -71,35 +71,16 @@ KoZoomWidget::KoZoomWidget(QWidget* parent, KoZoomAction::SpecialButtons special
layout->addWidget(d->slider);
layout->setStretch(1, 1);
if (specialButtons & KoZoomAction::AspectMode) {
d->aspectButton = new QToolButton(this);
d->aspectButton->setIcon(koIcon("zoom-pixels"));
d->aspectButton->setIconSize(QSize(16,16));
d->aspectButton->setCheckable(true);
d->aspectButton->setChecked(true);
d->aspectButton->setAutoRaise(true);
d->aspectButton->setToolTip(i18n("Use same aspect as pixels"));
connect(d->aspectButton, SIGNAL(toggled(bool)), this, SIGNAL(aspectModeChanged(bool)));
layout->addWidget(d->aspectButton);
}
if (specialButtons & KoZoomAction::ZoomToSelection) {
QToolButton * zoomToSelectionButton = new QToolButton(this);
zoomToSelectionButton->setIcon(koIcon("zoom-select"));
zoomToSelectionButton->setIconSize(QSize(16,16));
zoomToSelectionButton->setAutoRaise(true);
zoomToSelectionButton->setToolTip(i18n("Zoom to Selection"));
connect(zoomToSelectionButton, SIGNAL(clicked(bool)), this, SIGNAL(zoomedToSelection()));
layout->addWidget(zoomToSelectionButton);
}
if (specialButtons & KoZoomAction::ZoomToAll) {
QToolButton * zoomToAllButton = new QToolButton(this);
zoomToAllButton->setIcon(koIcon("zoom-draw"));
zoomToAllButton->setIconSize(QSize(16,16));
zoomToAllButton->setAutoRaise(true);
zoomToAllButton->setToolTip(i18n("Zoom to All"));
connect(zoomToAllButton, SIGNAL(clicked(bool)), this, SIGNAL(zoomedToAll()));
layout->addWidget(zoomToAllButton);
}
d->aspectButton = new QToolButton(this);
d->aspectButton->setIcon(koIcon("zoom-pixels"));
d->aspectButton->setIconSize(QSize(16,16));
d->aspectButton->setCheckable(true);
d->aspectButton->setChecked(true);
d->aspectButton->setAutoRaise(true);
d->aspectButton->setToolTip(i18n("Use same aspect as pixels"));
connect(d->aspectButton, SIGNAL(toggled(bool)), this, SIGNAL(aspectModeChanged(bool)));
layout->addWidget(d->aspectButton);
connect(d->slider, SIGNAL(valueChanged(int)), this, SIGNAL(sliderValueChanged(int)));
}
......
......@@ -31,7 +31,7 @@ class KoZoomWidget : public QWidget
Q_OBJECT
public:
KoZoomWidget(QWidget* parent, KoZoomAction::SpecialButtons specialButtons, int maxZoom);
KoZoomWidget(QWidget* parent, int maxZoom);
~KoZoomWidget() override;
Q_SIGNALS:
......
......@@ -31,7 +31,7 @@
void zoomcontroller_test::testApi()
{
KoZoomHandler zoomHandler;
KoZoomController zoomController(new KoCanvasControllerWidget(0), &zoomHandler, new KActionCollection(this), KoZoomAction::AspectMode);
KoZoomController zoomController(new KoCanvasControllerWidget(0), &zoomHandler, new KActionCollection(this));
Q_UNUSED(zoomController);
}
......
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