From 8ebba542b08359e09689caac0d1fd35d315c4d3f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2012 12:05:23 +0200 Subject: [PATCH] Save and restore zoom value for desktop zoom and magnifier effects REVIEW: 104597 BUG: 189956 FIXED-IN: 4.9.0 --- effects/magnifier/magnifier.cpp | 14 ++++++++++++-- effects/zoom/zoom.cpp | 15 +++++++++++++-- effects/zoom/zoom.h | 3 ++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/effects/magnifier/magnifier.cpp b/effects/magnifier/magnifier.cpp index 69ae3b6b61..88801cb2ae 100644 --- a/effects/magnifier/magnifier.cpp +++ b/effects/magnifier/magnifier.cpp @@ -66,6 +66,10 @@ MagnifierEffect::~MagnifierEffect() delete m_fbo; delete m_texture; delete m_pixmap; + // Save the zoom value. + KConfigGroup conf = EffectsHandler::effectConfig("Magnifier"); + conf.writeEntry("InitialZoom", target_zoom); + conf.sync(); } bool MagnifierEffect::supported() @@ -81,6 +85,10 @@ void MagnifierEffect::reconfigure(ReconfigureFlags) width = conf.readEntry("Width", 200); height = conf.readEntry("Height", 200); magnifier_size = QSize(width, height); + // Load the saved zoom value. + target_zoom = conf.readEntry("InitialZoom", target_zoom); + if (target_zoom != zoom) + toggle(); } void MagnifierEffect::prePaintScreen(ScreenPrePaintData& data, int time) @@ -256,8 +264,10 @@ void MagnifierEffect::zoomOut() void MagnifierEffect::toggle() { - if (target_zoom == 1.0) { - target_zoom = 2; + if (zoom == 1.0) { + if (target_zoom == 1.0) { + target_zoom = 2; + } if (!polling) { polling = true; effects->startMousePolling(); diff --git a/effects/zoom/zoom.cpp b/effects/zoom/zoom.cpp index 067be39a02..b275b1e9ee 100644 --- a/effects/zoom/zoom.cpp +++ b/effects/zoom/zoom.cpp @@ -129,6 +129,10 @@ ZoomEffect::~ZoomEffect() { // switch off and free resources showCursor(); + // Save the zoom value. + KConfigGroup conf = EffectsHandler::effectConfig("Zoom"); + conf.writeEntry("InitialZoom", target_zoom); + conf.sync(); } void ZoomEffect::showCursor() @@ -223,6 +227,10 @@ void ZoomEffect::reconfigure(ReconfigureFlags) focusDelay = qMax(0, conf.readEntry("FocusDelay", focusDelay)); // The factor the zoom-area will be moved on touching an edge on push-mode or using the navigation KAction's. moveFactor = qMax(0.1, conf.readEntry("MoveFactor", moveFactor)); + // Load the saved zoom value. + target_zoom = conf.readEntry("InitialZoom", target_zoom); + if (target_zoom > 1.0) + zoomIn(target_zoom); } void ZoomEffect::prePaintScreen(ScreenPrePaintData& data, int time) @@ -368,9 +376,12 @@ void ZoomEffect::postPaintScreen() effects->postPaintScreen(); } -void ZoomEffect::zoomIn() +void ZoomEffect::zoomIn(double to) { - target_zoom *= zoomFactor; + if (to < 0.0) + target_zoom *= zoomFactor; + else + target_zoom = to; if (!polling) { polling = true; effects->startMousePolling(); diff --git a/effects/zoom/zoom.h b/effects/zoom/zoom.h index d08a82a640..d809b21877 100644 --- a/effects/zoom/zoom.h +++ b/effects/zoom/zoom.h @@ -45,7 +45,8 @@ public: virtual void postPaintScreen(); virtual bool isActive() const; private slots: - void zoomIn(); + inline void zoomIn() { zoomIn(-1.0); }; + void zoomIn(double to); void zoomOut(); void actualSize(); void moveZoomLeft();