add return key to toolbar as input method is broken
authorchristian <christian@christian-laptop.(none)>
Thu, 12 Aug 2010 17:27:58 +0000 (19:27 +0200)
committerchristian <christian@christian-laptop.(none)>
Thu, 12 Aug 2010 17:27:58 +0000 (19:27 +0200)
src/mainwindow.cpp
src/mainwindow.h
src/vncview.cpp
src/vncview.h

index f660963..ad7b284 100644 (file)
@@ -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());
index f5aaddc..fcdab29 100644 (file)
@@ -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();
index 72e87cf..591fb0f 100644 (file)
@@ -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"
index c1c00c6..e8d2ebb 100644 (file)
@@ -30,6 +30,7 @@
 class KConfigGroup{};
 
 #include <QClipboard>
+#include <QTextEdit>
 
 extern "C" {
 #include <rfb/rfbclient.h>