- QDialog::accept();
-
- QString selected_host = hosts.currentText();
- if(selected_host.isEmpty()) {
- return;
- }
-
-#ifdef Q_WS_MAEMO_5
- int quality = quality_selector->currentIndex() + 1;
-#else
- int quality = 2;
-#endif
-
- QSettings settings;
- if(!hosts.itemIcon(hosts.currentIndex()).isNull()) {
- int listen_port = settings.value("listen_port", LISTEN_PORT_OFFSET).toInt();
-
-#if QT_VERSION >= 0x040500
- //ask user if listen_port is correct
- bool ok;
- listen_port = QInputDialog::getInt(this,
- tr("Listen for Incoming Connections"),
- tr("Listen on Port:"),
- listen_port, 1, 65535, //value, min, max
- 1, &ok);
-#else
- bool ok = true;
-#endif
- if(ok) {
- settings.setValue("listen_port", listen_port);
- emit connectToHost("", quality, listen_port);
- }
- return;
- }
-
- settings.beginGroup("hosts");
- const bool new_item = !hostnames_sorted.contains(selected_host);
- const bool used_old_host = !new_item and hosts.currentIndex() > 0;
- //if both are false, we don't need to mess with positions
-
- if(new_item or used_old_host) {
- //put selected_host at the top
- settings.setValue(QString("%1/position").arg(selected_host), 0);
-
- //don't create duplicates
- if(used_old_host)
- hostnames_sorted.removeAll(selected_host);
-
- //now rebuild list for positions >= 1
- for(int i = 0; i < hostnames_sorted.size(); i++)
- settings.setValue(QString("%1/position").arg(hostnames_sorted.at(i)), i+1);
- }
-
-#ifdef Q_WS_MAEMO_5
- settings.setValue(QString("%1/quality").arg(selected_host), quality);
-#endif
-
- settings.endGroup();
- settings.sync();
-
- emit connectToHost(QString("vnc://%1").arg(selected_host), quality, 0);
+ QDialog::accept();
+
+ QString selected_host = hosts.currentText();
+ if(selected_host.isEmpty()) {
+ return;
+ }
+
+ int quality = quality_combobox.currentIndex() + 1;
+
+ QSettings settings;
+ if(!hosts.itemIcon(hosts.currentIndex()).isNull()) {
+ //listen mode selected
+ int listen_port = settings.value("listen_port", LISTEN_PORT_OFFSET).toInt();
+
+ //ask user if listen_port is correct
+ bool ok;
+ listen_port = QInputDialog::getInt(this,
+ tr("Listen for Incoming Connections"),
+ tr("Listen on Port:"),
+ listen_port, 1, 65535, //value, min, max
+ 1, &ok);
+
+ if(ok) {
+ settings.setValue("listen_port", listen_port);
+ emit connectToHost("", quality, listen_port, viewonly.isChecked());
+ }
+ return;
+ }
+
+ settings.beginGroup("hosts");
+ const bool new_item = !hostnames_sorted.contains(selected_host);
+ const bool used_old_host = !new_item and hosts.currentIndex() > 0;
+ //if both are false, we don't need to mess with positions
+
+ if(new_item or used_old_host) {
+ //put selected_host at the top
+ settings.setValue(QString("%1/position").arg(selected_host), 0);
+
+ //don't create duplicates
+ if(used_old_host)
+ hostnames_sorted.removeAll(selected_host);
+
+ //now rebuild list for positions >= 1
+ for(int i = 0; i < hostnames_sorted.size(); i++)
+ settings.setValue(QString("%1/position").arg(hostnames_sorted.at(i)), i+1);
+ }
+
+ settings.setValue(QString("%1/quality").arg(selected_host), quality);
+ settings.setValue(QString("%1/viewonly").arg(selected_host), viewonly.isChecked());
+
+ settings.endGroup();
+ settings.sync();
+
+ //listen_port = 0 is ignored
+ emit connectToHost(QString("vnc://%1").arg(selected_host), quality, 0, viewonly.isChecked());