Save and restore zoom value for desktop zoom and magnifier effects

REVIEW: 104597
BUG: 189956
FIXED-IN: 4.9.0
This commit is contained in:
Ghislain MARY 2012-04-13 12:05:23 +02:00 committed by Martin Gräßlin
parent 9aa30ad976
commit 8ebba542b0
3 changed files with 27 additions and 5 deletions

View file

@ -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();

View file

@ -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();

View file

@ -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();