From: Christian Pulvermacher Date: Wed, 27 Oct 2010 19:37:21 +0000 (+0200) Subject: add 'zoom to cursor' option X-Git-Tag: 0.7~6^2~1 X-Git-Url: https://vcs.maemo.org/git/?p=presencevnc;a=commitdiff_plain;h=245b76cabb0cd6f36802845e6f217f78ed62abb2 add 'zoom to cursor' option --- diff --git a/debian/changelog b/debian/changelog index fd02309..d5e3e29 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Sat, 23 Oct 2010 18:32:50 +0200 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b63faa1..6926409 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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); diff --git a/src/mainwindow.h b/src/mainwindow.h index 6444d49..7249e54 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 diff --git a/src/preferences.cpp b/src/preferences.cpp index ea1fe2e..5a2fa2e 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -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(); } diff --git a/src/preferences.h b/src/preferences.h index 1065ec4..7f95375 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -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 diff --git a/src/vncview.h b/src/vncview.h index 1d146c1..35b6612 100644 --- a/src/vncview.h +++ b/src/vncview.h @@ -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