51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "connectdialog.h"
-#include "fullscreenexitbutton.h"
#include "keymenu.h"
#include "mainwindow.h"
#include "preferences.h"
MainWindow::MainWindow(QString url, int quality, int listen_port, bool view_only):
QMainWindow(0),
vnc_view(0),
- scroll_area(new ScrollArea(0)),
+ scroll_area(new ScrollArea(this)),
input_toolbuttons(new QActionGroup(this)),
key_menu(0)
{
//set up toolbar
toolbar = new QToolBar(0);
- input_toolbuttons->addAction(toolbar->addAction(QChar(0x2026), this, SLOT(showKeyMenu()))); //"..." button
+ 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())));
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);
this, SLOT(updateScreenSpaceDelayed()));
#ifdef Q_WS_MAEMO_5
QDBusConnection::systemBus().connect("", MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_DISPLAY_SIG,
- this, SLOT(displayStateChanged(QString)));
+ this, SLOT(displayStateChanged(QString)));
#endif
setCentralWidget(scroll_area);
- FullScreenExitButton* fullscreen_exit_button = new FullScreenExitButton(this);
- connect(fullscreen_exit_button, SIGNAL(clicked()),
+ connect(scroll_area, SIGNAL(fullscreenButtonClicked()),
this, SLOT(toggleFullscreen()));
grabZoomKeys(true);
return;
}
XChangeProperty(QX11Info::display(), winId(), atom, XA_INTEGER,
- 32, PropModeReplace, reinterpret_cast<unsigned char *>(&val), 1);
+ 32, PropModeReplace, reinterpret_cast<unsigned char *>(&val), 1);
#endif
}
-void MainWindow::closeEvent(QCloseEvent*) {
+void MainWindow::closeEvent(QCloseEvent*)
+{
grabZoomKeys(false);
QSettings settings;
disconnectFromHost();
}
-void MainWindow::about() {
+void MainWindow::about()
+{
QMessageBox::about(this, tr("About Presence VNC"),
- tr("<center><h1>Presence VNC 0.8</h1>\
+ tr("<center><h1>Presence VNC 0.8</h1>\
<p>A touchscreen friendly VNC client</p>\
<p><a href=\"http://presencevnc.garage.maemo.org/\">http://presencevnc.garage.maemo.org/</a></p></center>\
<small><p>©2010 Christian Pulvermacher <pulvermacher@gmx.de><br />\
connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
this, SLOT(statusChanged(RemoteView::RemoteStatus)));
+ connect(vnc_view, SIGNAL(errorMessage(QString, QString)),
+ scroll_area, SLOT(showMessage(QString, QString)));
scroll_area->setWidget(vnc_view);
vnc_view->start();
+ setWindowTitle(QString("Presence VNC - %1").arg(vnc_view->host()) + (view_only?tr(" [View Only]"):""));
disconnect_action->setEnabled(true);
if(!vnc_view)
return;
+ setWindowTitle("Presence VNC");
disconnect_action->setEnabled(false);
toolbar->setEnabled(false);
scroll_area->setWidget(0);
static RemoteView::RemoteStatus old_status = RemoteView::Disconnected;
switch(status) {
- case RemoteView::Connecting:
+ case RemoteView::Connecting:
#ifdef Q_WS_MAEMO_5
- setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
#endif
- break;
- case RemoteView::Connected:
+ break;
+ case RemoteView::Connected:
#ifdef Q_WS_MAEMO_5
- setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
#endif
- toolbar->setEnabled(true);
+ toolbar->setEnabled(true);
- //disable key input buttons in view only mode
- input_toolbuttons->setEnabled(!vnc_view->viewOnly());
+ //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();
- break;
- case RemoteView::Disconnecting:
- if(old_status == RemoteView::Disconnected) //Disconnecting also occurs while connecting, so check last state
- break;
-
- if(disconnect_action->isEnabled()) //don't show when manually disconnecting
- scroll_area->showMessage(tr("Connection lost"));
-
- //clean up
- scroll_area->setWidget(0);
- vnc_view = 0;
- disconnect_action->setEnabled(false);
- toolbar->setEnabled(false);
-
- //exit fullscreen mode
- if(windowState() & Qt::WindowFullScreen)
- setWindowState(windowState() ^ Qt::WindowFullScreen);
+ vnc_view->setZoomLevel(zoom_slider->value());
+ vnc_view->useFastTransformations(false);
+ vnc_view->update();
+ break;
+ case RemoteView::Disconnecting:
+ if(old_status == RemoteView::Disconnected) //Disconnecting also occurs while connecting, so check last state
break;
- case RemoteView::Disconnected:
+
+ if(disconnect_action->isEnabled()) //don't show when manually disconnecting
+ scroll_area->showMessage(tr("Connection lost"));
+
+ //clean up
+ scroll_area->setWidget(0);
+ vnc_view = 0;
+ setWindowTitle("Presence VNC");
+ disconnect_action->setEnabled(false);
+ toolbar->setEnabled(false);
+
+ //exit fullscreen mode
+ if(windowState() & Qt::WindowFullScreen)
+ setWindowState(windowState() ^ Qt::WindowFullScreen);
+ break;
+ case RemoteView::Disconnected:
#ifdef Q_WS_MAEMO_5
- setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
#endif
- if(old_status == RemoteView::Disconnecting) {
- scroll_area->setWidget(0); //remove widget
- }
- break;
- default: //avoid compiler warnings
- break;
+ if(old_status == RemoteView::Disconnecting) {
+ scroll_area->setWidget(0); //remove widget
+ }
+ break;
+ default: //avoid compiler warnings
+ break;
}
old_status = status;
if(vnc_view) {
vnc_view->setZoomLevel();
}
-}
+}
void MainWindow::updateScreenSpaceDelayed()
{
menuBar()->setVisible(in_fullscreen);
#endif
- setWindowState(windowState() ^ Qt::WindowFullScreen);
+ setWindowState(windowState() ^ Qt::WindowFullScreen);
updateScreenSpaceDelayed();
}
{
key_menu->exec();
vnc_view->sendKeySequence(key_menu->getKeySequence());
+ key_menu_button->setChecked(key_menu->isAltChecked() or key_menu->isWinChecked());
}
void MainWindow::showPreferences()
center = center * (double(new_factor)/old_factor);
scroll_area->ensureVisible(center.x(), center.y(),
- vnc_view->visibleRegion().boundingRect().width()/2,
- vnc_view->visibleRegion().boundingRect().height()/2);
+ vnc_view->visibleRegion().boundingRect().width()/2,
+ vnc_view->visibleRegion().boundingRect().height()/2);
vnc_view->useFastTransformations(zoom_slider->isSliderDown());
vnc_view->update();