QApplication app(argc, argv);
- QString url("");
+ QString url;
int quality = 2;
+ bool view_only = false;
QStringList arguments = QCoreApplication::arguments();
for(int i = 1; i < arguments.count(); i++) {
std::cout << "Usage: " << qPrintable(arguments.at(0)) << " [options] [URL [quality]]\n"
<< "\nOptions:\n"
- << " --help\t This text\n"
+ << " --help\t\t Print this text and exit.\n"
+ << " --viewonly\t Don't send mouse/keyboard input to remote desktop. This is only useful if you also supply a URL.\n"
<< "\nURLs:\n"
- << " vnc://:password@server:display\n"
+ << " vnc://:password@server:display\n\n"
<< " Password and display can be omitted, e.g. vnc://server is a valid URL.\n"
<< " Optionally, you can define the quality as a second argument (1-3, where 1 is the best). Default is 2.\n";
return 0;
+ } else if(arguments.at(i) == "--viewonly") {
+ view_only = true;
} else { //not a valid command line option, should be the url
url = arguments.at(i);
+
if(arguments.count() > i+1) { //having a --quality option would make more sense.
- quality = arguments.at(i+1).toInt();
- i++;
+ quality = arguments.at(i+1).toInt();
+ i++;
}
}
}
- MainWindow main(url, quality);
+ MainWindow main(url, quality, view_only);
main.show();
return app.exec();
}
#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
//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;
grabZoomKeys(true);
reloadSettings();
- if(url.isNull()) {
+ if(url.isEmpty()) {
disconnect_action->setEnabled(false);
showConnectDialog();
} else {
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();
}
}
#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();