1 /****************************************************************************
3 ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org>
5 ** This file is part of KDE.
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
22 ****************************************************************************/
26 #include <QMessageBox>
27 #include <QInputDialog>
28 #define KMessageBox QMessageBox
29 #define error(parent, message, caption) \
30 critical(parent, caption, message)
32 #include <QApplication>
37 #include <QHBoxLayout>
38 #include <QVBoxLayout>
40 #include <QMouseEvent>
41 #include <QPushButton>
48 // Definition of key modifier mask constants
49 #define KMOD_Alt_R 0x01
50 #define KMOD_Alt_L 0x02
51 #define KMOD_Meta_L 0x04
52 #define KMOD_Control_L 0x08
53 #define KMOD_Shift_L 0x10
55 VncView::VncView(QWidget *parent, const KUrl &url, RemoteView::Quality quality)
63 m_firstPasswordTry(true),
64 m_dontSendClipboard(false),
65 m_horizontalFactor(1.0),
66 m_verticalFactor(1.0),
67 m_forceLocalCursor(false),
68 force_full_repaint(false),
75 connect(&vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)), Qt::BlockingQueuedConnection);
76 connect(&vncThread, SIGNAL(gotCut(const QString&)), this, SLOT(setCut(const QString&)), Qt::BlockingQueuedConnection);
77 connect(&vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()), Qt::BlockingQueuedConnection);
78 connect(&vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString)));
80 m_clipboard = QApplication::clipboard();
81 connect(m_clipboard, SIGNAL(selectionChanged()), this, SLOT(clipboardSelectionChanged()));
82 connect(m_clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
91 // Disconnect all signals so that we don't get any more callbacks from the client thread
92 vncThread.disconnect();
97 void VncView::forceFullRepaint()
99 force_full_repaint = true;
103 bool VncView::eventFilter(QObject *obj, QEvent *event)
106 if (event->type() == QEvent::KeyPress ||
107 event->type() == QEvent::KeyRelease ||
108 event->type() == QEvent::MouseButtonDblClick ||
109 event->type() == QEvent::MouseButtonPress ||
110 event->type() == QEvent::MouseButtonRelease ||
111 event->type() == QEvent::Wheel ||
112 event->type() == QEvent::MouseMove)
115 return RemoteView::eventFilter(obj, event);
118 QSize VncView::framebufferSize()
120 return m_frame.size();
123 QSize VncView::sizeHint() const
128 QSize VncView::minimumSizeHint() const
133 void VncView::scaleResize(int w, int h)
135 RemoteView::scaleResize(w, h);
137 kDebug(5011) << "scaleResize(): " <<w << h;
139 m_verticalFactor = (qreal) h / m_frame.height();
140 m_horizontalFactor = (qreal) w / m_frame.width();
142 m_verticalFactor = m_horizontalFactor = qMin(m_verticalFactor, m_horizontalFactor);
144 const qreal newW = m_frame.width() * m_horizontalFactor;
145 const qreal newH = m_frame.height() * m_verticalFactor;
147 setMaximumSize(newW, newH); //This is a hack to force Qt to center the view in the scroll area
148 //also causes the widget's size to flicker
155 void VncView::startQuitting()
157 kDebug(5011) << "about to quit";
159 const bool connected = status() == RemoteView::Connected;
161 setStatus(Disconnecting);
171 const bool quitSuccess = vncThread.wait(500);
173 kDebug(5011) << "startQuitting(): Quit VNC thread success:" << quitSuccess;
175 setStatus(Disconnected);
178 bool VncView::isQuitting()
183 bool VncView::start()
185 vncThread.setHost(m_host);
186 vncThread.setPort(m_port);
188 vncThread.setQuality(quality);
190 // set local cursor on by default because low quality mostly means slow internet connection
191 if (quality == RemoteView::Low) {
192 showDotCursor(RemoteView::CursorOn);
195 setStatus(Connecting);
201 bool VncView::supportsScaling() const
206 bool VncView::supportsLocalCursor() const
211 void VncView::requestPassword()
213 kDebug(5011) << "request password";
215 setStatus(Authenticating);
217 if (!m_url.password().isNull()) {
218 vncThread.setPassword(m_url.password());
223 settings.beginGroup("hosts");
224 QString password = settings.value(QString("%1/password").arg(m_host), "").toString();
225 //check for saved password
226 if(m_firstPasswordTry and !password.isEmpty()) {
227 kDebug(5011) << "Trying saved password";
228 m_firstPasswordTry = false;
229 vncThread.setPassword(password);
232 m_firstPasswordTry = false;
235 QDialog dialog(this);
236 dialog.setWindowTitle(tr("Password required"));
238 QLineEdit passwordbox;
239 passwordbox.setEchoMode(QLineEdit::Password);
240 passwordbox.setText(password);
241 QCheckBox save_password(tr("Save Password"));
242 save_password.setChecked(!password.isEmpty()); //offer to overwrite saved password
243 QPushButton ok_button(tr("Done"));
244 ok_button.setMaximumWidth(100);
245 connect(&ok_button, SIGNAL(clicked()),
246 &dialog, SLOT(accept()));
250 layout2.addWidget(&passwordbox);
251 layout2.addWidget(&save_password);
252 layout1.addLayout(&layout2);
253 layout1.addWidget(&ok_button);
254 dialog.setLayout(&layout1);
256 if(dialog.exec()) { //dialog accepted
257 password = passwordbox.text();
259 if(save_password.isChecked()) {
260 kDebug(5011) << "Saving password for host '" << m_host << "'";
262 settings.setValue(QString("%1/password").arg(m_host), password);
266 vncThread.setPassword(password);
272 void VncView::outputErrorMessage(const QString &message)
274 kDebug(5011) << message;
276 if (message == "INTERNAL:APPLE_VNC_COMPATIBILTY") {
277 setCursor(localDotCursor());
278 m_forceLocalCursor = true;
284 emit errorMessage(i18n("VNC failure"), message);
287 void VncView::updateImage(int x, int y, int w, int h)
289 if(!QApplication::focusWidget()) { //no focus, we're probably minimized
292 //kDebug(5011) << "got update" << width() << height();
295 static unsigned int frames = 0;
296 static unsigned int updates = 0;
297 static QTime time = QTime::currentTime();
299 if(updates % 100 == 0)
300 kDebug(5011) << "u/s: " << updates/double(time.elapsed()) * 1000.0;
301 if(x == 0 and y == 0) {
303 if(frames % 100 == 0)
304 kDebug(5011) << "f/s: " << frames/double(time.elapsed()) * 1000.0;
313 if (m_horizontalFactor != 1.0 || m_verticalFactor != 1.0) {
314 // If the view is scaled, grow the update rectangle to avoid artifacts
315 int x_extrapixels = 1.0/m_horizontalFactor+1;
316 int y_extrapixels = 1.0/m_verticalFactor+1;
320 m_w+=2*x_extrapixels;
321 m_h+=2*y_extrapixels;
324 m_frame = vncThread.image();
327 setAttribute(Qt::WA_StaticContents);
328 setAttribute(Qt::WA_OpaquePaintEvent);
329 installEventFilter(this);
331 setCursor(((m_dotCursorState == CursorOn) || m_forceLocalCursor) ? localDotCursor() : Qt::BlankCursor);
333 setMouseTracking(true); // get mouse events even when there is no mousebutton pressed
334 setFocusPolicy(Qt::WheelFocus);
335 setStatus(Connected);
336 // emit framebufferSizeChanged(m_frame.width(), m_frame.height());
341 scaleResize(parentWidget()->width(), parentWidget()->height());
343 scaleResize(width(), height());
350 static QSize old_frame_size = QSize();
351 if ((y == 0 && x == 0) && (m_frame.size() != old_frame_size)) {
352 old_frame_size = m_frame.size();
353 kDebug(5011) << "Updating framebuffer size";
355 //setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
357 scaleResize(parentWidget()->width(), parentWidget()->height());
359 kDebug(5011) << "Resizing: " << m_frame.width() << m_frame.height();
360 resize(m_frame.width(), m_frame.height());
361 //setMaximumSize(m_frame.width(), m_frame.height()); //This is a hack to force Qt to center the view in the scroll area
362 //setMinimumSize(m_frame.width(), m_frame.height());
364 emit framebufferSizeChanged(m_frame.width(), m_frame.height());
368 repaint(qRound(m_x * m_horizontalFactor), qRound(m_y * m_verticalFactor), qRound(m_w * m_horizontalFactor), qRound(m_h * m_verticalFactor));
372 void VncView::setViewOnly(bool viewOnly)
374 RemoteView::setViewOnly(viewOnly);
376 m_dontSendClipboard = viewOnly;
379 setCursor(Qt::ArrowCursor);
381 setCursor(m_dotCursorState == CursorOn ? localDotCursor() : Qt::BlankCursor);
384 void VncView::showDotCursor(DotCursorState state)
386 RemoteView::showDotCursor(state);
388 setCursor(state == CursorOn ? localDotCursor() : Qt::BlankCursor);
391 void VncView::enableScaling(bool scale)
393 RemoteView::enableScaling(scale);
396 //setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
397 //setMinimumSize(1, 1);
399 scaleResize(parentWidget()->width(), parentWidget()->height());
401 scaleResize(width(), height());
403 m_verticalFactor = 1.0;
404 m_horizontalFactor = 1.0;
406 //setMaximumSize(m_frame.width(), m_frame.height()); //This is a hack to force Qt to center the view in the scroll area
407 //setMinimumSize(m_frame.width(), m_frame.height());
408 resize(m_frame.width(), m_frame.height());
412 void VncView::setCut(const QString &text)
414 m_dontSendClipboard = true;
415 m_clipboard->setText(text, QClipboard::Clipboard);
416 m_clipboard->setText(text, QClipboard::Selection);
417 m_dontSendClipboard = false;
420 void VncView::paintEvent(QPaintEvent *event)
422 //kDebug(5011) << "paint event: x: " << m_x << ", y: " << m_y << ", w: " << m_w << ", h: " << m_h;
423 if (m_frame.isNull() || m_frame.format() == QImage::Format_Invalid) {
424 kDebug(5011) << "no valid image to paint";
425 RemoteView::paintEvent(event);
431 QPainter painter(this);
433 if (m_repaint and !force_full_repaint) {
434 // kDebug(5011) << "normal repaint";
435 painter.drawImage(QRect(qRound(m_x*m_horizontalFactor), qRound(m_y*m_verticalFactor),
436 qRound(m_w*m_horizontalFactor), qRound(m_h*m_verticalFactor)),
437 m_frame.copy(m_x, m_y, m_w, m_h).scaled(qRound(m_w*m_horizontalFactor),
438 qRound(m_h*m_verticalFactor),
439 Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
441 //kDebug(5011) << "resize repaint";
442 QRect rect = event->rect();
443 if (!force_full_repaint and (rect.width() != width() || rect.height() != height())) {
444 // kDebug(5011) << "Partial repaint";
445 const int sx = rect.x()/m_horizontalFactor;
446 const int sy = rect.y()/m_verticalFactor;
447 const int sw = rect.width()/m_horizontalFactor;
448 const int sh = rect.height()/m_verticalFactor;
449 painter.drawImage(rect,
450 m_frame.copy(sx, sy, sw, sh).scaled(rect.width(), rect.height(),
451 Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
453 kDebug(5011) << "Full repaint" << width() << height() << m_frame.width() << m_frame.height();
454 painter.drawImage(QRect(0, 0, width(), height()),
455 m_frame.scaled(m_frame.width() * m_horizontalFactor, m_frame.height() * m_verticalFactor,
456 Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
457 force_full_repaint = false;
461 //draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
462 if((m_dotCursorState == CursorOn) || m_forceLocalCursor) {
463 #if QT_VERSION >= 0x040500
464 painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
466 painter.drawRect(cursor_x*m_horizontalFactor - 2, cursor_y*m_verticalFactor - 2, 5, 5);
469 RemoteView::paintEvent(event);
472 void VncView::resizeEvent(QResizeEvent *event)
474 RemoteView::resizeEvent(event);
475 scaleResize(event->size().width(), event->size().height());
479 bool VncView::event(QEvent *event)
481 switch (event->type()) {
482 case QEvent::KeyPress:
483 case QEvent::KeyRelease:
484 // kDebug(5011) << "keyEvent";
485 keyEventHandler(static_cast<QKeyEvent*>(event));
488 case QEvent::MouseButtonDblClick:
489 case QEvent::MouseButtonPress:
490 case QEvent::MouseButtonRelease:
491 case QEvent::MouseMove:
492 // kDebug(5011) << "mouseEvent";
493 mouseEventHandler(static_cast<QMouseEvent*>(event));
497 // kDebug(5011) << "wheelEvent";
498 wheelEventHandler(static_cast<QWheelEvent*>(event));
501 case QEvent::WindowActivate: //input panel may have been closed, prevent IM from interfering with hardware keyboard
502 setAttribute(Qt::WA_InputMethodEnabled, false);
505 return RemoteView::event(event);
509 //call with e == 0 to flush held events
510 void VncView::mouseEventHandler(QMouseEvent *e)
512 static bool tap_detected = false;
513 static bool double_tap_detected = false;
514 static bool tap_drag_detected = false;
515 static QTime press_time;
516 static QTime up_time; //used for double clicks/tap&drag, for time after first tap
518 const int TAP_PRESS_TIME = 180;
519 const int DOUBLE_TAP_UP_TIME = 500;
521 if(!e) { //flush held taps
523 m_buttonMask |= 0x01;
524 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
525 m_buttonMask &= 0xfe;
526 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
527 tap_detected = false;
528 } else if(double_tap_detected and press_time.elapsed() > TAP_PRESS_TIME) { //got tap + another press -> tap & drag
529 m_buttonMask |= 0x01;
530 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
531 double_tap_detected = false;
532 tap_drag_detected = true;
538 if(e->x() < 0 or e->y() < 0) { //QScrollArea tends to send invalid events sometimes...
543 cursor_x = qRound(e->x()/m_horizontalFactor);
544 cursor_y = qRound(e->y()/m_verticalFactor);
545 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask); // plain move event
547 if(!disable_tapping and e->button() == Qt::LeftButton) { //implement touchpad-like input for left button
548 if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
550 if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
551 tap_detected = false;
552 double_tap_detected = true;
554 QTimer::singleShot(TAP_PRESS_TIME, this, SLOT(mouseEventHandler()));
556 } else if(e->type() == QEvent::MouseButtonRelease) {
557 if(tap_drag_detected) {
558 m_buttonMask &= 0xfe;
559 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
560 tap_drag_detected = false;
561 } else if(double_tap_detected) { //double click
562 double_tap_detected = false;
564 m_buttonMask |= 0x01;
565 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
566 m_buttonMask &= 0xfe;
567 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
568 m_buttonMask |= 0x01;
569 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
570 m_buttonMask &= 0xfe;
571 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
572 } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
575 QTimer::singleShot(DOUBLE_TAP_UP_TIME, this, SLOT(mouseEventHandler()));
579 } else { //middle or right button, send directly
580 if ((e->type() == QEvent::MouseButtonPress)) {
581 if (e->button() & Qt::MidButton)
582 m_buttonMask |= 0x02;
583 if (e->button() & Qt::RightButton)
584 m_buttonMask |= 0x04;
585 } else if (e->type() == QEvent::MouseButtonRelease) {
586 if (e->button() & Qt::MidButton)
587 m_buttonMask &= 0xfd;
588 if (e->button() & Qt::RightButton)
589 m_buttonMask &= 0xfb;
591 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
594 //prevent local cursor artifacts
595 static int old_cursor_x = cursor_x;
596 static int old_cursor_y = cursor_y;
597 if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
598 and (cursor_x != old_cursor_x or cursor_y != old_cursor_y)) {
599 //clear last position (plus a few extra pixels)
600 repaint(old_cursor_x*m_horizontalFactor - 3, old_cursor_y*m_verticalFactor - 3, 7, 7);
601 //and refresh new one
602 repaint(cursor_x*m_horizontalFactor - 3, cursor_y*m_verticalFactor - 3, 7, 7);
604 old_cursor_x = cursor_x; old_cursor_y = cursor_y;
608 void VncView::wheelEventHandler(QWheelEvent *event)
611 if (event->delta() < 0)
616 const int x = qRound(event->x() / m_horizontalFactor);
617 const int y = qRound(event->y() / m_verticalFactor);
619 vncThread.mouseEvent(x, y, eb | m_buttonMask);
620 vncThread.mouseEvent(x, y, m_buttonMask);
623 void VncView::keyEventHandler(QKeyEvent *e)
625 // strip away autorepeating KeyRelease; see bug #206598
626 if (e->isAutoRepeat() && (e->type() == QEvent::KeyRelease)) {
630 // parts of this code are based on http://italc.sourcearchive.com/documentation/1.0.9.1/vncview_8cpp-source.html
631 rfbKeySym k = e->nativeVirtualKey();
633 // we do not handle Key_Backtab separately as the Shift-modifier
634 // is already enabled
635 if (e->key() == Qt::Key_Backtab) {
639 const bool pressed = (e->type() == QEvent::KeyPress);
642 //don't send ISO_Level3_Shift (would break things like Win+0-9)
643 //also enable IM so symbol key works
645 setAttribute(Qt::WA_InputMethodEnabled, pressed);
652 if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L) {
655 } else if (m_mods.contains(k)) {
663 int current_zoom = -1;
664 if(e->key() == Qt::Key_F8)
665 current_zoom = left_zoom;
666 else if(e->key() == Qt::Key_F7)
667 current_zoom = right_zoom;
669 // kDebug(5011) << "got '" << e->text() << "'.";
670 vncThread.keyEvent(k, pressed);
672 kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed.";
676 if(current_zoom == -1)
679 //handle zoom buttons
680 if(current_zoom == 0) { //left click
682 m_buttonMask |= 0x01;
684 m_buttonMask &= 0xfe;
685 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
686 } else if(current_zoom == 1) { //right click
688 m_buttonMask |= 0x04;
690 m_buttonMask &= 0xfb;
691 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
692 } else if(current_zoom == 2) { //middle click
694 m_buttonMask |= 0x02;
696 m_buttonMask &= 0xfd;
697 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
698 } else if(current_zoom == 3 and pressed) { //wheel up
700 vncThread.mouseEvent(cursor_x, cursor_y, eb | m_buttonMask);
701 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
702 } else if(current_zoom == 4 and pressed) { //wheel down
704 vncThread.mouseEvent(cursor_x, cursor_y, eb | m_buttonMask);
705 vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
706 } else if(current_zoom == 5) { //page up
707 vncThread.keyEvent(0xff55, pressed);
708 } else if(current_zoom == 6) { //page down
709 vncThread.keyEvent(0xff56, pressed);
713 void VncView::unpressModifiers()
715 const QList<unsigned int> keys = m_mods.keys();
716 QList<unsigned int>::const_iterator it = keys.constBegin();
717 while (it != keys.end()) {
718 vncThread.keyEvent(*it, false);
724 void VncView::clipboardSelectionChanged()
726 if (m_status != Connected)
729 if (m_clipboard->ownsSelection() || m_dontSendClipboard)
732 const QString text = m_clipboard->text(QClipboard::Selection);
734 vncThread.clientCut(text);
737 void VncView::clipboardDataChanged()
739 if (m_status != Connected)
742 if (m_clipboard->ownsClipboard() || m_dontSendClipboard)
745 const QString text = m_clipboard->text(QClipboard::Clipboard);
747 vncThread.clientCut(text);
751 void VncView::sendKey(Qt::Key key)
753 //convert Qt::Key into x11 keysym
765 case Qt::Key_PageDown:
783 case Qt::Key_Backspace:
798 k = 0xffbe + int(key - Qt::Key_F1);
801 case Qt::MetaModifier:
805 case Qt::AltModifier:
808 case Qt::Key_Control:
809 case Qt::ControlModifier:
813 kDebug(5011) << "sendKey(): Unhandled Qt::Key value " << key;
817 if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L || k == XK_Super_L) {
818 if (m_mods.contains(k)) { //release
820 vncThread.keyEvent(k, false);
823 vncThread.keyEvent(k, true);
825 } else { //normal key
826 vncThread.keyEvent(k, true);
827 vncThread.keyEvent(k, false);
831 void VncView::sendKeySequence(QKeySequence keys)
833 Q_ASSERT(keys.count() <= 1); //we can only handle a single combination
835 //to get at individual key presses, we split 'keys' into its components
837 for(int i = 0; ; i++) {
838 QString k = keys.toString().section('+', i, i);
841 //kDebug(5011) << "found key: " << k;
843 key_list.append(Qt::Key_Alt);
844 } else if(k == "Ctrl") {
845 key_list.append(Qt::Key_Control);
846 } else if(k == "Meta") {
847 key_list.append(Qt::Key_Meta);
849 key_list.append(QKeySequence(k)[0]);
853 for(int i = 0; i < key_list.count(); i++)
854 sendKey(Qt::Key(key_list.at(i)));
856 //release modifiers (everything before final key)
857 for(int i = key_list.count()-2; i >= 0; i--)
858 sendKey(Qt::Key(key_list.at(i)));
861 void VncView::reloadSettings()
864 left_zoom = settings.value("left_zoom", 0).toInt();
865 right_zoom = settings.value("right_zoom", 1).toInt();
866 disable_tapping = settings.value("disable_tapping", false).toBool();
868 bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
869 if(always_show_local_cursor)
870 showDotCursor(CursorOn);
873 //convert commitString into keyevents
874 void VncView::inputMethodEvent(QInputMethodEvent *event)
876 //TODO handle replacements
877 //NOTE for the return key to work Qt needs to enable multiline input, which only works for Q(Plain)TextEdit
879 //kDebug(5011) << event->commitString() << "|" << event->preeditString() << "|" << event->replacementLength() << "|" << event->replacementStart();
880 QString letters = event->commitString();
881 for(int i = 0; i < letters.length(); i++) {
882 char k = letters.at(i).toLatin1(); //works with all 'normal' keys, not umlauts.
884 kDebug(5011) << "unhandled key";
887 vncThread.keyEvent(k, true);
888 vncThread.keyEvent(k, false);
893 #include "moc_vncview.cpp"