update URL in about dialog
[presencevnc] / src / mainwindow.cpp
index e62ae7a..e042805 100644 (file)
 #endif
 
 
-MainWindow::MainWindow(QString url, int quality):
+MainWindow::MainWindow(QString url, int quality, bool view_only):
        QMainWindow(0),
        vnc_view(0),
        scroll_area(new ScrollArea(0)),
+       input_toolbuttons(new QActionGroup(this)),
        key_menu(new KeyMenu(this))
 {
        setWindowTitle("Presence VNC");
-       setContextMenuPolicy(Qt::NoContextMenu);
 #ifdef Q_WS_MAEMO_5
+       setContextMenuPolicy(Qt::NoContextMenu);
        setAttribute(Qt::WA_Maemo5StackedWindow);
 #endif
 
@@ -49,14 +50,14 @@ MainWindow::MainWindow(QString url, int quality):
 
        //set up toolbar
        toolbar = new QToolBar(0);
-       toolbar->addAction(QChar(0x2026), this, SLOT(showKeyMenu())); //"..." button
-       toolbar->addAction(tr("Tab"), this, SLOT(sendTab()));
-       toolbar->addAction(tr("Esc"), this, SLOT(sendEsc()));
-       toolbar->addAction(tr("PgUp"), this, SLOT(sendPgUp()));
-       toolbar->addAction(tr("PgDn"), this, SLOT(sendPgDn()));
+       input_toolbuttons->addAction(toolbar->addAction(QChar(0x2026), this, SLOT(showKeyMenu()))); //"..." button
+       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
-       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()));
+       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;
@@ -77,7 +78,7 @@ MainWindow::MainWindow(QString url, int quality):
        //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 = 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);
@@ -127,7 +128,7 @@ MainWindow::MainWindow(QString url, int quality):
        grabZoomKeys(true);
        reloadSettings();
 
-       if(url.isNull()) {
+       if(url.isEmpty()) {
                disconnect_action->setEnabled(false);
                showConnectDialog();
        } else {
@@ -135,6 +136,7 @@ MainWindow::MainWindow(QString url, int quality):
                connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
                        this, SLOT(statusChanged(RemoteView::RemoteStatus)));
                scroll_area->setWidget(vnc_view);
+               vnc_view->setViewOnly(view_only);
                vnc_view->start();
        }
 }
@@ -170,7 +172,7 @@ void MainWindow::about() {
        QMessageBox::about(this, tr("About Presence VNC"),
                tr("<center><h1>Presence VNC 0.8</h1>\
 <p>A touchscreen friendly VNC client</p>\
-<p><a href=\"https://garage.maemo.org/projects/presencevnc/\">https://garage.maemo.org/projects/presencevnc</a></p></center>\
+<p><a href=\"http://presencevnc.garage.maemo.org/\">http://presencevnc.garage.maemo.org/</a></p></center>\
 <small><p>&copy;2010 Christian Pulvermacher &lt;pulvermacher@gmx.de&gt;<br />\
 Based on KRDC, &copy; 2007-2008 Urs Wolfer<br />\
 and LibVNCServer, &copy; 2001-2003 Johannes E. Schindelin</p>\
@@ -180,16 +182,17 @@ and LibVNCServer, &copy; 2001-2003 Johannes E. Schindelin</p>\
 void MainWindow::showConnectDialog()
 {
        ConnectDialog *connect_dialog = new ConnectDialog(this);
-       connect(connect_dialog, SIGNAL(connectToHost(QString, int, int)),
-               this, SLOT(connectToHost(QString, int, int)));
+       connect(connect_dialog, SIGNAL(connectToHost(QString, int, int, bool)),
+               this, SLOT(connectToHost(QString, int, int, bool)));
        connect_dialog->exec();
 }
 
-void MainWindow::connectToHost(QString url, int quality, int listen_port)
+void MainWindow::connectToHost(QString url, int quality, int listen_port, bool view_only)
 {
        disconnectFromHost();
 
        vnc_view = new VncView(this, url, RemoteView::Quality(quality), listen_port);
+       vnc_view->setViewOnly(view_only);
 
        connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
                this, SLOT(statusChanged(RemoteView::RemoteStatus)));
@@ -232,6 +235,9 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status)
 #endif
                toolbar->setEnabled(true);
 
+               //disable key input buttons in view only mode
+               input_toolbuttons->setEnabled(!vnc_view->viewOnly());
+
                vnc_view->setZoomLevel(zoom_slider->value());
                vnc_view->useFastTransformations(false);
                vnc_view->repaint();