X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fpreferences.cpp;h=83a180dbcfb71d52a02f8ace685ff90a3a3b7a34;hb=6c001694d20e612b0c9ca1bcbfae3b4269022e50;hp=893a8e5c8c53778e21f845324744b5fe437bff39;hpb=8e4c1dcc44c78f4fabcdc95810120e18f62abae9;p=presencevnc diff --git a/src/preferences.cpp b/src/preferences.cpp index 893a8e5..83a180d 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -17,8 +17,11 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include + +#ifdef Q_WS_MAEMO_5 #include #include +#endif #include "preferences.h" @@ -28,8 +31,19 @@ void migrateConfiguration() { QSettings settings; int config_ver = settings.value("config_version", 0).toInt(); - if(config_ver == 1) //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"; @@ -42,6 +56,35 @@ void migrateConfiguration() settings.setValue("left_zoom", right_zoom+1); config_ver = 1; } + if(config_ver == 1) { + QString last_hostname = settings.value("last_hostname", "").toString(); + settings.remove("last_hostname"); + if(!last_hostname.isEmpty()) { + //make sure hostname is sane + last_hostname.remove(QChar('/')); + last_hostname.remove(QChar('\\')); + last_hostname = last_hostname.toLower(); + + settings.setValue(QString("hosts/%1/position").arg(last_hostname), 0); + } + + 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(); } @@ -50,12 +93,13 @@ void migrateConfiguration() Preferences::Preferences(QWidget *parent): QDialog(parent) { - setWindowTitle("Preferences"); + setWindowTitle(tr("Preferences")); QHBoxLayout *layout1 = new QHBoxLayout(); QVBoxLayout *layout2 = new QVBoxLayout(); - QMaemo5ValueButton *rotation = new QMaemo5ValueButton(tr("Screen Rotation"), this); +#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); model->appendRow(new QStandardItem(tr("Automatic"))); @@ -67,23 +111,23 @@ Preferences::Preferences(QWidget *parent): rotation->setValueLayout(QMaemo5ValueButton::ValueBesideText); layout2->addWidget(rotation); - QMaemo5ValueButton *leftzoom = new QMaemo5ValueButton(tr("Left Zoom Button"), this); + QMaemo5ValueButton *leftzoom = new QMaemo5ValueButton(tr("Left zoom button"), this); leftzoom_selector = new QMaemo5ListPickSelector(this); QStandardItemModel *key_model = new QStandardItemModel(0, 1, this); - key_model->insertRow(0, new QStandardItem(tr("Left Click"))); - key_model->insertRow(1, new QStandardItem(tr("Right Click"))); - key_model->insertRow(2, new QStandardItem(tr("Middle Click"))); - key_model->insertRow(3, new QStandardItem(tr("Wheel Up"))); - key_model->insertRow(4, new QStandardItem(tr("Wheel Down"))); - key_model->insertRow(5, new QStandardItem(tr("Page Up"))); - key_model->insertRow(6, new QStandardItem(tr("Page Down"))); + key_model->insertRow(0, new QStandardItem(tr("Left click"))); + key_model->insertRow(1, new QStandardItem(tr("Right click"))); + key_model->insertRow(2, new QStandardItem(tr("Middle click"))); + key_model->insertRow(3, new QStandardItem(tr("Wheel up"))); + key_model->insertRow(4, new QStandardItem(tr("Wheel down"))); + key_model->insertRow(5, new QStandardItem(tr("Page up"))); + key_model->insertRow(6, new QStandardItem(tr("Page down"))); leftzoom_selector->setModel(key_model); leftzoom_selector->setCurrentIndex(settings.value("left_zoom", 0).toInt()); leftzoom->setPickSelector(leftzoom_selector); leftzoom->setValueLayout(QMaemo5ValueButton::ValueBesideText); layout2->addWidget(leftzoom); - QMaemo5ValueButton *rightzoom = new QMaemo5ValueButton(tr("Right Zoom Button"), this); + QMaemo5ValueButton *rightzoom = new QMaemo5ValueButton(tr("Right zoom button"), this); rightzoom_selector = new QMaemo5ListPickSelector(this); rightzoom_selector->setModel(key_model); rightzoom_selector->setCurrentIndex(settings.value("right_zoom", 1).toInt()); @@ -91,11 +135,21 @@ Preferences::Preferences(QWidget *parent): rightzoom->setValueLayout(QMaemo5ValueButton::ValueBesideText); layout2->addWidget(rightzoom); - disable_tapping = new QCheckBox(tr("Disable Tapping"), this); + //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("OK"); + 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); layout1->addLayout(layout2); @@ -109,14 +163,16 @@ 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.setValue("zoom_to_cursor", zoom_to_cursor->isChecked()); settings.sync(); }