scroll_area(new QScrollArea(0))
{
setWindowTitle("Presence VNC");
- swipe_start = QPoint(0,0);
+// swipe_start = QPoint(0,0);
setAttribute(Qt::WA_Maemo5StackedWindow);
//set up toolbar
toolbar->addAction("Esc", this, SLOT(sendEsc()));
toolbar->addAction("PgUp", this, SLOT(sendPgUp()));
toolbar->addAction("PgDn", this, SLOT(sendPgDn()));
- toolbar->addAction("Fullscreen", this, SLOT(toggleFullscreen()));
+ toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png"), "", this, SLOT(toggleFullscreen()));
addToolBar(toolbar);
//set up menu
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);
vnc_view = new VncView(0, url, RemoteView::Quality(quality));
connect(scaling, SIGNAL(toggled(bool)),
vnc_view, SLOT(enableScaling(bool)));
+ connect(scaling, SIGNAL(toggled(bool)),
+ scroll_area, SLOT(setWidgetResizable(bool)));
connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
this, SLOT(statusChanged(RemoteView::RemoteStatus)));
scroll_area->setWidget(vnc_view);
connect(scaling, SIGNAL(toggled(bool)),
vnc_view, SLOT(enableScaling(bool)));
+ connect(scaling, SIGNAL(toggled(bool)),
+ scroll_area, SLOT(setWidgetResizable(bool)));
connect(vnc_view, SIGNAL(statusChanged(RemoteView::RemoteStatus)),
this, SLOT(statusChanged(RemoteView::RemoteStatus)));
vnc_view->start();
old_status = status;
}
+
+//when rescaling is enabled, this resizes the widget to use available screen space
+//necessary when rotating, showing fullscreen, etc.
+void MainWindow::forceResize()
+{
+ if(vnc_view and scaling->isChecked()) {
+ vnc_view->resize(scroll_area->size());
+ }
+}
+
+void MainWindow::forceResizeDelayed()
+{
+ QTimer::singleShot(500, this, SLOT(forceResize()));
+}
+
+void MainWindow::toggleFullscreen()
+{
+ setWindowState(windowState() ^ Qt::WindowFullScreen);
+ forceResizeDelayed();
+}
public:
MainWindow(QString url, int quality);
public slots:
+ void about();
void connectDialog();
void disconnectFromHost();
- void about();
+ void forceResize();
+ void forceResizeDelayed();
+ void sendTab() { vnc_view->sendKey(Qt::Key_Tab); }
+ void sendEsc() { vnc_view->sendKey(Qt::Key_Escape); }
+ void sendPgUp() { vnc_view->sendKey(Qt::Key_PageUp); }
+ void sendPgDn() { vnc_view->sendKey(Qt::Key_PageDown); }
void statusChanged(RemoteView::RemoteStatus status);
+ void toggleFullscreen();
protected:
//virtual bool event(QEvent *event);
void closeEvent(QCloseEvent*);
QScrollArea *scroll_area;
//QWidget *menu;
QToolBar *toolbar;
- QPoint swipe_start;
+ //QPoint swipe_start;
QAction *scaling;
QAction *disconnect_action;
-
-private slots:
- void sendTab() { vnc_view->sendKey(Qt::Key_Tab); }
- void sendEsc() { vnc_view->sendKey(Qt::Key_Escape); }
- void sendPgUp() { vnc_view->sendKey(Qt::Key_PageUp); }
- void sendPgDn() { vnc_view->sendKey(Qt::Key_PageDown); }
- void toggleFullscreen() { setWindowState(windowState() ^ Qt::WindowFullScreen); }
};
#endif