From e2186a49cb5cbdf01b56f57818a15a760ff25b2e Mon Sep 17 00:00:00 2001 From: treke Date: Thu, 05 Sep 2002 04:42:25 +0000 Subject: Added support for client side scaling of the screen. Slow, but sometimes usable. --- (limited to 'noncore/comm') diff --git a/noncore/comm/keypebble/krfbbuffer.cpp b/noncore/comm/keypebble/krfbbuffer.cpp index 5a52f31..f1cb929 100644 --- a/noncore/comm/keypebble/krfbbuffer.cpp +++ b/noncore/comm/keypebble/krfbbuffer.cpp @@ -6,6 +6,8 @@ #include #include "krfbdecoder.h" #include "krfbbuffer.h" +#include "krfbconnection.h" +#include "krfbserver.h" #include "krfbserverinfo.h" // @@ -86,6 +88,7 @@ void KRFBBuffer::drawRawRectChunk( void *data, { QImage img( w, h, 32 ); + int scaleFactor=decoder->con->options()->scaleFactor; int redMax = Swap16IfLE( decoder->format->redMax ); int greenMax = Swap16IfLE( decoder->format->greenMax ); int blueMax = Swap16IfLE( decoder->format->blueMax ); @@ -97,7 +100,8 @@ void KRFBBuffer::drawRawRectChunk( void *data, uint r,g,b; - for ( int j = 0; j < h; j++ ) { + + for ( int j = 0; j < h; j++) { for ( int i = 0; i < w ; i++ ) { r = d[ j * w + i ]; r = r >> decoder->format->redShift; @@ -187,8 +191,13 @@ void KRFBBuffer::drawRawRectChunk( void *data, p.drawRect( x, y, w, h ); } - p.drawImage( x, y, img ); - - emit updated( x, y, w, h ); + if (scaleFactor > 1) { + p.drawImage( x/scaleFactor, y/scaleFactor, img.smoothScale(w/scaleFactor,h/scaleFactor) ); + emit updated( x/scaleFactor, y/scaleFactor, w/scaleFactor, h/scaleFactor ); + } + else { + p.drawImage( x, y, img); + emit updated( x, y, w, h ); + } } diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp index 8b56795..896de7f 100644 --- a/noncore/comm/keypebble/krfbcanvas.cpp +++ b/noncore/comm/keypebble/krfbcanvas.cpp @@ -22,7 +22,8 @@ KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name ) this, SLOT( loggedIn() ) ); loggedIn_ = false; - QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold); + + //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold); viewport()->setFocusPolicy( QWidget::StrongFocus ); viewport()->setFocus(); @@ -104,6 +105,8 @@ void KRFBCanvas::viewportPaintEvent( QPaintEvent *e ) QRect r = e->rect(); if ( loggedIn_ ) { + QPixmap p; + bitBlt( viewport(), r.x(), r.y(), connection_->buffer()->pixmap(), r.x() + contentsX(), r.y() + contentsY(), diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp index a964c09..94e3b79 100644 --- a/noncore/comm/keypebble/krfbdecoder.cpp +++ b/noncore/comm/keypebble/krfbdecoder.cpp @@ -195,7 +195,7 @@ void KRFBDecoder::gotServerInit() qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d", info->redShift, info->greenShift,info-> blueShift ); - buf->resize( info->width, info->height ); + buf->resize( info->width/con->options()->scaleFactor, info->height /con->options()->scaleFactor); // Wait for desktop name qWarning( "Waiting for desktop name" ); @@ -642,8 +642,9 @@ void KRFBDecoder::sendMouseEvent( QMouseEvent *e ) } } - CARD16 x = Swap16IfLE( e->x() ); - CARD16 y = Swap16IfLE( e->y() ); + // HACK: Scaling + CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor ); + CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor ); con->write( &PointerEventId, 1 ); con->write( &buttonMask, 1 ); diff --git a/noncore/comm/keypebble/krfbdecoder.h b/noncore/comm/keypebble/krfbdecoder.h index 4ba0185..db6271d 100644 --- a/noncore/comm/keypebble/krfbdecoder.h +++ b/noncore/comm/keypebble/krfbdecoder.h @@ -98,6 +98,9 @@ signals: void error( const QString & ); void status( const QString & ); +protected: + /** The connection to the server. */ + KRFBConnection *con; private: State currentState; @@ -118,8 +121,6 @@ private: /** Where we draw the data (and the source of our events). */ KRFBBuffer *buf; - /** The connection to the server. */ - KRFBConnection *con; /** Info about the RFB server. */ KRFBServerInfo *info; diff --git a/noncore/comm/keypebble/krfbserver.cpp b/noncore/comm/keypebble/krfbserver.cpp index 5775f09..b47534e 100644 --- a/noncore/comm/keypebble/krfbserver.cpp +++ b/noncore/comm/keypebble/krfbserver.cpp @@ -9,6 +9,8 @@ KRFBServer::KRFBServer() QString password; display=0; + scaleFactor=1; + hexTile=0; corre=0; rre=0; diff --git a/noncore/comm/keypebble/krfbserver.h b/noncore/comm/keypebble/krfbserver.h index f87eecc..e38e2d2 100644 --- a/noncore/comm/keypebble/krfbserver.h +++ b/noncore/comm/keypebble/krfbserver.h @@ -29,6 +29,7 @@ public: bool deIconify; int updateRate; + int scaleFactor; }; #endif // KRFBOPTIONS_H diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp index aa46e2f..b173004 100644 --- a/noncore/comm/keypebble/kvnc.cpp +++ b/noncore/comm/keypebble/kvnc.cpp @@ -72,6 +72,7 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name ) stack->addWidget(canvas,get_unique_id()); setCentralWidget( stack ); + connect( bookmarkSelector->bookmarkList, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(openConnection(QListBoxItem *)) ); connect( canvas->connection(), SIGNAL(statusChanged(const QString &)), @@ -92,7 +93,10 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name ) stack->raiseWidget( bookmarkSelector ); - QPEToolBar *bar = new QPEToolBar( this ); + bar= new QToolBar( this ); + setToolBarsMovable( false ); + setRightJustification(false); + QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); @@ -235,6 +239,7 @@ void KVNC::connected() disconnectAction->setEnabled( true ); fullScreenAction->setEnabled( true ); stack->raiseWidget(canvas); + bar->hide(); } void KVNC::loggedIn() @@ -254,6 +259,7 @@ void KVNC::disconnected() disconnectAction->setEnabled( false ); fullScreenAction->setEnabled( false ); stack->raiseWidget(bookmarkSelector); + bar->show(); } void KVNC::statusMessage( const QString &m ) diff --git a/noncore/comm/keypebble/kvnc.h b/noncore/comm/keypebble/kvnc.h index 6e0a385..82a24fc 100644 --- a/noncore/comm/keypebble/kvnc.h +++ b/noncore/comm/keypebble/kvnc.h @@ -4,7 +4,7 @@ #define KVNC_H #include -#include +#include #include #include "kvncbookmarkdlg.h" @@ -57,6 +57,7 @@ private: QAction *disconnectAction; QAction *ctlAltDelAction;; QAction *connectAction; + QToolBar * bar; KVNCBookmarkDlg * bookmarkSelector; QWidgetStack * stack; diff --git a/noncore/comm/keypebble/kvncbookmarkdlg.cpp b/noncore/comm/keypebble/kvncbookmarkdlg.cpp index 1f97d13..1e2f3c3 100644 --- a/noncore/comm/keypebble/kvncbookmarkdlg.cpp +++ b/noncore/comm/keypebble/kvncbookmarkdlg.cpp @@ -161,6 +161,8 @@ void KVNCBookmarkDlg::readBookmarks(void) server->deIconify=val.toInt(); else if (key=="updaterate") server->updateRate=val.toInt(); + else if (key=="scalefactor") + server->scaleFactor=val.toInt(); } if (server){ @@ -200,6 +202,7 @@ void KVNCBookmarkDlg::writeBookmarks(void) t << "\treadonly=" << server->readOnly << '\n'; t << "\tdeiconify=" << server->deIconify << '\n'; t << "\tupdaterate=" << server->updateRate << '\n'; + t << "\tscalefactor=" << server->scaleFactor << '\n'; } f.close(); diff --git a/noncore/comm/keypebble/kvncconndlg.cpp b/noncore/comm/keypebble/kvncconndlg.cpp index 6873feb..2f073f8 100644 --- a/noncore/comm/keypebble/kvncconndlg.cpp +++ b/noncore/comm/keypebble/kvncconndlg.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,12 @@ KVNCConnDlg::KVNCConnDlg( KRFBServer *options, rre->setChecked( options->rre ); copyRect->setChecked( options->copyrect ); + for (int i=0; i < scaleFactor->count(); ++i) { + if (scaleFactor->text(i).toInt()==tmpOptions.scaleFactor) { + scaleFactor->setCurrentItem(i); + } + } + // TODO hex->setEnabled( false ); corre->setEnabled( false ); @@ -40,9 +47,12 @@ KVNCConnDlg::KVNCConnDlg( KRFBServer *options, shared->setChecked( options->shared ); timeBox->setValue( options->updateRate ); + serverPassword->setEchoMode(QLineEdit::Password); -} + connect(togglePassword, SIGNAL( stateChanged(int) ), this, SLOT( showPassword(int) ) ); + +} KVNCConnDlg::~KVNCConnDlg() { } @@ -66,6 +76,7 @@ void KVNCConnDlg::save() tmpOptions.password = serverPassword->text(); tmpOptions.display = serverDisplay->value(); tmpOptions.name = serverBookmark->text(); + tmpOptions.scaleFactor = scaleFactor->currentText().toInt(); if (!serverBookmark->text().isEmpty()) { if ( options) { @@ -73,3 +84,11 @@ void KVNCConnDlg::save() } } } + +void KVNCConnDlg::showPassword(int show) +{ + if (show) + serverPassword->setEchoMode(QLineEdit::Normal); + else + serverPassword->setEchoMode(QLineEdit::Password); +} diff --git a/noncore/comm/keypebble/kvncconndlg.h b/noncore/comm/keypebble/kvncconndlg.h index fae7d62..5e84750 100644 --- a/noncore/comm/keypebble/kvncconndlg.h +++ b/noncore/comm/keypebble/kvncconndlg.h @@ -20,6 +20,7 @@ class KVNCConnDlg : public KVNCConnDlgBase void accept(); private slots: void save(); + void showPassword(int); private: KRFBServer tmpOptions; diff --git a/noncore/comm/keypebble/kvncconndlgbase.ui b/noncore/comm/keypebble/kvncconndlgbase.ui index df0d375..42765c1 100644 --- a/noncore/comm/keypebble/kvncconndlgbase.ui +++ b/noncore/comm/keypebble/kvncconndlgbase.ui @@ -11,8 +11,8 @@ 0 0 - 984 - 676 + 260 + 242 @@ -22,397 +22,447 @@ layoutMargin - + + QTabWidget - margin - 0 + name + TabWidget3 - spacing - 6 + geometry + + 0 + 0 + 266 + 233 + - QTabWidget + QWidget name - TabWidget3 + tab - - QWidget + + title + Server + + - name - tab + margin + 11 - - title - Server - - + + spacing + 6 + + + QLineEdit - margin - 11 + name + serverPassword - spacing - 6 + autoMask + true - - QLabel - - name - hostname - - - text - Host Name: - - - - QLabel - - name - TextLabel2_2 - - - text - Display Number: - - - - QLineEdit - - name - serverPassword - - - autoMask - true - - - - QSpinBox - - name - serverDisplay - - - maxValue - 500 - - - minValue - 0 - + + echoMode + Password + + + + QCheckBox + + name + togglePassword + + + text + Show Password + + + + QLabel + + name + TextLabel3 + + + text + Password: + + + + QLineEdit + + name + serverBookmark + + + + QLabel + + name + TextLabel1_2 + + + text + Bookmark Name: + + + + QLineEdit + + name + serverHostname + + + + QLabel + + name + hostname + + + text + Host Name: + + + + QLabel + + name + TextLabel2_2 + + + text + Display Number: + + + + QSpinBox + + name + serverDisplay + + + maxValue + 500 + + + minValue + 0 + + + value + 0 + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + tab + + + title + Options + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + Check for screen updates every: + + + + QLayoutWidget + + name + Layout2 + + - value + margin 0 - - - QLineEdit - - name - serverHostname - - - - QLabel - - name - TextLabel3 - - text - Password: + spacing + 6 - - - QLineEdit - - name - serverBookmark - - - - QLabel - - name - TextLabel1_2 - - - text - Bookmark Name: - - - - - name - Spacer2 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QLayoutWidget - - name - Layout3 - - + + QSpinBox - margin - 0 + name + timeBox - spacing - 6 + maxValue + 500 - - - - - - QWidget - - name - tab - - - title - Options - - + + minValue + 1 + + + + QLabel + + name + TextLabel2 + + + text + Milliseconds + + + + + + QCheckBox - margin - 11 + name + bit - spacing - 6 + text + Request 8-bit session - - QLabel - - name - TextLabel1 - + + + QCheckBox + + name + deIconify + + + text + Raise on bell + + + + QCheckBox + + name + shared + + + text + Request shared session + + + + QLayoutWidget + + name + Layout3 + + - text - Check for screen updates every: + margin + 0 - - - QLayoutWidget - name - Layout2 + spacing + 6 - - - margin - 0 - - - spacing - 6 - - - QSpinBox - - name - timeBox - - - maxValue - 500 - - - minValue - 1 + + QComboBox + + + text + 1 - - - QLabel - - name - TextLabel2 + + + + text + 2 - + + + text - Milliseconds + 4 - - - - - QCheckBox - - name - bit - - - text - Request 8-bit session - - - - QCheckBox - - name - deIconify - - - text - Raise on bell - - - - QCheckBox - - name - shared - - - text - Request shared session - - - - - name - Spacer2 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - - QWidget + + + name + scaleFactor + + + + QLabel + + name + TextLabel2_3 + + + text + Scale Factor + + + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + tab + + + title + Encodings + + + + margin + 11 + - name - tab + spacing + 6 - - title - Encodings - - + + QCheckBox - margin - 11 + name + hex - spacing - 6 + enabled + false - - QCheckBox - - name - hex - - - enabled - false - - - text - Hextile encoding - - - - QCheckBox - - name - corre - - - enabled - false - - - text - CoRRE encoding - - - - QCheckBox - - name - rre - - - enabled - false - - - text - RRE encoding - - - - QCheckBox - - name - copyRect - - - text - Copy rectangle encoding - - - - - name - Spacer3 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - + + text + Hextile encoding + + + + QCheckBox + + name + corre + + + enabled + false + + + text + CoRRE encoding + + + + QCheckBox + + name + rre + + + enabled + false + + + text + RRE encoding + + + + QCheckBox + + name + copyRect + + + text + Copy rectangle encoding + + + + + name + Spacer3 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + - + TabWidget3 -- cgit v0.9.0.2