+
+void MainWindow::showKeyMenu()
+{
+ key_menu->exec();
+ vnc_view->sendKeySequence(key_menu->getKeySequence());
+}
+
+void MainWindow::showPreferences()
+{
+ Preferences *p = new Preferences(this);
+ p->exec();
+ delete p;
+
+ reloadSettings();
+}
+
+void MainWindow::reloadSettings()
+{
+ QSettings settings;
+#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);
+ setAttribute(Qt::WA_Maemo5PortraitOrientation, rotation == 2);
+#endif
+
+ if(vnc_view)
+ vnc_view->reloadSettings();
+}
+
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+ QMainWindow::resizeEvent(event);
+
+ forceResize();
+ if(vnc_view)
+ vnc_view->setZoomLevel(zoom_slider->value());
+
+#ifdef Q_WS_MAEMO_5
+ //hide zoom slider in portrait mode
+ zoom_slider->setVisible(height() < width());
+#endif
+}
+
+void MainWindow::showInputPanel()
+{
+#ifdef Q_WS_MAEMO_5
+ //TODO: when hardware keyboard is open, this will only cause the IM to mess up 'real' key events
+ vnc_view->setAttribute(Qt::WA_InputMethodEnabled, true);
+ vnc_view->setInputMethodHints(Qt::ImhNoAutoUppercase); //without this, IM starts with caps lock
+
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(vnc_view, &event);
+#endif
+}
+
+void MainWindow::setZoomLevel(int level)
+{
+ if(!vnc_view)
+ return;
+
+ int old_width = vnc_view->width();
+ QPoint center = vnc_view->visibleRegion().boundingRect().center();
+
+ vnc_view->setZoomLevel(level);
+
+ int new_width = vnc_view->width();
+
+ //scroll to center, if zoom level actually changed
+ if(new_width != old_width) {
+ center = center * (double(new_width)/old_width);
+ scroll_area->ensureVisible(center.x(), center.y(),
+ scroll_area->width()/2, scroll_area->height()/2);
+ vnc_view->update();
+ }
+}