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 ****************************************************************************/
25 #include "vncclientthread.h"
27 //for mouse button masks
28 #include "rfb/rfbproto.h"
33 // Definition of key modifier mask constants
34 #define KMOD_Alt_R 0x01
35 #define KMOD_Alt_L 0x02
36 #define KMOD_Meta_L 0x04
37 #define KMOD_Control_L 0x08
38 #define KMOD_Shift_L 0x10
40 //local cursor width/height in px, should be an odd number
41 const int CURSOR_SIZE = 7;
44 const int TAP_PRESS_TIME = 180;
45 const int DOUBLE_TAP_UP_TIME = 500;
48 VncView::VncView(QWidget *parent, const KUrl &url, RemoteView::Quality quality, int listen_port)
50 m_vncThread(new VncClientThread()),
56 m_firstPasswordTry(true),
57 m_dontSendClipboard(false),
58 m_horizontalFactor(1.0),
59 m_verticalFactor(1.0),
60 m_forceLocalCursor(false),
62 m_listen_port(listen_port),
63 m_transformation_mode(Qt::FastTransformation),
70 //BlockingQueuedConnection can cause deadlocks when exiting, handled in startQuitting()
71 connect(m_vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)), Qt::BlockingQueuedConnection);
72 connect(m_vncThread, SIGNAL(gotCut(const QString&)), this, SLOT(setCut(const QString&)), Qt::BlockingQueuedConnection);
73 connect(m_vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()), Qt::BlockingQueuedConnection);
74 connect(m_vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString)));
76 //don't miss early connection failures
77 connect(m_vncThread, SIGNAL(finished()), this, SLOT(startQuitting()));
79 m_clipboard = QApplication::clipboard();
80 connect(m_clipboard, SIGNAL(selectionChanged()), this, SLOT(clipboardSelectionChanged()));
81 connect(m_clipboard, SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
90 // Disconnect all signals so that we don't get any more callbacks from the client thread
91 m_vncThread->disconnect();
98 bool VncView::eventFilter(QObject *obj, QEvent *event)
101 if (event->type() == QEvent::KeyPress ||
102 event->type() == QEvent::KeyRelease ||
103 event->type() == QEvent::MouseButtonDblClick ||
104 event->type() == QEvent::MouseButtonPress ||
105 event->type() == QEvent::MouseButtonRelease ||
106 event->type() == QEvent::Wheel ||
107 event->type() == QEvent::MouseMove) {
114 return RemoteView::eventFilter(obj, event);
117 QSize VncView::framebufferSize() const
119 return m_frame.size();
122 QSize VncView::sizeHint() const
127 QSize VncView::minimumSizeHint() const
132 void VncView::startQuitting()
137 kDebug(5011) << "about to quit";
139 setStatus(Disconnecting);
145 const bool quitSuccess = m_vncThread->wait(700);
147 //happens when m_vncThread wants to call a slot via BlockingQueuedConnection,
148 //needs an event loop in this thread so execution continues after 'emit'
150 if(!loop.processEvents())
151 kDebug(5011) << "BUG: deadlocked, but no events to deliver?";
152 m_vncThread->wait(700);
154 setStatus(Disconnected);
157 bool VncView::isQuitting() const
162 bool VncView::start()
164 m_vncThread->setHost(m_host);
165 m_vncThread->setPort(m_port);
166 m_vncThread->setListenPort(m_listen_port); //if port is != 0, thread will listen for connections
167 m_vncThread->setQuality(m_quality);
169 // set local cursor on by default because low quality mostly means slow internet connection
170 if (m_quality == RemoteView::Low) {
171 showDotCursor(RemoteView::CursorOn);
174 setStatus(Connecting);
176 m_vncThread->start();
180 bool VncView::supportsScaling() const
185 bool VncView::supportsLocalCursor() const
190 void VncView::requestPassword()
192 kDebug(5011) << "request password";
194 setStatus(Authenticating);
196 if (!m_url.password().isNull()) {
197 m_vncThread->setPassword(m_url.password());
202 settings.beginGroup("hosts");
204 //check for saved password
205 QString password = settings.value(QString("%1/password").arg(m_host), "").toString();
206 if(m_firstPasswordTry and !password.isEmpty()) {
207 kDebug(5011) << "Trying saved password";
208 m_firstPasswordTry = false;
209 m_vncThread->setPassword(password);
212 m_firstPasswordTry = false;
215 QDialog dialog(this);
216 dialog.setWindowTitle(tr("Password required"));
218 QLineEdit passwordbox;
219 passwordbox.setEchoMode(QLineEdit::Password);
220 passwordbox.setText(password);
221 QCheckBox save_password(tr("Save Password"));
222 save_password.setChecked(!password.isEmpty()); //offer to overwrite saved password
223 QPushButton ok_button(tr("Done"));
224 ok_button.setMaximumWidth(100);
225 connect(&ok_button, SIGNAL(clicked()),
226 &dialog, SLOT(accept()));
230 layout2.addWidget(&passwordbox);
231 if(!m_host.isEmpty()) //don't save incoming connections
232 layout2.addWidget(&save_password);
233 layout1.addLayout(&layout2);
234 layout1.addWidget(&ok_button);
235 dialog.setLayout(&layout1);
237 if(dialog.exec()) { //dialog accepted
238 password = passwordbox.text();
240 if(!m_host.isEmpty() and save_password.isChecked()) {
241 kDebug(5011) << "Saving password for host '" << m_host << "'";
243 settings.setValue(QString("%1/password").arg(m_host), password);
247 m_vncThread->setPassword(password);
249 m_vncThread->setPassword(QString()); //null string to exit
253 void VncView::outputErrorMessage(const QString &message)
255 if (message == "INTERNAL:APPLE_VNC_COMPATIBILTY") {
256 setCursor(localDotCursor());
257 m_forceLocalCursor = true;
261 emit errorMessage(i18n("VNC failure"), message);
266 void VncView::updateImage(int x, int y, int w, int h)
269 //don't update if window is out of focus / display is off
270 if(!QApplication::focusWidget() || display_off) {
275 //kDebug(5011) << "got update" << width() << height();
282 if (m_horizontalFactor != 1.0 || m_verticalFactor != 1.0) {
283 // If the view is scaled, grow the update rectangle to avoid artifacts
284 int x_extrapixels = 1.0/m_horizontalFactor + 1;
285 int y_extrapixels = 1.0/m_verticalFactor + 1;
289 m_w+=2*x_extrapixels;
290 m_h+=2*y_extrapixels;
293 m_frame = m_vncThread->image();
295 if (!m_initDone) { //TODO this seems an odd place for initialization
296 setAttribute(Qt::WA_NoSystemBackground);
297 installEventFilter(this);
299 setCursor(((m_dotCursorState == CursorOn) || m_forceLocalCursor) ? localDotCursor() : Qt::BlankCursor);
301 setMouseTracking(true); // get mouse events even when there is no mousebutton pressed
302 setFocusPolicy(Qt::WheelFocus);
303 setStatus(Connected);
306 resize(width(), height());
311 static QSize old_frame_size = QSize();
312 if ((y == 0 && x == 0) && (m_frame.size() != old_frame_size)) {
313 old_frame_size = m_frame.size();
314 kDebug(5011) << "Updating framebuffer size";
316 useFastTransformations(false);
318 emit framebufferSizeChanged(m_frame.width(), m_frame.height());
321 update(qRound(m_x * m_horizontalFactor), qRound(m_y * m_verticalFactor), qRound(m_w * m_horizontalFactor), qRound(m_h * m_verticalFactor));
324 void VncView::setViewOnly(bool viewOnly)
326 RemoteView::setViewOnly(viewOnly);
328 m_dontSendClipboard = viewOnly;
331 showDotCursor(CursorOff);
332 setCursor(Qt::ArrowCursor);
334 setCursor(m_dotCursorState == CursorOn ? localDotCursor() : Qt::BlankCursor);
338 void VncView::showDotCursor(DotCursorState state)
340 RemoteView::showDotCursor(state);
342 setCursor(state == CursorOn ? localDotCursor() : Qt::BlankCursor);
345 //level should be in [0, 100]
346 void VncView::setZoomLevel(int level)
348 Q_ASSERT(parentWidget() != 0);
350 if(level == -1) { //handle resize
351 resize(m_frame.width()*m_horizontalFactor, m_frame.height()*m_verticalFactor);
355 double magnification;
358 } else if(level >= 90) {
361 const double min_horiz_magnification = double(parentWidget()->width())/m_frame.width();
362 const double min_vert_magnification = double(parentWidget()->height())/m_frame.height();
363 const double fit_screen_magnification = qMin(min_horiz_magnification, min_vert_magnification);
365 //level=90 => magnification=1.0, level=0 => magnification=fit_screen_magnification
366 magnification = (level)/90.0*(1.0 - fit_screen_magnification) + fit_screen_magnification;
369 //remote display smaller than local (or NAN)?
370 if(magnification < 0 or magnification != magnification)
373 m_verticalFactor = m_horizontalFactor = magnification;
374 resize(m_frame.width()*magnification, m_frame.height()*magnification);
377 void VncView::setCut(const QString &text)
379 m_dontSendClipboard = true;
380 m_clipboard->setText(text, QClipboard::Clipboard);
381 m_clipboard->setText(text, QClipboard::Selection);
382 m_dontSendClipboard = false;
385 void VncView::paintEvent(QPaintEvent *event)
387 if (m_frame.isNull() || m_frame.format() == QImage::Format_Invalid) {
388 //no valid image to paint
389 RemoteView::paintEvent(event);
395 //split update region into smaller non-intersecting rectangles and only paint those
396 QPainter painter(this);
397 foreach(QRect update_rect, event->region().rects()) {
398 if(m_horizontalFactor == 2.0 and m_verticalFactor == 2.0) {
399 //grow client side updates to multiples of 2 to avoid artifacts
404 update_rect.adjust(0, 0,
405 (update_rect.x()+update_rect.width())%2,
406 (update_rect.y()+update_rect.height())%2);
408 const int sx = qRound(update_rect.x()/m_horizontalFactor);
409 const int sy = qRound(update_rect.y()/m_verticalFactor);
410 const int sw = qRound(update_rect.width()/m_horizontalFactor);
411 const int sh = qRound(update_rect.height()/m_verticalFactor);
413 //kDebug(5011) << "Partial repaint, widget x,y,w,h:" << update_rect.x() << update_rect.y() << update_rect.width() << update_rect.height() << "orig: " << sx << sy << sw << sh;
415 painter.drawImage(update_rect,
416 m_frame.copy(sx, sy, sw, sh)
417 .scaled(update_rect.size(), Qt::IgnoreAspectRatio, m_transformation_mode));
420 //draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
421 if((m_dotCursorState == CursorOn) || m_forceLocalCursor) {
422 #if QT_VERSION >= 0x040500
423 painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
425 //rectangle size includes 1px pen width
426 painter.drawRect(m_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, m_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE-1, CURSOR_SIZE-1);
429 RemoteView::paintEvent(event);
432 void VncView::resizeEvent(QResizeEvent *event)
434 RemoteView::resizeEvent(event);
438 bool VncView::event(QEvent *event)
440 switch (event->type()) {
441 case QEvent::KeyPress:
442 case QEvent::KeyRelease:
443 keyEventHandler(static_cast<QKeyEvent*>(event));
446 case QEvent::MouseButtonDblClick:
447 case QEvent::MouseButtonPress:
448 case QEvent::MouseButtonRelease:
449 case QEvent::MouseMove:
450 mouseEventHandler(static_cast<QMouseEvent*>(event));
454 wheelEventHandler(static_cast<QWheelEvent*>(event));
457 case QEvent::WindowActivate: //input panel may have been closed, prevent IM from interfering with hardware keyboard
458 setAttribute(Qt::WA_InputMethodEnabled, false);
461 return RemoteView::event(event);
465 //call with e == 0 to flush held events
466 void VncView::mouseEventHandler(QMouseEvent *e)
468 static bool tap_detected = false;
469 static bool double_tap_detected = false;
470 static bool tap_drag_detected = false;
471 static QTime press_time;
472 static QTime up_time; //used for double clicks/tap&drag, for time after first tap
475 if(!e) { //flush held taps
477 m_buttonMask |= rfbButton1Mask;
478 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
479 m_buttonMask &= ~rfbButton1Mask;
480 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
481 tap_detected = false;
482 } else if(double_tap_detected and press_time.elapsed() > TAP_PRESS_TIME) { //got tap + another press -> tap & drag
483 m_buttonMask |= rfbButton1Mask;
484 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
485 double_tap_detected = false;
486 tap_drag_detected = true;
492 if(e->x() < 0 or e->y() < 0) { //QScrollArea tends to send invalid events sometimes...
497 m_cursor_x = qRound(e->x()/m_horizontalFactor);
498 m_cursor_y = qRound(e->y()/m_verticalFactor);
499 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask); // plain move event
501 if(!m_disable_tapping and e->button() == Qt::LeftButton) { //implement touchpad-like input for left button
502 if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
504 if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
505 tap_detected = false;
506 double_tap_detected = true;
508 QTimer::singleShot(TAP_PRESS_TIME, this, SLOT(mouseEventHandler()));
510 } else if(e->type() == QEvent::MouseButtonRelease) {
511 if(tap_drag_detected) { //end tap & drag
512 m_buttonMask &= ~rfbButton1Mask;
513 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
514 tap_drag_detected = false;
515 } else if(double_tap_detected) { //double click
516 double_tap_detected = false;
518 m_buttonMask |= rfbButton1Mask;
519 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
520 m_buttonMask &= ~rfbButton1Mask;
521 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
522 m_buttonMask |= rfbButton1Mask;
523 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
524 m_buttonMask &= ~rfbButton1Mask;
525 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
526 } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
529 QTimer::singleShot(DOUBLE_TAP_UP_TIME, this, SLOT(mouseEventHandler()));
533 } else { //middle or right button, send directly
534 if ((e->type() == QEvent::MouseButtonPress)) {
535 if (e->button() & Qt::MidButton)
536 m_buttonMask |= rfbButton2Mask;
537 if (e->button() & Qt::RightButton)
538 m_buttonMask |= rfbButton3Mask;
539 } else if (e->type() == QEvent::MouseButtonRelease) {
540 if (e->button() & Qt::MidButton)
541 m_buttonMask &= ~rfbButton2Mask;
542 if (e->button() & Qt::RightButton)
543 m_buttonMask &= ~rfbButton3Mask;
545 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
548 //prevent local cursor artifacts
549 static int old_cursor_x = m_cursor_x;
550 static int old_cursor_y = m_cursor_y;
551 if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
552 and (m_cursor_x != old_cursor_x or m_cursor_y != old_cursor_y)) {
553 //clear last position
554 update(old_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, old_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
555 //and refresh new one
556 update(m_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, m_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
558 old_cursor_x = m_cursor_x;
559 old_cursor_y = m_cursor_y;
563 void VncView::wheelEventHandler(QWheelEvent *event)
566 if (event->delta() < 0)
567 eb |= rfbWheelDownMask;
569 eb |= rfbWheelUpMask;
571 const int x = qRound(event->x() / m_horizontalFactor);
572 const int y = qRound(event->y() / m_verticalFactor);
574 m_vncThread->mouseEvent(x, y, m_buttonMask | eb);
575 m_vncThread->mouseEvent(x, y, m_buttonMask);
578 void VncView::keyEventHandler(QKeyEvent *e)
580 // strip away autorepeating KeyRelease; see bug #206598
581 if (e->isAutoRepeat() && (e->type() == QEvent::KeyRelease)) {
585 // parts of this code are based on http://italc.sourcearchive.com/documentation/1.0.9.1/vncview_8cpp-source.html
586 rfbKeySym k = e->nativeVirtualKey();
589 // we do not handle Key_Backtab separately as the Shift-modifier
590 // is already enabled
591 if (e->key() == Qt::Key_Backtab) {
595 const bool pressed = (e->type() == QEvent::KeyPress);
598 //don't send ISO_Level3_Shift (would break things like Win+0-9)
599 //also enable IM so symbol key works
601 setAttribute(Qt::WA_InputMethodEnabled, pressed);
608 if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L) {
611 } else if (m_mods.contains(k)) {
619 int current_zoom = -1;
620 if(e->key() == Qt::Key_F8)
621 current_zoom = m_left_zoom;
622 else if(e->key() == Qt::Key_F7)
623 current_zoom = m_right_zoom;
625 kDebug(5011) << "Key pressed: '" << e->text() << "', nativeVirtualKey: " << k;
626 m_vncThread->keyEvent(k, pressed);
628 kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed.";
632 if(current_zoom == -1)
635 //handle zoom buttons
636 if(current_zoom == 0) { //left click
638 m_buttonMask |= rfbButton1Mask;
640 m_buttonMask &= ~rfbButton1Mask;
641 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
642 } else if(current_zoom == 1) { //right click
644 m_buttonMask |= rfbButton3Mask;
646 m_buttonMask &= ~rfbButton3Mask;
647 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
648 } else if(current_zoom == 2) { //middle click
650 m_buttonMask |= rfbButton2Mask;
652 m_buttonMask &= ~rfbButton2Mask;
653 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
654 } else if(current_zoom == 3 and pressed) { //wheel up
655 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask | rfbWheelUpMask);
656 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
657 } else if(current_zoom == 4 and pressed) { //wheel down
658 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask | rfbWheelDownMask);
659 m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
660 } else if(current_zoom == 5) { //page up
661 m_vncThread->keyEvent(0xff55, pressed);
662 } else if(current_zoom == 6) { //page down
663 m_vncThread->keyEvent(0xff56, pressed);
667 void VncView::unpressModifiers()
669 const QList<unsigned int> keys = m_mods.keys();
670 QList<unsigned int>::const_iterator it = keys.constBegin();
671 while (it != keys.end()) {
672 m_vncThread->keyEvent(*it, false);
678 void VncView::clipboardSelectionChanged()
680 if (m_status != Connected)
683 if (m_clipboard->ownsSelection() || m_dontSendClipboard)
686 const QString text = m_clipboard->text(QClipboard::Selection);
688 m_vncThread->clientCut(text);
691 void VncView::clipboardDataChanged()
693 if (m_status != Connected)
696 if (m_clipboard->ownsClipboard() || m_dontSendClipboard)
699 const QString text = m_clipboard->text(QClipboard::Clipboard);
701 m_vncThread->clientCut(text);
705 void VncView::sendKey(Qt::Key key)
707 //convert Qt::Key into x11 keysym
719 case Qt::Key_PageDown:
737 case Qt::Key_Backspace:
752 k = 0xffbe + int(key - Qt::Key_F1);
769 case Qt::Key_Control:
773 kDebug(5011) << "sendKey(): Unhandled Qt::Key value " << key;
777 if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L || k == XK_Super_L) {
778 if (m_mods.contains(k)) { //release
780 m_vncThread->keyEvent(k, false);
783 m_vncThread->keyEvent(k, true);
785 } else { //normal key
786 m_vncThread->keyEvent(k, true);
787 m_vncThread->keyEvent(k, false);
791 void VncView::sendKeySequence(QKeySequence keys)
793 Q_ASSERT(keys.count() <= 1); //we can only handle a single combination
795 //to get at individual key presses, we split 'keys' into its components
796 QList<Qt::Key> key_list;
799 QString k = keys.toString().section('+', pos, pos);
803 //kDebug(5011) << "found key: " << k;
805 key_list.append(Qt::Key_Alt);
806 } else if(k == "Ctrl") {
807 key_list.append(Qt::Key_Control);
808 } else if(k == "Meta") {
809 key_list.append(Qt::Key_Meta);
811 key_list.append((Qt::Key)QKeySequence(k)[0]);
817 for(int i = 0; i < key_list.count(); i++)
818 sendKey(key_list.at(i));
820 //release modifiers (everything before final key)
821 for(int i = key_list.count()-2; i >= 0; i--)
822 sendKey(key_list.at(i));
825 void VncView::reloadSettings()
828 m_left_zoom = settings.value("left_zoom", 0).toInt();
829 m_right_zoom = settings.value("right_zoom", 1).toInt();
830 m_disable_tapping = settings.value("disable_tapping", false).toBool();
832 bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
833 showDotCursor(always_show_local_cursor?CursorOn:CursorOff);
838 //convert commitString into keyevents
839 void VncView::inputMethodEvent(QInputMethodEvent *event)
841 //TODO handle replacements
842 //NOTE for the return key to work Qt needs to enable multiline input, which only works for Q(Plain)TextEdit
844 //kDebug(5011) << event->commitString() << "|" << event->preeditString() << "|" << event->replacementLength() << "|" << event->replacementStart();
845 QString letters = event->commitString();
846 for(int i = 0; i < letters.length(); i++) {
847 char k = letters.at(i).toLatin1();
849 kDebug(5011) << "unhandled key";
852 m_vncThread->keyEvent(k, true);
853 m_vncThread->keyEvent(k, false);
857 void VncView::useFastTransformations(bool enabled)
859 if(enabled or zoomFactor() >= 1.0) {
860 m_transformation_mode = Qt::FastTransformation;
862 m_transformation_mode = Qt::SmoothTransformation;