add 'zoom to cursor' option
authorChristian Pulvermacher <christian@hazel.(none)>
Wed, 27 Oct 2010 19:37:21 +0000 (21:37 +0200)
committerChristian Pulvermacher <christian@hazel.(none)>
Wed, 27 Oct 2010 19:37:21 +0000 (21:37 +0200)
debian/changelog
src/mainwindow.cpp
src/mainwindow.h
src/preferences.cpp
src/preferences.h
src/vncview.h

index fd02309..d5e3e29 100644 (file)
@@ -1,7 +1,8 @@
 presencevnc (0.7) unstable; urgency=low
 
-  * Show current magnification when zooming
   * Doubleclick zoom slider for 100%
+  * Added "Zoom to cursor" option (on by default)
+  * Show current magnification when zooming
 
  -- Christian Pulvermacher <pulvermacher@gmx.de>  Sat, 23 Oct 2010 18:32:50 +0200
 
index b63faa1..6926409 100644 (file)
@@ -315,8 +315,10 @@ void MainWindow::showPreferences()
 
 void MainWindow::reloadSettings()
 {
-#ifdef Q_WS_MAEMO_5
        QSettings settings;
+       zoom_to_cursor = settings.value("zoom_to_cursor", true).toBool();
+       
+#ifdef Q_WS_MAEMO_5
        int rotation = settings.value("screen_rotation", 0).toInt();
        setAttribute(Qt::WA_Maemo5AutoOrientation, rotation == 0);
        setAttribute(Qt::WA_Maemo5LandscapeOrientation, rotation == 1);
@@ -367,7 +369,11 @@ void MainWindow::setZoomLevel(int level)
 
        //scroll to center, if zoom level actually changed
        if(old_factor != new_factor) {
-               center = center * (double(new_factor)/old_factor);
+               if(zoom_to_cursor)
+                       center = new_factor * vnc_view->cursorPosition();
+               else //zoom to center of visible region
+                       center = center * (double(new_factor)/old_factor);
+
                scroll_area->ensureVisible(center.x(), center.y(),
                        vnc_view->visibleRegion().boundingRect().width()/2,
                        vnc_view->visibleRegion().boundingRect().height()/2);
index 6444d49..7249e54 100644 (file)
@@ -56,11 +56,13 @@ protected:
 private:
        void grabZoomKeys(bool grab);
        void reloadSettings();
+
        VncView *vnc_view;
        ScrollArea *scroll_area;
        QToolBar *toolbar;
        QSlider *zoom_slider;
        QAction *scaling, *show_toolbar, *disconnect_action;
        KeyMenu *key_menu;
+       bool zoom_to_cursor;
 };
 #endif
index ea1fe2e..5a2fa2e 100644 (file)
@@ -145,6 +145,10 @@ Preferences::Preferences(QWidget *parent):
        always_show_local_cursor->setChecked(settings.value("always_show_local_cursor", false).toBool());
        layout2->addWidget(always_show_local_cursor);
 
+       zoom_to_cursor = new QCheckBox(tr("Zoom to cursor"), this);
+       zoom_to_cursor->setChecked(settings.value("zoom_to_cursor", true).toBool());
+       layout2->addWidget(zoom_to_cursor);
+
        QPushButton *ok = new QPushButton(tr("Done"));
        ok->setMaximumWidth(100);
 
@@ -168,6 +172,7 @@ void Preferences::save()
        settings.setValue("disable_tapping", disable_tapping->isChecked());
 #endif
        settings.setValue("always_show_local_cursor", always_show_local_cursor->isChecked());
+       settings.setValue("zoom_to_cursor", zoom_to_cursor->isChecked());
 
        settings.sync();
 }
index 1065ec4..7f95375 100644 (file)
@@ -40,6 +40,6 @@ private:
        QMaemo5ListPickSelector *rightzoom_selector;
        QCheckBox *disable_tapping;
 #endif
-       QCheckBox *always_show_local_cursor;
+       QCheckBox *always_show_local_cursor, *zoom_to_cursor;
 };
 #endif
index 1d146c1..35b6612 100644 (file)
@@ -58,6 +58,7 @@ public:
     void setViewOnly(bool viewOnly);
     void showDotCursor(DotCursorState state);
     void useFastTransformations(bool enabled);
+    QPoint cursorPosition() { return QPoint(cursor_x, cursor_y); }
     
 public slots:
     void setZoomLevel(int level = -1); //'level' doesn't correspond to actual magnification, though mapping is done here