Diffstat (limited to 'noncore/comm/keypebble/krfbcanvas.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/comm/keypebble/krfbcanvas.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp index 918ce8b..049bbd4 100644 --- a/noncore/comm/keypebble/krfbcanvas.cpp +++ b/noncore/comm/keypebble/krfbcanvas.cpp | |||
@@ -1,41 +1,45 @@ | |||
1 | #include "krfbconnection.h" | 1 | #include "krfbconnection.h" |
2 | #include "krfbcanvas.h" | 2 | #include "krfbcanvas.h" |
3 | #include "krfbserver.h" | 3 | #include "krfbserver.h" |
4 | #include "krfbbuffer.h" | 4 | #include "krfbbuffer.h" |
5 | 5 | ||
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qclipboard.h> | 10 | #include <qclipboard.h> |
11 | #include <qaction.h> | 11 | #include <qaction.h> |
12 | #include <qpixmap.h> | 12 | #include <qpixmap.h> |
13 | #include <qpoint.h> | ||
13 | #include <qapplication.h> | 14 | #include <qapplication.h> |
14 | #include <qmainwindow.h> | 15 | #include <qmainwindow.h> |
15 | #include <qiconset.h> | 16 | #include <qiconset.h> |
16 | 17 | ||
17 | KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name ) | 18 | KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name ) |
18 | : QScrollView( parent, name ) | 19 | : QScrollView( parent, name ) |
19 | { | 20 | { |
20 | connection_ = new KRFBConnection(); | 21 | connection_ = new KRFBConnection(); |
21 | connect( connection_, SIGNAL( loggedIn() ), | 22 | connect( connection_, SIGNAL( loggedIn() ), |
22 | this, SLOT( loggedIn() ) ); | 23 | this, SLOT( loggedIn() ) ); |
23 | 24 | ||
24 | loggedIn_ = false; | 25 | loggedIn_ = false; |
25 | 26 | ||
26 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold); | 27 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold); |
27 | 28 | ||
28 | viewport()->setFocusPolicy( QWidget::StrongFocus ); | 29 | viewport()->setFocusPolicy( QWidget::StrongFocus ); |
29 | viewport()->setFocus(); | 30 | viewport()->setFocus(); |
31 | |||
32 | nextRightClick=0; | ||
33 | nextDoubleClick=0; | ||
30 | } | 34 | } |
31 | 35 | ||
32 | KRFBCanvas::~KRFBCanvas() | 36 | KRFBCanvas::~KRFBCanvas() |
33 | { | 37 | { |
34 | } | 38 | } |
35 | 39 | ||
36 | 40 | ||
37 | void KRFBCanvas::openConnection(KRFBServer server) | 41 | void KRFBCanvas::openConnection(KRFBServer server) |
38 | { | 42 | { |
39 | 43 | ||
40 | 44 | ||
41 | QCString host = server.hostname.latin1(); | 45 | QCString host = server.hostname.latin1(); |
@@ -115,34 +119,55 @@ void KRFBCanvas::viewportPaintEvent( QPaintEvent *e ) | |||
115 | else { | 119 | else { |
116 | QScrollView::viewportPaintEvent( e ); | 120 | QScrollView::viewportPaintEvent( e ); |
117 | } | 121 | } |
118 | } | 122 | } |
119 | 123 | ||
120 | void KRFBCanvas::viewportUpdate( int x, int y, int w, int h ) | 124 | void KRFBCanvas::viewportUpdate( int x, int y, int w, int h ) |
121 | { | 125 | { |
122 | updateContents( x, y, w, h ); | 126 | updateContents( x, y, w, h ); |
123 | } | 127 | } |
124 | 128 | ||
125 | void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e ) | 129 | void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e ) |
126 | { | 130 | { |
127 | if ( loggedIn_ ) | 131 | |
132 | if (nextDoubleClick) { | ||
133 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),LeftButton,LeftButton)); | ||
134 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); | ||
135 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0)); | ||
136 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); | ||
137 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); | ||
138 | } if (nextRightClick) { | ||
139 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),RightButton,RightButton)); | ||
140 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),RightButton,0)); | ||
141 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton)); | ||
142 | connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0)); | ||
143 | } else if ( loggedIn_ ) | ||
128 | connection_->buffer()->mouseEvent( e ); | 144 | connection_->buffer()->mouseEvent( e ); |
145 | |||
146 | qDebug("Press"); | ||
147 | qDebug(QString::number(e->type()==QEvent::MouseButtonPress)); | ||
129 | } | 148 | } |
130 | 149 | ||
131 | void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e ) | 150 | void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e ) |
132 | { | 151 | { |
133 | if ( loggedIn_ ) | 152 | if ( loggedIn_ && !nextRightClick && !nextDoubleClick) { |
134 | connection_->buffer()->mouseEvent( e ); | 153 | connection_->buffer()->mouseEvent( e ); |
135 | } | 154 | } |
136 | 155 | ||
156 | nextRightClick=0; | ||
157 | nextDoubleClick=0; | ||
158 | qDebug("Release"); | ||
159 | qDebug(QString::number(e->button())); | ||
160 | } | ||
161 | |||
137 | void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e ) | 162 | void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e ) |
138 | { | 163 | { |
139 | if ( loggedIn_ ) | 164 | if ( loggedIn_ ) |
140 | connection_->buffer()->mouseEvent( e ); | 165 | connection_->buffer()->mouseEvent( e ); |
141 | } | 166 | } |
142 | 167 | ||
143 | void KRFBCanvas::keyPressEvent( QKeyEvent *e ) | 168 | void KRFBCanvas::keyPressEvent( QKeyEvent *e ) |
144 | { | 169 | { |
145 | if ( loggedIn_ ) | 170 | if ( loggedIn_ ) |
146 | connection_->buffer()->keyPressEvent( e ); | 171 | connection_->buffer()->keyPressEvent( e ); |
147 | } | 172 | } |
148 | 173 | ||
@@ -158,22 +183,31 @@ void KRFBCanvas::refresh() | |||
158 | connection_->refresh(); | 183 | connection_->refresh(); |
159 | } | 184 | } |
160 | 185 | ||
161 | void KRFBCanvas::clipboardChanged() | 186 | void KRFBCanvas::clipboardChanged() |
162 | { | 187 | { |
163 | if ( loggedIn_ ) { | 188 | if ( loggedIn_ ) { |
164 | connection_->sendCutText( qApp->clipboard()->text() ); | 189 | connection_->sendCutText( qApp->clipboard()->text() ); |
165 | } | 190 | } |
166 | } | 191 | } |
167 | void KRFBCanvas::sendCtlAltDel( void) | 192 | void KRFBCanvas::sendCtlAltDel( void) |
168 | { | 193 | { |
169 | 194 | ||
170 | qDebug("Here"); | ||
171 | if ( loggedIn_ ) { | 195 | if ( loggedIn_ ) { |
172 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Control, 0,0)); | 196 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Control, 0,0)); |
173 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Alt, 0,0)); | 197 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Alt, 0,0)); |
174 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, 0,0)); | 198 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, 0,0)); |
175 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Control, 0,0)); | 199 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Control, 0,0)); |
176 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Alt, 0,0)); | 200 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Alt, 0,0)); |
177 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Delete, 0,0)); | 201 | connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Delete, 0,0)); |
178 | } | 202 | } |
179 | } | 203 | } |
204 | |||
205 | void KRFBCanvas::markDoubleClick( void) | ||
206 | { | ||
207 | nextRightClick=1; | ||
208 | } | ||
209 | |||
210 | void KRFBCanvas::markRightClick( void) | ||
211 | { | ||
212 | nextRightClick=1; | ||
213 | } | ||