From: Christian Pulvermacher Date: Sun, 24 Oct 2010 11:32:08 +0000 (+0200) Subject: use own message display instead of QMaemo5InformationBox X-Git-Tag: 0.7~23 X-Git-Url: https://vcs.maemo.org/git/?p=presencevnc;a=commitdiff_plain;h=7c397d50a78cb949a55c072cd47f22dfa569632c use own message display instead of QMaemo5InformationBox --- diff --git a/debian/changelog b/debian/changelog index 7c1105d..e2a6c3a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ presencevnc (0.7) unstable; urgency=low - * ... + * Show current magnification when zooming -- Christian Pulvermacher Sat, 23 Oct 2010 18:32:50 +0200 diff --git a/debian/rules b/debian/rules index 25b70af..90f5757 100755 --- a/debian/rules +++ b/debian/rules @@ -5,7 +5,7 @@ export DH_VERBOSE=1 #currently builds a maemo-only package #comment this line for quick builds -buildlibs=foo +#buildlibs=foo SOURCEDIR=./ BUILDDIR=debian/build/ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fe39fbc..555326a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -21,6 +21,7 @@ #include "keymenu.h" #include "mainwindow.h" #include "preferences.h" +#include "scrollarea.h" #include "vncview.h" #ifdef Q_WS_MAEMO_5 @@ -58,13 +59,6 @@ MainWindow::MainWindow(QString url, int quality): toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/control_keyboard.png"), "", this, SLOT(showInputPanel())); #endif - /* - //move remaining buttons to the right - QWidget *spacer = new QWidget(); - spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - toolbar->addWidget(spacer); - */ - QSettings settings; zoom_slider = new QSlider(Qt::Horizontal, 0); zoom_slider->setRange(0, 100); @@ -239,22 +233,21 @@ void MainWindow::statusChanged(RemoteView::RemoteStatus status) vnc_view->forceFullRepaint(); break; case RemoteView::Disconnecting: - if(old_status != RemoteView::Disconnected) { //Disconnecting also occurs while connecting, so check last state -#ifdef Q_WS_MAEMO_5 - if(disconnect_action->isEnabled()) //don't show when manually disconnecting - QMaemo5InformationBox::information(this, tr("Connection lost")); -#endif - - //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); - } + 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); break; case RemoteView::Disconnected: #ifdef Q_WS_MAEMO_5 @@ -367,6 +360,7 @@ void MainWindow::setZoomLevel(int level) if(!vnc_view) return; + //TODO: use getZoomFactor() instead int old_width = vnc_view->width(); QPoint center = vnc_view->visibleRegion().boundingRect().center(); @@ -382,8 +376,6 @@ void MainWindow::setZoomLevel(int level) vnc_view->visibleRegion().boundingRect().height()/2); vnc_view->update(); -#ifdef Q_WS_MAEMO_5 - QMaemo5InformationBox::information(this, tr("%1\%").arg(qRound(100*vnc_view->getZoomFactor()))); -#endif + scroll_area->showMessage(tr("Zoom: %1\%").arg(qRound(100*vnc_view->getZoomFactor()))); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 17b3299..0aa0792 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,20 +25,7 @@ #include class KeyMenu; - -//fix tearing during scrolling -class ScrollArea : public QScrollArea { -public: - ScrollArea(QWidget *parent) : QScrollArea(parent) { } -protected: - virtual void scrollContentsBy(int dx, int dy) - { - QScrollArea::scrollContentsBy(dx, dy); - if(widget()) - widget()->update(); //update whole widget - } -}; - +class ScrollArea; class MainWindow : public QMainWindow { Q_OBJECT @@ -57,7 +44,7 @@ public slots: void sendPgUp() { vnc_view->sendKey(Qt::Key_PageUp); } void sendPgDn() { vnc_view->sendKey(Qt::Key_PageDown); } void sendReturn() { vnc_view->sendKey(Qt::Key_Return); } - void setZoomLevel(int level); + void setZoomLevel(int level); void showInputPanel(); void showKeyMenu(); void showPreferences(); diff --git a/src/scrollarea.h b/src/scrollarea.h new file mode 100644 index 0000000..19a18a1 --- /dev/null +++ b/src/scrollarea.h @@ -0,0 +1,72 @@ +/* + Presence VNC + Copyright (C) 2010 Christian Pulvermacher + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#ifndef SCROLLAREA_H +#define SCROLLAREA_H + +#include +#include +#include + +//fixes tearing during scrolling and can display messages +class ScrollArea : public QScrollArea { +public: + ScrollArea(QWidget *parent): + QScrollArea(parent) + { + message.setParent(this); + message.setVisible(false); + message.setAlignment(Qt::AlignCenter); + message.setWordWrap(true); + + QPalette pal = message.palette(); + QColor backgroundColor = pal.color(backgroundRole()); + backgroundColor.setAlpha(128); + pal.setColor(backgroundRole(), backgroundColor); + message.setPalette(pal); + message.setAutoFillBackground(true); + + timer.setSingleShot(true); + timer.setInterval(2500); + connect(&timer, SIGNAL(timeout()), + &message, SLOT(hide())); + } + + void showMessage(const QString &s) + { + message.setText(s); + message.show(); + timer.start(); + } +protected: + virtual void resizeEvent(QResizeEvent* ev) + { + QScrollArea::resizeEvent(ev); + message.setFixedWidth(width()); + } + virtual void scrollContentsBy(int dx, int dy) + { + QScrollArea::scrollContentsBy(dx, dy); + if(widget()) + widget()->update(); //update whole widget + } +private: + QLabel message; + QTimer timer; +}; +#endif diff --git a/vnc.pro b/vnc.pro index 9a46c17..ed6eb25 100644 --- a/vnc.pro +++ b/vnc.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = presencevnc-bin LIBS += -Llibvnc/libvncclient/.libs -lvncclient DEFINES += QTONLY -CONFIG += silent clean +CONFIG += silent debug maemo5 { QT += maemo5 @@ -13,5 +13,5 @@ MOC_DIR = $${PWD}/tmp VPATH = $${PWD}/src INCLUDEPATH = $${PWD}/src $${PWD}/libvnc -HEADERS += remoteview.h vncclientthread.h vncview.h mainwindow.h preferences.h connectdialog.h fullscreenexitbutton.h keymenu.h +HEADERS += remoteview.h vncclientthread.h vncview.h mainwindow.h preferences.h connectdialog.h fullscreenexitbutton.h keymenu.h scrollarea.h SOURCES += main.cpp remoteview.cpp vncclientthread.cpp vncview.cpp mainwindow.cpp preferences.cpp connectdialog.cpp keymenu.cpp