add 'zoom to cursor' option
[presencevnc] / src / mainwindow.cpp
index 46737d4..6926409 100644 (file)
@@ -119,7 +119,10 @@ MainWindow::MainWindow(QString url, int quality):
                this, SLOT(updateScreenSpaceDelayed()));
 
        setCentralWidget(scroll_area);
-       new FullScreenExitButton(this);
+
+       FullScreenExitButton* fullscreen_exit_button = new FullScreenExitButton(this);
+       connect(fullscreen_exit_button, SIGNAL(clicked()),
+               this, SLOT(toggleFullscreen()));
 
        grabZoomKeys(true);
        reloadSettings();
@@ -312,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);
@@ -364,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);