From f238da62b6d98097e193c1539611beed34ab0ba3 Mon Sep 17 00:00:00 2001 From: Christian Pulvermacher Date: Wed, 1 Feb 2012 22:44:12 +0100 Subject: [PATCH] Show more detailed error messages --- debian/changelog | 1 + src/mainwindow.cpp | 2 ++ src/scrollarea.h | 10 ++++++++-- src/vncclientthread.cpp | 18 ++++++------------ src/vncview.cpp | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/debian/changelog b/debian/changelog index 00b73bd..f0c2ade 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ presencevnc (0.8) unstable; urgency=low * Add --viewonly, --listen and --help command line options * Use less CPU when display is off * Improve performance of partial repaints, scrolling more fluent + * Show more detailed error messages in UI -- Christian Pulvermacher Thu, 28 Oct 2010 19:48:01 +0200 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5eb80dd..86970c6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -207,6 +207,8 @@ void MainWindow::connectToHost(QString url, int quality, int listen_port, bool v 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]"):"")); diff --git a/src/scrollarea.h b/src/scrollarea.h index 6e525f1..fa59830 100644 --- a/src/scrollarea.h +++ b/src/scrollarea.h @@ -26,10 +26,12 @@ //fixes tearing during scrolling and can display messages class ScrollArea : public QScrollArea { + Q_OBJECT public: explicit ScrollArea(QWidget *parent): - QScrollArea(parent) { - message.setParent(this); + QScrollArea(parent), + message(this) + { message.setVisible(false); message.setAlignment(Qt::AlignCenter); message.setWordWrap(true); @@ -54,11 +56,15 @@ public: #endif } +public slots: void showMessage(const QString &s) { message.setText(s); message.show(); message_timer.start(); } + + //provided for convenience + void showMessage(QString /*title*/, QString msg) { showMessage(msg); } protected: virtual void resizeEvent(QResizeEvent* ev) { QScrollArea::resizeEvent(ev); diff --git a/src/vncclientthread.cpp b/src/vncclientthread.cpp index 78f0971..a3f7bd9 100644 --- a/src/vncclientthread.cpp +++ b/src/vncclientthread.cpp @@ -146,20 +146,15 @@ void VncClientThread::outputHandler(const char *format, ...) if ((message.contains("Couldn't convert ")) || (message.contains("Unable to connect to VNC server"))) outputErrorMessageString = i18n("Server not found."); - - if ((message.contains("VNC connection failed: Authentication failed, too many tries")) || + else if ((message.contains("VNC connection failed: Authentication failed, too many tries")) || (message.contains("VNC connection failed: Too many authentication failures"))) outputErrorMessageString = i18n("VNC authentication failed because of too many authentication tries."); - - if (message.contains("VNC connection failed: Authentication failed")) + else if (message.contains("VNC connection failed: Authentication failed")) outputErrorMessageString = i18n("VNC authentication failed."); - - if (message.contains("VNC server closed connection")) + else if (message.contains("VNC server closed connection")) outputErrorMessageString = i18n("VNC server closed connection."); - - // internal messages, not displayed to user - if (message.contains("VNC server supports protocol version 3.889")) // see http://bugs.kde.org/162640 - outputErrorMessageString = "INTERNAL:APPLE_VNC_COMPATIBILTY"; + else if (message.contains("VNC server supports protocol version 3.889")) // see http://bugs.kde.org/162640 + outputErrorMessageString = "INTERNAL:APPLE_VNC_COMPATIBILTY"; // internal messages, not displayed to user } VncClientThread::VncClientThread(QObject *parent) @@ -191,12 +186,11 @@ VncClientThread::~VncClientThread() void VncClientThread::checkOutputErrorMessage() { if (!outputErrorMessageString.isEmpty()) { - kDebug(5011) << outputErrorMessageString; QString errorMessage = outputErrorMessageString; outputErrorMessageString.clear(); // show authentication failure error only after the 3rd unsuccessful try if ((errorMessage != i18n("VNC authentication failed.")) || m_passwordError) - outputErrorMessage(errorMessage); + emit outputErrorMessage(errorMessage); } } diff --git a/src/vncview.cpp b/src/vncview.cpp index 891950f..3885050 100644 --- a/src/vncview.cpp +++ b/src/vncview.cpp @@ -254,9 +254,9 @@ void VncView::outputErrorMessage(const QString &message) return; } - startQuitting(); - emit errorMessage(i18n("VNC failure"), message); + + startQuitting(); } void VncView::updateImage(int x, int y, int w, int h) -- 1.7.9.5