From 1397abfc77577ddfc513f4d688f36bbfcb4f8a0a Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 12 Aug 2010 19:27:58 +0200 Subject: [PATCH] add return key to toolbar as input method is broken --- src/mainwindow.cpp | 3 ++- src/mainwindow.h | 1 + src/vncview.cpp | 20 +++++++++++++++----- src/vncview.h | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f660963..ad7b284 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -48,7 +48,8 @@ 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("IM", this, SLOT(showInputPanel())); + toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/chat_enter.png"), "", this, SLOT(sendReturn())); + toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/control_keyboard.png"), "", this, SLOT(showInputPanel())); toolbar->addAction(QIcon("/usr/share/icons/hicolor/48x48/hildon/general_fullsize.png"), "", this, SLOT(toggleFullscreen())); addToolBar(toolbar); toolbar->setVisible(settings.value("show_toolbar", true).toBool()); diff --git a/src/mainwindow.h b/src/mainwindow.h index f5aaddc..fcdab29 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -38,6 +38,7 @@ public slots: 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 sendReturn() { vnc_view->sendKey(Qt::Key_Return); } void showInputPanel(); void showModifierMenu(); void showPreferences(); diff --git a/src/vncview.cpp b/src/vncview.cpp index 72e87cf..591fb0f 100644 --- a/src/vncview.cpp +++ b/src/vncview.cpp @@ -75,6 +75,7 @@ VncView::VncView(QWidget *parent, const KUrl &url, RemoteView::Quality quality) connect(m_clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); reloadSettings(); + } VncView::~VncView() @@ -550,8 +551,9 @@ void VncView::wheelEventHandler(QWheelEvent *event) void VncView::keyEventHandler(QKeyEvent *e) { // strip away autorepeating KeyRelease; see bug #206598 - if (e->isAutoRepeat() && (e->type() == QEvent::KeyRelease)) + if (e->isAutoRepeat() && (e->type() == QEvent::KeyRelease)) { return; + } // parts of this code are based on http://italc.sourcearchive.com/documentation/1.0.9.1/vncview_8cpp-source.html rfbKeySym k = e->nativeVirtualKey(); @@ -581,9 +583,10 @@ void VncView::keyEventHandler(QKeyEvent *e) current_zoom = left_zoom; else if(e->key() == Qt::Key_F7) current_zoom = right_zoom; - else if (k) + else if (k) { + // kDebug(5011) << "got '" << e->text() << "'."; vncThread.keyEvent(k, pressed); - else { + } else { kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed."; return; } @@ -683,6 +686,9 @@ void VncView::sendKey(Qt::Key key) case Qt::Key_PageDown: k = 0xff56; break; + case Qt::Key_Return: + k = 0xff0d; + break; case Qt::Key_Meta: //TODO: test this. k = XK_Super_L; break; @@ -690,7 +696,7 @@ void VncView::sendKey(Qt::Key key) k = XK_Alt_L; break; default: - kDebug(5011) << "unhandled Qt::Key value " << key; + kDebug(5011) << "sendKey(): Unhandled Qt::Key value " << key; return; } @@ -721,7 +727,9 @@ void VncView::inputMethodEvent(QInputMethodEvent *event) { //TODO handle replacements //TODO convert utf8 to X11 keysyms myself, should work with umlauts, kana... - //TODO Enter? + //NOTE for the return key to work Qt needs to enable multiline input, which only works for Q(Plain)TextEdit + + //kDebug(5011) << event->commitString() << "|" << event->preeditString() << "|" << event->replacementLength() << "|" << event->replacementStart(); QString letters = event->commitString(); for(int i = 0; i < letters.length(); i++) { char k = letters.at(i).toLatin1(); //works with all 'normal' keys, not umlauts. @@ -729,9 +737,11 @@ void VncView::inputMethodEvent(QInputMethodEvent *event) kDebug(5011) << "unhandled key"; continue; } + kDebug(5011) << "key: " << int(k); vncThread.keyEvent(k, true); vncThread.keyEvent(k, false); } } + #include "moc_vncview.cpp" diff --git a/src/vncview.h b/src/vncview.h index c1c00c6..e8d2ebb 100644 --- a/src/vncview.h +++ b/src/vncview.h @@ -30,6 +30,7 @@ class KConfigGroup{}; #include +#include extern "C" { #include -- 1.7.9.5