- setWindowTitle("Presence VNC");
- setAttribute(Qt::WA_Maemo5StackedWindow);
-
- migrateConfiguration();
-
- QSettings settings;
-
- //set up toolbar
- toolbar = new QToolBar(0);
- toolbar->addAction("Mod", this, SLOT(showModifierMenu()));
- toolbar->addAction("Tab", this, SLOT(sendTab()));
- toolbar->addAction("Esc", this, SLOT(sendEsc()));
- toolbar->addAction("PgUp", this, SLOT(sendPgUp()));
- toolbar->addAction("PgDn", this, SLOT(sendPgDn()));
- toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/chat_enter.png"), "", this, SLOT(sendReturn()));
- toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/control_keyboard.png"), "", this, SLOT(showInputPanel()));
-
- //move fullscreen button to the right
- QWidget *spacer = new QWidget();
- spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- toolbar->addWidget(spacer);
-
- toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png"), "", this, SLOT(toggleFullscreen()));
- addToolBar(toolbar);
- toolbar->setVisible(settings.value("show_toolbar", true).toBool());
-
- //set up menu
- QMenuBar *menu = new QMenuBar(this);
- QAction *connect_action = new QAction(tr("Connect"), this);
- disconnect_action = new QAction(tr("Disconnect"), this);
- menu->addAction(connect_action);
- menu->addAction(disconnect_action);
- scaling = new QAction(tr("Fit to Screen"), this);
- scaling->setCheckable(true);
- scaling->setChecked(settings.value("rescale", true).toBool());
- menu->addAction(scaling);
- show_toolbar = new QAction(tr("Show Toolbar"), this);
- show_toolbar->setCheckable(true);
- show_toolbar->setChecked(settings.value("show_toolbar", true).toBool());
- menu->addAction(show_toolbar);
- QAction *pref_action = new QAction(tr("Preferences"), this);
- menu->addAction(pref_action);
- QAction *about_action = new QAction(tr("About"), this);
- menu->addAction(about_action);
-
- connect(about_action, SIGNAL(triggered()),
- this, SLOT(about()));
- connect(pref_action, SIGNAL(triggered()),
- this, SLOT(showPreferences()));
- connect(connect_action, SIGNAL(triggered()),
- this, SLOT(showConnectDialog()));
- connect(disconnect_action, SIGNAL(triggered()),
- this, SLOT(disconnectFromHost()));
- connect(show_toolbar, SIGNAL(toggled(bool)),
- toolbar, SLOT(setVisible(bool)));
- connect(show_toolbar, SIGNAL(toggled(bool)),
- this, SLOT(forceResizeDelayed()));
-
- setCentralWidget(scroll_area);
- new FullScreenExitButton(this);
-
- grabZoomKeys(true);
- reloadSettings();
-
- connect(QApplication::desktop(), SIGNAL(resized(int)),
- this, SLOT(forceResize()));
-
- if(url.isNull()) {
- disconnect_action->setEnabled(false);
- toolbar->setEnabled(false);
- showConnectDialog();
- } else {
- vnc_view = new VncView(this, url, RemoteView::Quality(quality));
- connect(scaling, SIGNAL(toggled(bool)),
- vnc_view, SLOT(enableScaling(bool)));
- connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
- this, SLOT(statusChanged(RemoteView::RemoteStatus)));
- scroll_area->setWidget(vnc_view);
- vnc_view->start();
- vnc_view->enableScaling(scaling->isChecked());
- }
+ setWindowTitle("Presence VNC");
+#ifdef Q_WS_MAEMO_5
+ setContextMenuPolicy(Qt::NoContextMenu);
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+#endif
+
+ migrateConfiguration();
+
+ //set up toolbar
+ toolbar = new QToolBar(0);
+ key_menu_button = input_toolbuttons->addAction(toolbar->addAction(QChar(0x2026), this, SLOT(showKeyMenu()))); //"..." button
+ key_menu_button->setCheckable(true); //used to indicate wether a modifier key is still pressed
+ input_toolbuttons->addAction(toolbar->addAction(tr("Tab"), this, SLOT(sendTab())));
+ input_toolbuttons->addAction(toolbar->addAction(tr("Esc"), this, SLOT(sendEsc())));
+ input_toolbuttons->addAction(toolbar->addAction(tr("PgUp"), this, SLOT(sendPgUp())));
+ input_toolbuttons->addAction(toolbar->addAction(tr("PgDn"), this, SLOT(sendPgDn())));
+#ifdef Q_WS_MAEMO_5
+ input_toolbuttons->addAction(toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/chat_enter.png"), "", this, SLOT(sendReturn())));
+ input_toolbuttons->addAction(toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/control_keyboard.png"), "", this, SLOT(showInputPanel())));
+#endif
+
+ QSettings settings;
+ zoom_slider = new QSlider(Qt::Horizontal, 0);
+ zoom_slider->setRange(0, 100);
+ connect(zoom_slider, SIGNAL(valueChanged(int)),
+ this, SLOT(setZoomLevel(int)));
+ connect(zoom_slider, SIGNAL(sliderReleased()),
+ this, SLOT(zoomSliderReleased()));
+ zoom_slider->setValue(settings.value("zoomlevel", 95).toInt());
+ toolbar->addWidget(zoom_slider);
+
+#ifdef Q_WS_MAEMO_5
+ toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png"), "", this, SLOT(toggleFullscreen()));
+#else
+ toolbar->addAction(tr("Toggle Fullscreen"), this, SLOT(toggleFullscreen()));
+#endif
+ addToolBar(toolbar);
+ toolbar->setVisible(settings.value("show_toolbar", true).toBool());
+ toolbar->setEnabled(false);
+
+ //set up menu
+ QAction *connect_action = new QAction(tr("Connect"), this);
+ disconnect_action = new QAction(tr("Disconnect"), this);
+ show_toolbar = new QAction(tr("Show toolbar"), this);
+ show_toolbar->setCheckable(true);
+ show_toolbar->setChecked(settings.value("show_toolbar", true).toBool());
+ QAction *pref_action = new QAction(tr("Preferences"), this);
+ QAction *about_action = new QAction(tr("About"), this);
+
+#ifdef Q_WS_MAEMO_5
+ menuBar()->addAction(connect_action);
+ menuBar()->addAction(disconnect_action);
+ menuBar()->addAction(show_toolbar);
+ menuBar()->addAction(pref_action);
+ menuBar()->addAction(about_action);
+#else
+ QMenu* session_menu = menuBar()->addMenu(tr("&Session"));
+ session_menu->addAction(connect_action);
+ session_menu->addAction(disconnect_action);
+ session_menu->addSeparator();
+ session_menu->addAction(pref_action);
+ session_menu->addSeparator();
+ session_menu->addAction(tr("&Quit"), this, SLOT(close()));
+
+ QMenu* view_menu = menuBar()->addMenu(tr("&View"));
+ view_menu->addAction(show_toolbar);
+
+ QMenu* help_menu = menuBar()->addMenu(tr("&Help"));
+ help_menu->addAction(about_action);
+#endif
+
+ connect(about_action, SIGNAL(triggered()),
+ this, SLOT(about()));
+ connect(pref_action, SIGNAL(triggered()),
+ this, SLOT(showPreferences()));
+ connect(connect_action, SIGNAL(triggered()),
+ this, SLOT(showConnectDialog()));
+ connect(disconnect_action, SIGNAL(triggered()),
+ this, SLOT(disconnectFromHost()));
+ connect(show_toolbar, SIGNAL(toggled(bool)),
+ toolbar, SLOT(setVisible(bool)));
+ connect(show_toolbar, SIGNAL(toggled(bool)),
+ this, SLOT(updateScreenSpaceDelayed()));
+#ifdef Q_WS_MAEMO_5
+ QDBusConnection::systemBus().connect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_DISPLAY_SIG,
+ this, SLOT(displayStateChanged(QString)));
+#endif
+
+ setCentralWidget(scroll_area);
+
+ connect(scroll_area, SIGNAL(fullscreenButtonClicked()),
+ this, SLOT(toggleFullscreen()));
+
+ grabZoomKeys(true);
+ reloadSettings();
+
+ if(url.isEmpty() and listen_port == 0) {
+ disconnect_action->setEnabled(false);
+ showConnectDialog();
+ } else {
+ connectToHost(url, quality, listen_port, view_only);
+ }