From: christian Date: Tue, 13 Jul 2010 14:28:58 +0000 (+0200) Subject: resize vnc_view when available space changes, rotation still missing X-Git-Tag: 0.6~88 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=3cce5bc4f6618a27c4cc4014411c72047993b21a;p=presencevnc resize vnc_view when available space changes, rotation still missing --- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5e4529f..27471fe 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -15,7 +15,7 @@ MainWindow::MainWindow(QString url, int quality): 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 @@ -25,7 +25,7 @@ MainWindow::MainWindow(QString url, int quality): 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 @@ -56,6 +56,8 @@ MainWindow::MainWindow(QString url, int quality): 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); @@ -71,6 +73,8 @@ MainWindow::MainWindow(QString url, int quality): 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); @@ -149,6 +153,8 @@ void MainWindow::connectDialog() 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(); @@ -196,3 +202,23 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status) 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(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index daa6896..588feb5 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -11,10 +11,17 @@ class MainWindow : public QMainWindow { 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*); @@ -24,15 +31,8 @@ private: 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