zoom into center of visible area
[presencevnc] / src / preferences.cpp
index a1e66e3..ea1fe2e 100644 (file)
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 #include <QtGui>
+
+#ifdef Q_WS_MAEMO_5
 #include <QMaemo5ValueButton>
 #include <QMaemo5ListPickSelector>
+#endif
 
 #include "preferences.h"
 
@@ -28,8 +31,19 @@ void migrateConfiguration()
 {
        QSettings settings;
        int config_ver = settings.value("config_version", 0).toInt();
-       if(config_ver == 2) //config file up-to-date
+       const int current_ver = 3;
+       if(config_ver == current_ver) //config file up-to-date
+               return;
+       if(config_ver > current_ver) {
+               std::cout << "Warning: Config file was created by a newer version of Presence VNC. This may break things.\n";
+               return;
+       }
+       
+       if(settings.allKeys().isEmpty()) { //no config file
+               settings.setValue("config_version", current_ver);
+               settings.sync();
                return;
+       }
 
        std::cout << "Migrating from configuration ver. " << config_ver << "\n";
 
@@ -56,6 +70,21 @@ void migrateConfiguration()
                
                config_ver = 2;
        }
+       if(config_ver == 2) {
+               bool rescale = settings.value("rescale", false).toBool();
+               settings.remove("rescale");
+
+               int zoomlevel;
+               if(rescale)
+                       zoomlevel = 0;
+               else
+                       zoomlevel = 95;
+
+               settings.setValue("zoomlevel", zoomlevel);
+               
+               config_ver = 3;
+       }
+       Q_ASSERT(config_ver == current_ver);
        settings.setValue("config_version", config_ver);
        settings.sync();
 }
@@ -69,6 +98,7 @@ Preferences::Preferences(QWidget *parent):
        QHBoxLayout *layout1 = new QHBoxLayout();
        QVBoxLayout *layout2 = new QVBoxLayout();
 
+#ifdef Q_WS_MAEMO_5
        QMaemo5ValueButton *rotation = new QMaemo5ValueButton(tr("Screen Rotation"), this);
        rotation_selector = new QMaemo5ListPickSelector(this);
        QStandardItemModel *model = new QStandardItemModel(0, 1, this);
@@ -105,9 +135,15 @@ Preferences::Preferences(QWidget *parent):
        rightzoom->setValueLayout(QMaemo5ValueButton::ValueBesideText);
        layout2->addWidget(rightzoom);
 
+       //useful if one only wants to click using the zoom buttons exclusively
        disable_tapping = new QCheckBox(tr("Disable Tapping"), this);
        disable_tapping->setChecked(settings.value("disable_tapping", false).toBool());
        layout2->addWidget(disable_tapping);
+#endif
+
+       always_show_local_cursor = new QCheckBox(tr("Always show local cursor"), this);
+       always_show_local_cursor->setChecked(settings.value("always_show_local_cursor", false).toBool());
+       layout2->addWidget(always_show_local_cursor);
 
        QPushButton *ok = new QPushButton(tr("Done"));
        ok->setMaximumWidth(100);
@@ -123,14 +159,15 @@ Preferences::Preferences(QWidget *parent):
                this, SLOT(save()));
 }
 
-Preferences::~Preferences() { }
-
 void Preferences::save()
 {
+#ifdef Q_WS_MAEMO_5
        settings.setValue("screen_rotation", rotation_selector->currentIndex());
        settings.setValue("left_zoom", leftzoom_selector->currentIndex());
        settings.setValue("right_zoom", rightzoom_selector->currentIndex());
        settings.setValue("disable_tapping", disable_tapping->isChecked());
+#endif
+       settings.setValue("always_show_local_cursor", always_show_local_cursor->isChecked());
 
        settings.sync();
 }