author | zecke <zecke> | 2005-02-14 17:57:40 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 17:57:40 (UTC) |
commit | 93d1877f2a13074065093772a1d018c8bda74fda (patch) (unidiff) | |
tree | d19468c3e97dd6806cf675a7cd0ab938e4029afb | |
parent | 41881e3dcd695dc8ecdc5ef22cefd6f842858992 (diff) | |
download | opie-93d1877f2a13074065093772a1d018c8bda74fda.zip opie-93d1877f2a13074065093772a1d018c8bda74fda.tar.gz opie-93d1877f2a13074065093772a1d018c8bda74fda.tar.bz2 |
Use tr for translatable strings
-rw-r--r-- | noncore/net/opierdesktop/qtwin.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/noncore/net/opierdesktop/qtwin.cpp b/noncore/net/opierdesktop/qtwin.cpp index 54a5a03..71ba5a5 100644 --- a/noncore/net/opierdesktop/qtwin.cpp +++ b/noncore/net/opierdesktop/qtwin.cpp | |||
@@ -1,948 +1,948 @@ | |||
1 | /* | 1 | /* |
2 | rdesktop: A Remote Desktop Protocol client. | 2 | rdesktop: A Remote Desktop Protocol client. |
3 | User interface services - X Window System | 3 | User interface services - X Window System |
4 | Copyright (C) Matthew Chapman 1999-2002 | 4 | Copyright (C) Matthew Chapman 1999-2002 |
5 | qt.cpp by Jay Sorg | 5 | qt.cpp by Jay Sorg |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "rdesktop.h" | 22 | #include "rdesktop.h" |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qimage.h> | 27 | #include <qimage.h> |
28 | #include <qsocketnotifier.h> | 28 | #include <qsocketnotifier.h> |
29 | #include <qscrollview.h> | 29 | #include <qscrollview.h> |
30 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qcheckbox.h> | 36 | #include <qcheckbox.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include "qtwin.h" | 38 | #include "qtwin.h" |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | 40 | ||
41 | uint32 flags; | 41 | uint32 flags; |
42 | char server[64] = ""; | 42 | char server[64] = ""; |
43 | char domain[16] = ""; | 43 | char domain[16] = ""; |
44 | char password[16] = ""; | 44 | char password[16] = ""; |
45 | char shell[128] = ""; | 45 | char shell[128] = ""; |
46 | char directory[32] = ""; | 46 | char directory[32] = ""; |
47 | 47 | ||
48 | extern int g_width; | 48 | extern int g_width; |
49 | extern int g_height; | 49 | extern int g_height; |
50 | extern int server_bpp; | 50 | extern int server_bpp; |
51 | extern BOOL fullscreen; | 51 | extern BOOL fullscreen; |
52 | extern char username[]; | 52 | extern char username[]; |
53 | int global_sock; | 53 | int global_sock; |
54 | 54 | ||
55 | QSocketNotifier* SocketNotifier; | 55 | QSocketNotifier* SocketNotifier; |
56 | QPEApplication* App; | 56 | QPEApplication* App; |
57 | QMyMainWindow* MW; | 57 | QMyMainWindow* MW; |
58 | QMyScrollView* SV; | 58 | QMyScrollView* SV; |
59 | struct QColorMap | 59 | struct QColorMap |
60 | { | 60 | { |
61 | uint32 RGBColors[256]; | 61 | uint32 RGBColors[256]; |
62 | int NumColors; | 62 | int NumColors; |
63 | }; | 63 | }; |
64 | QColorMap* CM; | 64 | QColorMap* CM; |
65 | uint8* BS; | 65 | uint8* BS; |
66 | int clipx; | 66 | int clipx; |
67 | int clipy; | 67 | int clipy; |
68 | int clipcx; | 68 | int clipcx; |
69 | int clipcy; | 69 | int clipcy; |
70 | 70 | ||
71 | struct bitmap | 71 | struct bitmap |
72 | { | 72 | { |
73 | int w; | 73 | int w; |
74 | int h; | 74 | int h; |
75 | uint8* data; | 75 | uint8* data; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | BOOL owncolmap = False; | 78 | BOOL owncolmap = False; |
79 | 79 | ||
80 | //***************************************************************************** | 80 | //***************************************************************************** |
81 | void CleanString(QString* Item) | 81 | void CleanString(QString* Item) |
82 | { | 82 | { |
83 | int i; | 83 | int i; |
84 | 84 | ||
85 | i = Item->length() - 1; | 85 | i = Item->length() - 1; |
86 | while (i >= 0) | 86 | while (i >= 0) |
87 | { | 87 | { |
88 | if (Item->at(i) == 10 || Item->at(i) == 13) | 88 | if (Item->at(i) == 10 || Item->at(i) == 13) |
89 | Item->remove(i, 1); | 89 | Item->remove(i, 1); |
90 | i--; | 90 | i--; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | //***************************************************************************** | 94 | //***************************************************************************** |
95 | QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) | 95 | QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) |
96 | { | 96 | { |
97 | setCaption( tr( "Configuration" ) ); | 97 | setCaption( tr( "Configuration" ) ); |
98 | int i, j; | 98 | int i, j; |
99 | char* home; | 99 | char* home; |
100 | char Text[256]; | 100 | char Text[256]; |
101 | QString Line; | 101 | QString Line; |
102 | QString ItemName; | 102 | QString ItemName; |
103 | QString ItemValue; | 103 | QString ItemValue; |
104 | 104 | ||
105 | // resize dialog | 105 | // resize dialog |
106 | resize(230, 270); | 106 | resize(230, 270); |
107 | // main list box | 107 | // main list box |
108 | ListBox = new QListBox(this); | 108 | ListBox = new QListBox(this); |
109 | ListBox->move(10, 10); | 109 | ListBox->move(10, 10); |
110 | ListBox->resize(200, 100); | 110 | ListBox->resize(200, 100); |
111 | connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); | 111 | connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); |
112 | connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); | 112 | connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); |
113 | // server | 113 | // server |
114 | Label1 = new QLabel(this); | 114 | Label1 = new QLabel(this); |
115 | Label1->setText("Server Desc"); | 115 | Label1->setText( tr("Server Desc") ); |
116 | Label1->move(10, 120); | 116 | Label1->move(10, 120); |
117 | Label1->resize(100, 20); | 117 | Label1->resize(100, 20); |
118 | ServerNameEdit = new QLineEdit(this); | 118 | ServerNameEdit = new QLineEdit(this); |
119 | ServerNameEdit->move(75, 120); | 119 | ServerNameEdit->move(75, 120); |
120 | ServerNameEdit->resize(100, 20); | 120 | ServerNameEdit->resize(100, 20); |
121 | // username | 121 | // username |
122 | Label2 = new QLabel(this); | 122 | Label2 = new QLabel(this); |
123 | Label2->setText("User Name"); | 123 | Label2->setText( tr("User Name") ); |
124 | Label2->move(10, 150); | 124 | Label2->move(10, 150); |
125 | Label2->resize(100, 20); | 125 | Label2->resize(100, 20); |
126 | UserNameEdit = new QLineEdit(this); | 126 | UserNameEdit = new QLineEdit(this); |
127 | UserNameEdit->move(75, 150); | 127 | UserNameEdit->move(75, 150); |
128 | UserNameEdit->resize(100, 20); | 128 | UserNameEdit->resize(100, 20); |
129 | // ip | 129 | // ip |
130 | Label3 = new QLabel(this); | 130 | Label3 = new QLabel(this); |
131 | Label3->setText("Server IP"); | 131 | Label3->setText( tr("Server Address") ); |
132 | Label3->move(10, 180); | 132 | Label3->move(10, 180); |
133 | Label3->resize(100, 20); | 133 | Label3->resize(100, 20); |
134 | IPEdit = new QLineEdit(this); | 134 | IPEdit = new QLineEdit(this); |
135 | IPEdit->move(75, 180); | 135 | IPEdit->move(75, 180); |
136 | IPEdit->resize(100, 20); | 136 | IPEdit->resize(100, 20); |
137 | // width and height | 137 | // width and height |
138 | WidthHeightBox = new QComboBox(this); | 138 | WidthHeightBox = new QComboBox(this); |
139 | WidthHeightBox->move(10, 210); | 139 | WidthHeightBox->move(10, 210); |
140 | WidthHeightBox->resize(100, 20); | 140 | WidthHeightBox->resize(100, 20); |
141 | WidthHeightBox->insertItem("240x320"); | 141 | WidthHeightBox->insertItem("240x320"); |
142 | WidthHeightBox->insertItem("640x480"); | 142 | WidthHeightBox->insertItem("640x480"); |
143 | WidthHeightBox->insertItem("800x600"); | 143 | WidthHeightBox->insertItem("800x600"); |
144 | connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); | 144 | connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); |
145 | WidthHeightBox->setCurrentItem(1); | 145 | WidthHeightBox->setCurrentItem(1); |
146 | WidthEdit = new QLineEdit(this); | 146 | WidthEdit = new QLineEdit(this); |
147 | WidthEdit->move(110, 210); | 147 | WidthEdit->move(110, 210); |
148 | WidthEdit->resize(30, 20); | 148 | WidthEdit->resize(30, 20); |
149 | WidthEdit->setText("800"); | 149 | WidthEdit->setText("800"); |
150 | HeightEdit = new QLineEdit(this); | 150 | HeightEdit = new QLineEdit(this); |
151 | HeightEdit->move(140, 210); | 151 | HeightEdit->move(140, 210); |
152 | HeightEdit->resize(30, 20); | 152 | HeightEdit->resize(30, 20); |
153 | HeightEdit->setText("600"); | 153 | HeightEdit->setText("600"); |
154 | // add to list button | 154 | // add to list button |
155 | AddButton = new QPushButton(this); | 155 | AddButton = new QPushButton(this); |
156 | AddButton->move(180, 120); | 156 | AddButton->move(180, 120); |
157 | AddButton->resize(50, 20); | 157 | AddButton->resize(50, 20); |
158 | AddButton->setText("Add"); | 158 | AddButton->setText(tr("Add", "Add Connection")); |
159 | connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); | 159 | connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); |
160 | // change list item button | 160 | // change list item button |
161 | EditButton = new QPushButton(this); | 161 | EditButton = new QPushButton(this); |
162 | EditButton->move(180, 140); | 162 | EditButton->move(180, 140); |
163 | EditButton->resize(50, 20); | 163 | EditButton->resize(50, 20); |
164 | EditButton->setText("Edit"); | 164 | EditButton->setText(tr("Edit")); |
165 | connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); | 165 | connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); |
166 | // save to file button | 166 | // save to file button |
167 | SaveButton = new QPushButton(this); | 167 | SaveButton = new QPushButton(this); |
168 | SaveButton->move(180, 160); | 168 | SaveButton->move(180, 160); |
169 | SaveButton->resize(50, 20); | 169 | SaveButton->resize(50, 20); |
170 | SaveButton->setText("Save"); | 170 | SaveButton->setText(tr("Save")); |
171 | connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); | 171 | connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); |
172 | // remove an item button | 172 | // remove an item button |
173 | RemoveButton = new QPushButton(this); | 173 | RemoveButton = new QPushButton(this); |
174 | RemoveButton->move(180, 180); | 174 | RemoveButton->move(180, 180); |
175 | RemoveButton->resize(50, 20); | 175 | RemoveButton->resize(50, 20); |
176 | RemoveButton->setText("Remove"); | 176 | RemoveButton->setText(tr("Remove")); |
177 | connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); | 177 | connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); |
178 | // full screen check box | 178 | // full screen check box |
179 | FullScreenCheckBox = new QCheckBox(this, "Full Screen"); | 179 | FullScreenCheckBox = new QCheckBox(this, "Full Screen"); |
180 | FullScreenCheckBox->setText("Full Screen"); | 180 | FullScreenCheckBox->setText(tr("Full Screen")); |
181 | FullScreenCheckBox->move(10, 230); | 181 | FullScreenCheckBox->move(10, 230); |
182 | // ok button | 182 | // ok button |
183 | 183 | ||
184 | for (i = 0; i < 10; i++) | 184 | for (i = 0; i < 10; i++) |
185 | { | 185 | { |
186 | ConnectionList[i] = new QMyConnectionItem; | 186 | ConnectionList[i] = new QMyConnectionItem; |
187 | ConnectionList[i]->ServerName = ""; | 187 | ConnectionList[i]->ServerName = ""; |
188 | ConnectionList[i]->UserName = ""; | 188 | ConnectionList[i]->UserName = ""; |
189 | ConnectionList[i]->ServerIP = ""; | 189 | ConnectionList[i]->ServerIP = ""; |
190 | ConnectionList[i]->Width = 0; | 190 | ConnectionList[i]->Width = 0; |
191 | ConnectionList[i]->Height = 0; | 191 | ConnectionList[i]->Height = 0; |
192 | ConnectionList[i]->FullScreen = 0; | 192 | ConnectionList[i]->FullScreen = 0; |
193 | } | 193 | } |
194 | home = getenv("HOME"); | 194 | home = getenv("HOME"); |
195 | if (home != NULL) | 195 | if (home != NULL) |
196 | { | 196 | { |
197 | sprintf(Text, "%s/rdesktop.ini", home); | 197 | sprintf(Text, "%s/rdesktop.ini", home); |
198 | QFile* File = new QFile(Text); | 198 | QFile* File = new QFile(Text); |
199 | if (File->open(IO_ReadOnly)) | 199 | if (File->open(IO_ReadOnly)) |
200 | { | 200 | { |
201 | i = -1; | 201 | i = -1; |
202 | while (!File->atEnd()) | 202 | while (!File->atEnd()) |
203 | { | 203 | { |
204 | File->readLine(Line, 255); | 204 | File->readLine(Line, 255); |
205 | j = Line.find("="); | 205 | j = Line.find("="); |
206 | if (j > 0) | 206 | if (j > 0) |
207 | { | 207 | { |
208 | ItemName = Line.mid(0, j); | 208 | ItemName = Line.mid(0, j); |
209 | CleanString(&ItemName); | 209 | CleanString(&ItemName); |
210 | ItemValue = Line.mid(j + 1); | 210 | ItemValue = Line.mid(j + 1); |
211 | CleanString(&ItemValue); | 211 | CleanString(&ItemValue); |
212 | if (ItemName == "Server") | 212 | if (ItemName == "Server") |
213 | { | 213 | { |
214 | i++; | 214 | i++; |
215 | ConnectionList[i]->ServerName = ItemValue; | 215 | ConnectionList[i]->ServerName = ItemValue; |
216 | ListBox->insertItem(ItemValue); | 216 | ListBox->insertItem(ItemValue); |
217 | } | 217 | } |
218 | else if (ItemName == "UserName") | 218 | else if (ItemName == "UserName") |
219 | ConnectionList[i]->UserName = ItemValue; | 219 | ConnectionList[i]->UserName = ItemValue; |
220 | else if (ItemName == "Width") | 220 | else if (ItemName == "Width") |
221 | ConnectionList[i]->Width = ItemValue.toInt(); | 221 | ConnectionList[i]->Width = ItemValue.toInt(); |
222 | else if (ItemName == "Height") | 222 | else if (ItemName == "Height") |
223 | ConnectionList[i]->Height = ItemValue.toInt(); | 223 | ConnectionList[i]->Height = ItemValue.toInt(); |
224 | else if (ItemName == "IP") | 224 | else if (ItemName == "IP") |
225 | ConnectionList[i]->ServerIP = ItemValue; | 225 | ConnectionList[i]->ServerIP = ItemValue; |
226 | else if (ItemName == "FullScreen") | 226 | else if (ItemName == "FullScreen") |
227 | ConnectionList[i]->FullScreen = (ItemValue != "0"); | 227 | ConnectionList[i]->FullScreen = (ItemValue != "0"); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | delete File; | 231 | delete File; |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | //***************************************************************************** | 235 | //***************************************************************************** |
236 | QMyDialog::~QMyDialog() | 236 | QMyDialog::~QMyDialog() |
237 | { | 237 | { |
238 | QMyConnectionItem* Item; | 238 | QMyConnectionItem* Item; |
239 | int i; | 239 | int i; |
240 | 240 | ||
241 | for (i = 0; i < 10; i++) | 241 | for (i = 0; i < 10; i++) |
242 | { | 242 | { |
243 | Item = ConnectionList[i]; | 243 | Item = ConnectionList[i]; |
244 | delete Item; | 244 | delete Item; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | //***************************************************************************** | 248 | //***************************************************************************** |
249 | void QMyDialog::ComboChanged(int index) | 249 | void QMyDialog::ComboChanged(int index) |
250 | { | 250 | { |
251 | if (index == 0) | 251 | if (index == 0) |
252 | { | 252 | { |
253 | WidthEdit->setText("240"); | 253 | WidthEdit->setText("240"); |
254 | HeightEdit->setText("320"); | 254 | HeightEdit->setText("320"); |
255 | } | 255 | } |
256 | if (index == 1) | 256 | if (index == 1) |
257 | { | 257 | { |
258 | WidthEdit->setText("640"); | 258 | WidthEdit->setText("640"); |
259 | HeightEdit->setText("480"); | 259 | HeightEdit->setText("480"); |
260 | } | 260 | } |
261 | else if (index == 2) | 261 | else if (index == 2) |
262 | { | 262 | { |
263 | WidthEdit->setText("800"); | 263 | WidthEdit->setText("800"); |
264 | HeightEdit->setText("600"); | 264 | HeightEdit->setText("600"); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | //***************************************************************************** | 268 | //***************************************************************************** |
269 | void QMyDialog::accept() | 269 | void QMyDialog::accept() |
270 | { | 270 | { |
271 | ServerName = ServerNameEdit->text(); | 271 | ServerName = ServerNameEdit->text(); |
272 | UserName = UserNameEdit->text(); | 272 | UserName = UserNameEdit->text(); |
273 | Width = WidthEdit->text().toInt(); | 273 | Width = WidthEdit->text().toInt(); |
274 | Height = HeightEdit->text().toInt(); | 274 | Height = HeightEdit->text().toInt(); |
275 | ServerIP = IPEdit->text(); | 275 | ServerIP = IPEdit->text(); |
276 | FullScreen = FullScreenCheckBox->isChecked(); | 276 | FullScreen = FullScreenCheckBox->isChecked(); |
277 | 277 | ||
278 | QDialog::accept(); | 278 | QDialog::accept(); |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
282 | //***************************************************************************** | 282 | //***************************************************************************** |
283 | void QMyDialog::AddClicked() | 283 | void QMyDialog::AddClicked() |
284 | { | 284 | { |
285 | int i; | 285 | int i; |
286 | QMyConnectionItem* Item; | 286 | QMyConnectionItem* Item; |
287 | 287 | ||
288 | i = ListBox->count(); | 288 | i = ListBox->count(); |
289 | if (i < 10) | 289 | if (i < 10) |
290 | { | 290 | { |
291 | ListBox->insertItem(ServerNameEdit->text()); | 291 | ListBox->insertItem(ServerNameEdit->text()); |
292 | Item = ConnectionList[i]; | 292 | Item = ConnectionList[i]; |
293 | Item->ServerName = ServerNameEdit->text(); | 293 | Item->ServerName = ServerNameEdit->text(); |
294 | Item->UserName = UserNameEdit->text(); | 294 | Item->UserName = UserNameEdit->text(); |
295 | Item->Width = WidthEdit->text().toInt(); | 295 | Item->Width = WidthEdit->text().toInt(); |
296 | Item->Height = HeightEdit->text().toInt(); | 296 | Item->Height = HeightEdit->text().toInt(); |
297 | Item->ServerIP = IPEdit->text(); | 297 | Item->ServerIP = IPEdit->text(); |
298 | Item->FullScreen = FullScreenCheckBox->isChecked(); | 298 | Item->FullScreen = FullScreenCheckBox->isChecked(); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | //***************************************************************************** | 302 | //***************************************************************************** |
303 | void QMyDialog::EditClicked() | 303 | void QMyDialog::EditClicked() |
304 | { | 304 | { |
305 | int i; | 305 | int i; |
306 | QMyConnectionItem* Item; | 306 | QMyConnectionItem* Item; |
307 | 307 | ||
308 | i = ListBox->currentItem(); | 308 | i = ListBox->currentItem(); |
309 | if (i >= 0) | 309 | if (i >= 0) |
310 | { | 310 | { |
311 | Item = ConnectionList[i]; | 311 | Item = ConnectionList[i]; |
312 | Item->ServerName = ServerNameEdit->text(); | 312 | Item->ServerName = ServerNameEdit->text(); |
313 | Item->UserName = UserNameEdit->text(); | 313 | Item->UserName = UserNameEdit->text(); |
314 | Item->Width = WidthEdit->text().toInt(); | 314 | Item->Width = WidthEdit->text().toInt(); |
315 | Item->Height = HeightEdit->text().toInt(); | 315 | Item->Height = HeightEdit->text().toInt(); |
316 | Item->ServerIP = IPEdit->text(); | 316 | Item->ServerIP = IPEdit->text(); |
317 | Item->FullScreen = FullScreenCheckBox->isChecked(); | 317 | Item->FullScreen = FullScreenCheckBox->isChecked(); |
318 | ListBox->changeItem(ServerNameEdit->text(), i); | 318 | ListBox->changeItem(ServerNameEdit->text(), i); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | //***************************************************************************** | 322 | //***************************************************************************** |
323 | void WriteString(QFile* File, QString* Line) | 323 | void WriteString(QFile* File, QString* Line) |
324 | { | 324 | { |
325 | File->writeBlock((const char*)(*Line), Line->length()); | 325 | File->writeBlock((const char*)(*Line), Line->length()); |
326 | } | 326 | } |
327 | 327 | ||
328 | //***************************************************************************** | 328 | //***************************************************************************** |
329 | void QMyDialog::SaveClicked() | 329 | void QMyDialog::SaveClicked() |
330 | { | 330 | { |
331 | int i, j; | 331 | int i, j; |
332 | QMyConnectionItem* Item; | 332 | QMyConnectionItem* Item; |
333 | QString Line; | 333 | QString Line; |
334 | char* home; | 334 | char* home; |
335 | char Text[256]; | 335 | char Text[256]; |
336 | QFile* File; | 336 | QFile* File; |
337 | 337 | ||
338 | home = getenv("HOME"); | 338 | home = getenv("HOME"); |
339 | if (home != NULL) | 339 | if (home != NULL) |
340 | { | 340 | { |
341 | sprintf(Text, "%s/rdesktop.ini", home); | 341 | sprintf(Text, "%s/rdesktop.ini", home); |
342 | File = new QFile(Text); | 342 | File = new QFile(Text); |
343 | if (File->open(IO_Truncate | IO_ReadWrite)) | 343 | if (File->open(IO_Truncate | IO_ReadWrite)) |
344 | { | 344 | { |
345 | i = ListBox->count(); | 345 | i = ListBox->count(); |
346 | for (j = 0; j < i; j++) | 346 | for (j = 0; j < i; j++) |
347 | { | 347 | { |
348 | Item = ConnectionList[j]; | 348 | Item = ConnectionList[j]; |
349 | Line = "Server="; | 349 | Line = "Server="; |
350 | Line += Item->ServerName; | 350 | Line += Item->ServerName; |
351 | Line += (char)10; | 351 | Line += (char)10; |
352 | WriteString(File, &Line); | 352 | WriteString(File, &Line); |
353 | Line = "UserName="; | 353 | Line = "UserName="; |
354 | Line += Item->UserName; | 354 | Line += Item->UserName; |
355 | Line += (char)10; | 355 | Line += (char)10; |
356 | WriteString(File, &Line); | 356 | WriteString(File, &Line); |
357 | Line = "Width="; | 357 | Line = "Width="; |
358 | sprintf(Text, "%d", Item->Width); | 358 | sprintf(Text, "%d", Item->Width); |
359 | Line += Text; | 359 | Line += Text; |
360 | Line += (char)10; | 360 | Line += (char)10; |
361 | WriteString(File, &Line); | 361 | WriteString(File, &Line); |
362 | Line = "Height="; | 362 | Line = "Height="; |
363 | sprintf(Text, "%d", Item->Height); | 363 | sprintf(Text, "%d", Item->Height); |
364 | Line += Text; | 364 | Line += Text; |
365 | Line += (char)10; | 365 | Line += (char)10; |
366 | WriteString(File, &Line); | 366 | WriteString(File, &Line); |
367 | Line = "IP="; | 367 | Line = "IP="; |
368 | Line += Item->ServerIP; | 368 | Line += Item->ServerIP; |
369 | Line += (char)10; | 369 | Line += (char)10; |
370 | WriteString(File, &Line); | 370 | WriteString(File, &Line); |
371 | Line = "FullScreen="; | 371 | Line = "FullScreen="; |
372 | if (Item->FullScreen) | 372 | if (Item->FullScreen) |
373 | Line += "1"; | 373 | Line += "1"; |
374 | else | 374 | else |
375 | Line += "0"; | 375 | Line += "0"; |
376 | Line += (char)10; | 376 | Line += (char)10; |
377 | WriteString(File, &Line); | 377 | WriteString(File, &Line); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | File->flush(); | 380 | File->flush(); |
381 | File->close(); | 381 | File->close(); |
382 | delete File; | 382 | delete File; |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | //***************************************************************************** | 386 | //***************************************************************************** |
387 | void QMyDialog::RemoveClicked() | 387 | void QMyDialog::RemoveClicked() |
388 | { | 388 | { |
389 | int i, j, c; | 389 | int i, j, c; |
390 | QMyConnectionItem* Item1; | 390 | QMyConnectionItem* Item1; |
391 | QMyConnectionItem* Item2; | 391 | QMyConnectionItem* Item2; |
392 | 392 | ||
393 | i = ListBox->currentItem(); | 393 | i = ListBox->currentItem(); |
394 | if (i >= 0) | 394 | if (i >= 0) |
395 | { | 395 | { |
396 | c = ListBox->count(); | 396 | c = ListBox->count(); |
397 | for (j = i; j < c - 1; j++) | 397 | for (j = i; j < c - 1; j++) |
398 | { | 398 | { |
399 | Item1 = ConnectionList[i]; | 399 | Item1 = ConnectionList[i]; |
400 | Item2 = ConnectionList[i + 1]; | 400 | Item2 = ConnectionList[i + 1]; |
401 | Item1->ServerName = Item2->ServerName; | 401 | Item1->ServerName = Item2->ServerName; |
402 | Item1->UserName = Item2->UserName; | 402 | Item1->UserName = Item2->UserName; |
403 | Item1->Width = Item2->Width; | 403 | Item1->Width = Item2->Width; |
404 | Item1->Height = Item2->Height; | 404 | Item1->Height = Item2->Height; |
405 | Item1->ServerIP = Item2->ServerIP; | 405 | Item1->ServerIP = Item2->ServerIP; |
406 | Item1->FullScreen = Item2->FullScreen; | 406 | Item1->FullScreen = Item2->FullScreen; |
407 | } | 407 | } |
408 | ListBox->removeItem(i); | 408 | ListBox->removeItem(i); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | //***************************************************************************** | 412 | //***************************************************************************** |
413 | void QMyDialog::ListBoxChanged() | 413 | void QMyDialog::ListBoxChanged() |
414 | { | 414 | { |
415 | int i; | 415 | int i; |
416 | QMyConnectionItem* Item; | 416 | QMyConnectionItem* Item; |
417 | char Text[100]; | 417 | char Text[100]; |
418 | 418 | ||
419 | i = ListBox->currentItem(); | 419 | i = ListBox->currentItem(); |
420 | if (i >= 0 && i < 10) | 420 | if (i >= 0 && i < 10) |
421 | { | 421 | { |
422 | Item = ConnectionList[i]; | 422 | Item = ConnectionList[i]; |
423 | ServerNameEdit->setText(Item->ServerName); | 423 | ServerNameEdit->setText(Item->ServerName); |
424 | UserNameEdit->setText(Item->UserName); | 424 | UserNameEdit->setText(Item->UserName); |
425 | sprintf(Text, "%d", Item->Width); | 425 | sprintf(Text, "%d", Item->Width); |
426 | WidthEdit->setText(Text); | 426 | WidthEdit->setText(Text); |
427 | sprintf(Text, "%d", Item->Height); | 427 | sprintf(Text, "%d", Item->Height); |
428 | HeightEdit->setText(Text); | 428 | HeightEdit->setText(Text); |
429 | IPEdit->setText(Item->ServerIP); | 429 | IPEdit->setText(Item->ServerIP); |
430 | FullScreenCheckBox->setChecked(Item->FullScreen != 0); | 430 | FullScreenCheckBox->setChecked(Item->FullScreen != 0); |
431 | } | 431 | } |
432 | } | 432 | } |
433 | 433 | ||
434 | //***************************************************************************** | 434 | //***************************************************************************** |
435 | void QMyDialog::ListBoxSelected(int /*index*/) | 435 | void QMyDialog::ListBoxSelected(int /*index*/) |
436 | { | 436 | { |
437 | } | 437 | } |
438 | 438 | ||
439 | //***************************************************************************** | 439 | //***************************************************************************** |
440 | void GetScanCode(QKeyEvent* e, int* ScanCode, int* code) | 440 | void GetScanCode(QKeyEvent* e, int* ScanCode, int* code) |
441 | { | 441 | { |
442 | int key; | 442 | int key; |
443 | int mod; | 443 | int mod; |
444 | int ascii; | 444 | int ascii; |
445 | 445 | ||
446 | key = e->key(); | 446 | key = e->key(); |
447 | mod = e->state(); | 447 | mod = e->state(); |
448 | ascii = e->ascii(); | 448 | ascii = e->ascii(); |
449 | 449 | ||
450 | *ScanCode = 0; | 450 | *ScanCode = 0; |
451 | *code = mod; // 8 shift, 16 control, 32 alt | 451 | *code = mod; // 8 shift, 16 control, 32 alt |
452 | 452 | ||
453 | switch (key) | 453 | switch (key) |
454 | { | 454 | { |
455 | case 4096: // esc | 455 | case 4096: // esc |
456 | case 4097: // tab | 456 | case 4097: // tab |
457 | case 4099: // backspace | 457 | case 4099: // backspace |
458 | case 4100: // enter | 458 | case 4100: // enter |
459 | case 4101: // enter | 459 | case 4101: // enter |
460 | case 4103: // delete | 460 | case 4103: // delete |
461 | ascii = 0; | 461 | ascii = 0; |
462 | } | 462 | } |
463 | 463 | ||
464 | if (ascii == 0) | 464 | if (ascii == 0) |
465 | { | 465 | { |
466 | switch (key) | 466 | switch (key) |
467 | { | 467 | { |
468 | case 4096: *ScanCode = 0x01; break; // esc | 468 | case 4096: *ScanCode = 0x01; break; // esc |
469 | case 4097: *ScanCode = 0x0f; break; // tab | 469 | case 4097: *ScanCode = 0x0f; break; // tab |
470 | case 4099: *ScanCode = 0x0e; break; // backspace | 470 | case 4099: *ScanCode = 0x0e; break; // backspace |
471 | case 4100: *ScanCode = 0x1c; break; // enter | 471 | case 4100: *ScanCode = 0x1c; break; // enter |
472 | case 4101: *ScanCode = 0x1c; break; // enter | 472 | case 4101: *ScanCode = 0x1c; break; // enter |
473 | case 4112: *ScanCode = 0xc7; break; // home | 473 | case 4112: *ScanCode = 0xc7; break; // home |
474 | case 4113: *ScanCode = 0xcf; break; // end | 474 | case 4113: *ScanCode = 0xcf; break; // end |
475 | case 4102: *ScanCode = 0xd2; break; // insert | 475 | case 4102: *ScanCode = 0xd2; break; // insert |
476 | case 4103: *ScanCode = 0xd3; break; // delete | 476 | case 4103: *ScanCode = 0xd3; break; // delete |
477 | case 4118: *ScanCode = 0xc9; break; // page up | 477 | case 4118: *ScanCode = 0xc9; break; // page up |
478 | case 4119: *ScanCode = 0xd1; break; // page down | 478 | case 4119: *ScanCode = 0xd1; break; // page down |
479 | case 4117: *ScanCode = 0xd0; break; // down arrow | 479 | case 4117: *ScanCode = 0xd0; break; // down arrow |
480 | case 4115: *ScanCode = 0xc8; break; // up arrow | 480 | case 4115: *ScanCode = 0xc8; break; // up arrow |
481 | case 4114: *ScanCode = 0xcb; break; // left arrow | 481 | case 4114: *ScanCode = 0xcb; break; // left arrow |
482 | case 4116: *ScanCode = 0xcd; break; // right arrow | 482 | case 4116: *ScanCode = 0xcd; break; // right arrow |
483 | case 4128: *ScanCode = 0x2a; break; // shift | 483 | case 4128: *ScanCode = 0x2a; break; // shift |
484 | case 4131: *ScanCode = 0x38; break; // alt | 484 | case 4131: *ScanCode = 0x38; break; // alt |
485 | case 4129: *ScanCode = 0x1d; break; // ctrl | 485 | case 4129: *ScanCode = 0x1d; break; // ctrl |
486 | } | 486 | } |
487 | if (*ScanCode != 0) | 487 | if (*ScanCode != 0) |
488 | return; | 488 | return; |
489 | } | 489 | } |
490 | 490 | ||
491 | switch (ascii) | 491 | switch (ascii) |
492 | { | 492 | { |
493 | // first row | 493 | // first row |
494 | case 'q': *ScanCode = 0x10; break; | 494 | case 'q': *ScanCode = 0x10; break; |
495 | case 'Q': *ScanCode = 0x10; *code |= 8; break; | 495 | case 'Q': *ScanCode = 0x10; *code |= 8; break; |
496 | case '1': *ScanCode = 0x02; break; | 496 | case '1': *ScanCode = 0x02; break; |
497 | case 'w': *ScanCode = 0x11; break; | 497 | case 'w': *ScanCode = 0x11; break; |
498 | case 'W': *ScanCode = 0x11; *code |= 8; break; | 498 | case 'W': *ScanCode = 0x11; *code |= 8; break; |
499 | case '2': *ScanCode = 0x03; break; | 499 | case '2': *ScanCode = 0x03; break; |
500 | case 'e': *ScanCode = 0x12; break; | 500 | case 'e': *ScanCode = 0x12; break; |
501 | case 'E': *ScanCode = 0x12; *code |= 8; break; | 501 | case 'E': *ScanCode = 0x12; *code |= 8; break; |
502 | case '3': *ScanCode = 0x04; break; | 502 | case '3': *ScanCode = 0x04; break; |
503 | case 'r': *ScanCode = 0x13; break; | 503 | case 'r': *ScanCode = 0x13; break; |
504 | case 'R': *ScanCode = 0x13; *code |= 8; break; | 504 | case 'R': *ScanCode = 0x13; *code |= 8; break; |
505 | case '4': *ScanCode = 0x05; break; | 505 | case '4': *ScanCode = 0x05; break; |
506 | case 't': *ScanCode = 0x14; break; | 506 | case 't': *ScanCode = 0x14; break; |
507 | case 'T': *ScanCode = 0x14; *code |= 8; break; | 507 | case 'T': *ScanCode = 0x14; *code |= 8; break; |
508 | case '5': *ScanCode = 0x06; break; | 508 | case '5': *ScanCode = 0x06; break; |
509 | case 'y': *ScanCode = 0x15; break; | 509 | case 'y': *ScanCode = 0x15; break; |
510 | case 'Y': *ScanCode = 0x15; *code |= 8; break; | 510 | case 'Y': *ScanCode = 0x15; *code |= 8; break; |
511 | case '6': *ScanCode = 0x07; break; | 511 | case '6': *ScanCode = 0x07; break; |
512 | case 'u': *ScanCode = 0x16; break; | 512 | case 'u': *ScanCode = 0x16; break; |
513 | case 'U': *ScanCode = 0x16; *code |= 8; break; | 513 | case 'U': *ScanCode = 0x16; *code |= 8; break; |
514 | case '7': *ScanCode = 0x08; break; | 514 | case '7': *ScanCode = 0x08; break; |
515 | case 'i': *ScanCode = 0x17; break; | 515 | case 'i': *ScanCode = 0x17; break; |
516 | case 'I': *ScanCode = 0x17; *code |= 8; break; | 516 | case 'I': *ScanCode = 0x17; *code |= 8; break; |
517 | case '8': *ScanCode = 0x09; break; | 517 | case '8': *ScanCode = 0x09; break; |
518 | case 'o': *ScanCode = 0x18; break; | 518 | case 'o': *ScanCode = 0x18; break; |
519 | case 'O': *ScanCode = 0x18; *code |= 8; break; | 519 | case 'O': *ScanCode = 0x18; *code |= 8; break; |
520 | case '9': *ScanCode = 0x0a; break; | 520 | case '9': *ScanCode = 0x0a; break; |
521 | case 'p': *ScanCode = 0x19; break; | 521 | case 'p': *ScanCode = 0x19; break; |
522 | case 'P': *ScanCode = 0x19; *code |= 8; break; | 522 | case 'P': *ScanCode = 0x19; *code |= 8; break; |
523 | case '0': *ScanCode = 0x0b; break; | 523 | case '0': *ScanCode = 0x0b; break; |
524 | // second row | 524 | // second row |
525 | case 'a': *ScanCode = 0x1e; break; | 525 | case 'a': *ScanCode = 0x1e; break; |
526 | case 'A': *ScanCode = 0x1e; *code |= 8; break; | 526 | case 'A': *ScanCode = 0x1e; *code |= 8; break; |
527 | case '!': *ScanCode = 0x02; *code |= 8; break; | 527 | case '!': *ScanCode = 0x02; *code |= 8; break; |
528 | case 's': *ScanCode = 0x1f; break; | 528 | case 's': *ScanCode = 0x1f; break; |
529 | case 'S': *ScanCode = 0x1f; *code |= 8; break; | 529 | case 'S': *ScanCode = 0x1f; *code |= 8; break; |
530 | case '@': *ScanCode = 0x03; *code |= 8; break; | 530 | case '@': *ScanCode = 0x03; *code |= 8; break; |
531 | case 'd': *ScanCode = 0x20; break; | 531 | case 'd': *ScanCode = 0x20; break; |
532 | case 'D': *ScanCode = 0x20; *code |= 8; break; | 532 | case 'D': *ScanCode = 0x20; *code |= 8; break; |
533 | case '#': *ScanCode = 0x04; *code |= 8; break; | 533 | case '#': *ScanCode = 0x04; *code |= 8; break; |
534 | case 'f': *ScanCode = 0x21; break; | 534 | case 'f': *ScanCode = 0x21; break; |
535 | case 'F': *ScanCode = 0x21; *code |= 8; break; | 535 | case 'F': *ScanCode = 0x21; *code |= 8; break; |
536 | case '$': *ScanCode = 0x05; *code |= 8; break; | 536 | case '$': *ScanCode = 0x05; *code |= 8; break; |
537 | case 'g': *ScanCode = 0x22; break; | 537 | case 'g': *ScanCode = 0x22; break; |
538 | case 'G': *ScanCode = 0x22; *code |= 8; break; | 538 | case 'G': *ScanCode = 0x22; *code |= 8; break; |
539 | case '%': *ScanCode = 0x06; *code |= 8; break; | 539 | case '%': *ScanCode = 0x06; *code |= 8; break; |
540 | case 'h': *ScanCode = 0x23; break; | 540 | case 'h': *ScanCode = 0x23; break; |
541 | case 'H': *ScanCode = 0x23; *code |= 8; break; | 541 | case 'H': *ScanCode = 0x23; *code |= 8; break; |
542 | case '_': *ScanCode = 0x0c; *code |= 8; break; | 542 | case '_': *ScanCode = 0x0c; *code |= 8; break; |
543 | case 'j': *ScanCode = 0x24; break; | 543 | case 'j': *ScanCode = 0x24; break; |
544 | case 'J': *ScanCode = 0x24; *code |= 8; break; | 544 | case 'J': *ScanCode = 0x24; *code |= 8; break; |
545 | case '&': *ScanCode = 0x08; *code |= 8; break; | 545 | case '&': *ScanCode = 0x08; *code |= 8; break; |
546 | case 'k': *ScanCode = 0x25; break; | 546 | case 'k': *ScanCode = 0x25; break; |
547 | case 'K': *ScanCode = 0x25; *code |= 8; break; | 547 | case 'K': *ScanCode = 0x25; *code |= 8; break; |
548 | case '*': *ScanCode = 0x09; *code |= 8; break; | 548 | case '*': *ScanCode = 0x09; *code |= 8; break; |
549 | case 'l': *ScanCode = 0x26; break; | 549 | case 'l': *ScanCode = 0x26; break; |
550 | case 'L': *ScanCode = 0x26; *code |= 8; break; | 550 | case 'L': *ScanCode = 0x26; *code |= 8; break; |
551 | case '(': *ScanCode = 0x0a; *code |= 8; break; | 551 | case '(': *ScanCode = 0x0a; *code |= 8; break; |
552 | // case 8: *ScanCode = 0x0e; break; // backspace | 552 | // case 8: *ScanCode = 0x0e; break; // backspace |
553 | // third row | 553 | // third row |
554 | case 'z': *ScanCode = 0x2c; break; | 554 | case 'z': *ScanCode = 0x2c; break; |
555 | case 'Z': *ScanCode = 0x2c; *code |= 8; break; | 555 | case 'Z': *ScanCode = 0x2c; *code |= 8; break; |
556 | case 'x': *ScanCode = 0x2d; break; | 556 | case 'x': *ScanCode = 0x2d; break; |
557 | case 'X': *ScanCode = 0x2d; *code |= 8; break; | 557 | case 'X': *ScanCode = 0x2d; *code |= 8; break; |
558 | case 'c': *ScanCode = 0x2e; break; | 558 | case 'c': *ScanCode = 0x2e; break; |
559 | case 'C': *ScanCode = 0x2e; *code |= 8; break; | 559 | case 'C': *ScanCode = 0x2e; *code |= 8; break; |
560 | case 'v': *ScanCode = 0x2f; break; | 560 | case 'v': *ScanCode = 0x2f; break; |
561 | case 'V': *ScanCode = 0x2f; *code |= 8; break; | 561 | case 'V': *ScanCode = 0x2f; *code |= 8; break; |
562 | case 'b': *ScanCode = 0x30; break; | 562 | case 'b': *ScanCode = 0x30; break; |
563 | case 'B': *ScanCode = 0x30; *code |= 8; break; | 563 | case 'B': *ScanCode = 0x30; *code |= 8; break; |
564 | case '-': *ScanCode = 0x0c; break; | 564 | case '-': *ScanCode = 0x0c; break; |
565 | case 'n': *ScanCode = 0x31; break; | 565 | case 'n': *ScanCode = 0x31; break; |
566 | case 'N': *ScanCode = 0x31; *code |= 8; break; | 566 | case 'N': *ScanCode = 0x31; *code |= 8; break; |
567 | case '+': *ScanCode = 0x0d; *code |= 8; break; | 567 | case '+': *ScanCode = 0x0d; *code |= 8; break; |
568 | case 'm': *ScanCode = 0x32; break; | 568 | case 'm': *ScanCode = 0x32; break; |
569 | case 'M': *ScanCode = 0x32; *code |= 8; break; | 569 | case 'M': *ScanCode = 0x32; *code |= 8; break; |
570 | case '=': *ScanCode = 0x0d; break; | 570 | case '=': *ScanCode = 0x0d; break; |
571 | case ',': *ScanCode = 0x33; break; | 571 | case ',': *ScanCode = 0x33; break; |
572 | case ';': *ScanCode = 0x27; break; | 572 | case ';': *ScanCode = 0x27; break; |
573 | case ')': *ScanCode = 0x0b; *code |= 8; break; | 573 | case ')': *ScanCode = 0x0b; *code |= 8; break; |
574 | // fourth row | 574 | // fourth row |
575 | // case 9: *ScanCode = 0x0f; break; // tab | 575 | // case 9: *ScanCode = 0x0f; break; // tab |
576 | case '/': *ScanCode = 0x35; break; | 576 | case '/': *ScanCode = 0x35; break; |
577 | case '?': *ScanCode = 0x35; *code |= 8; break; | 577 | case '?': *ScanCode = 0x35; *code |= 8; break; |
578 | case ' ': *ScanCode = 0x39; break; | 578 | case ' ': *ScanCode = 0x39; break; |
579 | case '\'': *ScanCode = 0x28; break; | 579 | case '\'': *ScanCode = 0x28; break; |
580 | case '"': *ScanCode = 0x28; *code |= 8; break; | 580 | case '"': *ScanCode = 0x28; *code |= 8; break; |
581 | case '~': *ScanCode = 0x29; *code |= 8; break; | 581 | case '~': *ScanCode = 0x29; *code |= 8; break; |
582 | case '.': *ScanCode = 0x34; break; | 582 | case '.': *ScanCode = 0x34; break; |
583 | case ':': *ScanCode = 0x27; *code |= 8; break; | 583 | case ':': *ScanCode = 0x27; *code |= 8; break; |
584 | case '<': *ScanCode = 0x33; *code |= 8; break; | 584 | case '<': *ScanCode = 0x33; *code |= 8; break; |
585 | // case 13: *ScanCode = 0x1c; break; // enter | 585 | // case 13: *ScanCode = 0x1c; break; // enter |
586 | case '>': *ScanCode = 0x34; *code |= 8; break; | 586 | case '>': *ScanCode = 0x34; *code |= 8; break; |
587 | // others | 587 | // others |
588 | // case 27: *ScanCode = 0x01; break; // esc | 588 | // case 27: *ScanCode = 0x01; break; // esc |
589 | case '`': *ScanCode = 0x29; break; | 589 | case '`': *ScanCode = 0x29; break; |
590 | case '^': *ScanCode = 0x07; *code |= 8; break; | 590 | case '^': *ScanCode = 0x07; *code |= 8; break; |
591 | case '[': *ScanCode = 0x1a; break; | 591 | case '[': *ScanCode = 0x1a; break; |
592 | case '{': *ScanCode = 0x1a; *code |= 8; break; | 592 | case '{': *ScanCode = 0x1a; *code |= 8; break; |
593 | case ']': *ScanCode = 0x1b; break; | 593 | case ']': *ScanCode = 0x1b; break; |
594 | case '}': *ScanCode = 0x1b; *code |= 8; break; | 594 | case '}': *ScanCode = 0x1b; *code |= 8; break; |
595 | case '\\': *ScanCode = 0x2b; break; | 595 | case '\\': *ScanCode = 0x2b; break; |
596 | case '|': *ScanCode = 0x2b; *code |= 8; break; | 596 | case '|': *ScanCode = 0x2b; *code |= 8; break; |
597 | // ctrl keys | 597 | // ctrl keys |
598 | case 1: *ScanCode = 0x1e; *code |= 16; break; // a | 598 | case 1: *ScanCode = 0x1e; *code |= 16; break; // a |
599 | case 2: *ScanCode = 0x30; *code |= 16; break; // b | 599 | case 2: *ScanCode = 0x30; *code |= 16; break; // b |
600 | } | 600 | } |
601 | 601 | ||
602 | if (*ScanCode == 0 && key < 3000) | 602 | if (*ScanCode == 0 && key < 3000) |
603 | printf("unknown key %d mod %d ascii %d\n", key, mod, ascii); | 603 | printf("unknown key %d mod %d ascii %d\n", key, mod, ascii); |
604 | 604 | ||
605 | } | 605 | } |
606 | 606 | ||
607 | //***************************************************************************** | 607 | //***************************************************************************** |
608 | QMyScrollView::QMyScrollView() : QScrollView() | 608 | QMyScrollView::QMyScrollView() : QScrollView() |
609 | { | 609 | { |
610 | } | 610 | } |
611 | 611 | ||
612 | //***************************************************************************** | 612 | //***************************************************************************** |
613 | QMyScrollView::~QMyScrollView() | 613 | QMyScrollView::~QMyScrollView() |
614 | { | 614 | { |
615 | } | 615 | } |
616 | 616 | ||
617 | //***************************************************************************** | 617 | //***************************************************************************** |
618 | void QMyScrollView::keyPressEvent(QKeyEvent* e) | 618 | void QMyScrollView::keyPressEvent(QKeyEvent* e) |
619 | { | 619 | { |
620 | int ScanCode, code; | 620 | int ScanCode, code; |
621 | GetScanCode(e, &ScanCode, &code); | 621 | GetScanCode(e, &ScanCode, &code); |
622 | if (ScanCode != 0) | 622 | if (ScanCode != 0) |
623 | { | 623 | { |
624 | if (code & 8) // send shift | 624 | if (code & 8) // send shift |
625 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0); | 625 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0); |
626 | if (code & 16) // send control | 626 | if (code & 16) // send control |
627 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0); | 627 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0); |
628 | if (code & 32) // send alt | 628 | if (code & 32) // send alt |
629 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0); | 629 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0); |
630 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0); | 630 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0); |
631 | e->accept(); | 631 | e->accept(); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | 634 | ||
635 | //***************************************************************************** | 635 | //***************************************************************************** |
636 | void QMyScrollView::keyReleaseEvent(QKeyEvent* e) | 636 | void QMyScrollView::keyReleaseEvent(QKeyEvent* e) |
637 | { | 637 | { |
638 | int ScanCode, code; | 638 | int ScanCode, code; |
639 | GetScanCode(e, &ScanCode, &code); | 639 | GetScanCode(e, &ScanCode, &code); |
640 | if (ScanCode != 0) | 640 | if (ScanCode != 0) |
641 | { | 641 | { |
642 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0); | 642 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0); |
643 | if (code & 8) // send shift | 643 | if (code & 8) // send shift |
644 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); | 644 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); |
645 | if (code & 16) // send control | 645 | if (code & 16) // send control |
646 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); | 646 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); |
647 | if (code & 32) // send alt | 647 | if (code & 32) // send alt |
648 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); | 648 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); |
649 | e->accept(); | 649 | e->accept(); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | 652 | ||
653 | //***************************************************************************** | 653 | //***************************************************************************** |
654 | void QMyScrollView::showEvent(QShowEvent* e) | 654 | void QMyScrollView::showEvent(QShowEvent* e) |
655 | { | 655 | { |
656 | QScrollView::showEvent(e); | 656 | QScrollView::showEvent(e); |
657 | } | 657 | } |
658 | 658 | ||
659 | //***************************************************************************** | 659 | //***************************************************************************** |
660 | void QMyScrollView::show() | 660 | void QMyScrollView::show() |
661 | { | 661 | { |
662 | QScrollView::show(); | 662 | QScrollView::show(); |
663 | } | 663 | } |
664 | 664 | ||
665 | //***************************************************************************** | 665 | //***************************************************************************** |
666 | void QMyScrollView::polish() | 666 | void QMyScrollView::polish() |
667 | { | 667 | { |
668 | QScrollView::polish(); | 668 | QScrollView::polish(); |
669 | } | 669 | } |
670 | 670 | ||
671 | //***************************************************************************** | 671 | //***************************************************************************** |
672 | void QMyScrollView::timerEvent(QTimerEvent* e) | 672 | void QMyScrollView::timerEvent(QTimerEvent* e) |
673 | { | 673 | { |
674 | QScrollView::timerEvent(e); | 674 | QScrollView::timerEvent(e); |
675 | killTimer(timer_id); | 675 | killTimer(timer_id); |
676 | QMyDialog* d; | 676 | QMyDialog* d; |
677 | QWidget* Desktop; | 677 | QWidget* Desktop; |
678 | int dw; | 678 | int dw; |
679 | int dh; | 679 | int dh; |
680 | 680 | ||
681 | d = new QMyDialog(this); | 681 | d = new QMyDialog(this); |
682 | if (d->exec() == 1) // ok clicked | 682 | if (d->exec() == 1) // ok clicked |
683 | { | 683 | { |
684 | flags = RDP_LOGON_NORMAL; | 684 | flags = RDP_LOGON_NORMAL; |
685 | g_width = d->Width; | 685 | g_width = d->Width; |
686 | g_height = d->Height; | 686 | g_height = d->Height; |
687 | fullscreen = d->FullScreen; | 687 | fullscreen = d->FullScreen; |
688 | sprintf(server, "%s", (const char*)d->ServerIP); | 688 | sprintf(server, "%s", (const char*)d->ServerIP); |
689 | sprintf(username, "%s", (const char*)d->UserName); | 689 | sprintf(username, "%s", (const char*)d->UserName); |
690 | if (!rdp_connect(server, flags, domain, password, shell, directory)) | 690 | if (!rdp_connect(server, flags, domain, password, shell, directory)) |
691 | { | 691 | { |
692 | delete d; | 692 | delete d; |
693 | SV->close(); | 693 | SV->close(); |
694 | return; | 694 | return; |
695 | } | 695 | } |
696 | BS = (uint8*)xmalloc(g_width * g_height); | 696 | BS = (uint8*)xmalloc(g_width * g_height); |
697 | memset(BS, 0, g_width * g_height); | 697 | memset(BS, 0, g_width * g_height); |
698 | clipx = 0; | 698 | clipx = 0; |
699 | clipy = 0; | 699 | clipy = 0; |
700 | clipcx = g_width; | 700 | clipcx = g_width; |
701 | clipcy = g_height; | 701 | clipcy = g_height; |
702 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); | 702 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); |
703 | memset(CM, 0, sizeof(struct QColorMap)); | 703 | memset(CM, 0, sizeof(struct QColorMap)); |
704 | CM->NumColors = 256; | 704 | CM->NumColors = 256; |
705 | MW = new QMyMainWindow(); | 705 | MW = new QMyMainWindow(); |
706 | MW->resize(g_width, g_height); | 706 | MW->resize(g_width, g_height); |
707 | MW->show(); | 707 | MW->show(); |
708 | SV->addChild(MW); | 708 | SV->addChild(MW); |
709 | MW->setMouseTracking(true); | 709 | MW->setMouseTracking(true); |
710 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); | 710 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); |
711 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); | 711 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); |
712 | if (fullscreen) | 712 | if (fullscreen) |
713 | { | 713 | { |
714 | Desktop = App->desktop(); | 714 | Desktop = App->desktop(); |
715 | dw = Desktop->width(); | 715 | dw = Desktop->width(); |
716 | dh = Desktop->height(); | 716 | dh = Desktop->height(); |
717 | if (dw == g_width && dh == g_height) | 717 | if (dw == g_width && dh == g_height) |
718 | MW->resize(g_width - 4, g_height - 4); | 718 | MW->resize(g_width - 4, g_height - 4); |
719 | SV->showFullScreen(); | 719 | SV->showFullScreen(); |
720 | } | 720 | } |
721 | delete d; | 721 | delete d; |
722 | } | 722 | } |
723 | else // cancel clicked | 723 | else // cancel clicked |
724 | { | 724 | { |
725 | delete d; | 725 | delete d; |
726 | SV->close(); | 726 | SV->close(); |
727 | } | 727 | } |
728 | } | 728 | } |
729 | 729 | ||
730 | //***************************************************************************** | 730 | //***************************************************************************** |
731 | QMyMainWindow::QMyMainWindow() : QWidget(SV->viewport()) | 731 | QMyMainWindow::QMyMainWindow() : QWidget(SV->viewport()) |
732 | { | 732 | { |
733 | PopupMenu = new QPopupMenu(this); | 733 | PopupMenu = new QPopupMenu(this); |
734 | PopupMenu->insertItem("Right click", 1, 0); | 734 | PopupMenu->insertItem("Right click", 1, 0); |
735 | PopupMenu->insertItem("Toggle fullscreen", 2, 1); | 735 | PopupMenu->insertItem("Toggle fullscreen", 2, 1); |
736 | PopupMenu->insertItem("Reset keyboard", 3, 2); | 736 | PopupMenu->insertItem("Reset keyboard", 3, 2); |
737 | PopupMenu->insertItem("Double click", 4, 3); | 737 | PopupMenu->insertItem("Double click", 4, 3); |
738 | connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); | 738 | connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); |
739 | } | 739 | } |
740 | 740 | ||
741 | //***************************************************************************** | 741 | //***************************************************************************** |
742 | QMyMainWindow::~QMyMainWindow() | 742 | QMyMainWindow::~QMyMainWindow() |
743 | { | 743 | { |
744 | delete PopupMenu; | 744 | delete PopupMenu; |
745 | } | 745 | } |
746 | 746 | ||
747 | //***************************************************************************** | 747 | //***************************************************************************** |
748 | void QMyMainWindow::timerEvent(QTimerEvent* e) | 748 | void QMyMainWindow::timerEvent(QTimerEvent* e) |
749 | { | 749 | { |
750 | QWidget::timerEvent(e); | 750 | QWidget::timerEvent(e); |
751 | if (e->timerId() == timer_id) | 751 | if (e->timerId() == timer_id) |
752 | { | 752 | { |
753 | // send mouse up | 753 | // send mouse up |
754 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); | 754 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
755 | // if in fullscreen, take it out or the menu won't work | 755 | // if in fullscreen, take it out or the menu won't work |
756 | if (fullscreen) | 756 | if (fullscreen) |
757 | { | 757 | { |
758 | fullscreen = 0; | 758 | fullscreen = 0; |
759 | SV->showNormal(); | 759 | SV->showNormal(); |
760 | SV->showMaximized(); | 760 | SV->showMaximized(); |
761 | } | 761 | } |
762 | else | 762 | else |
763 | PopupMenu->popup(mapToGlobal(QPoint(mx, my))); | 763 | PopupMenu->popup(mapToGlobal(QPoint(mx, my))); |
764 | } | 764 | } |
765 | killTimer(timer_id); | 765 | killTimer(timer_id); |
766 | } | 766 | } |
767 | 767 | ||
768 | //***************************************************************************** | 768 | //***************************************************************************** |
769 | void QMyMainWindow::MemuClicked(int MenuID) | 769 | void QMyMainWindow::MemuClicked(int MenuID) |
770 | { | 770 | { |
771 | QWidget* Desktop; | 771 | QWidget* Desktop; |
772 | int dw; | 772 | int dw; |
773 | int dh; | 773 | int dh; |
774 | 774 | ||
775 | if (MenuID == 1) // right click | 775 | if (MenuID == 1) // right click |
776 | { | 776 | { |
777 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my); | 777 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my); |
778 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my); | 778 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my); |
779 | } | 779 | } |
780 | else if (MenuID == 2) // toggle full screen | 780 | else if (MenuID == 2) // toggle full screen |
781 | { | 781 | { |
782 | fullscreen = ~fullscreen; | 782 | fullscreen = ~fullscreen; |
783 | if (fullscreen) | 783 | if (fullscreen) |
784 | { | 784 | { |
785 | Desktop = App->desktop(); | 785 | Desktop = App->desktop(); |
786 | dw = Desktop->width(); | 786 | dw = Desktop->width(); |
787 | dh = Desktop->height(); | 787 | dh = Desktop->height(); |
788 | if (dw == g_width && dh == g_height) | 788 | if (dw == g_width && dh == g_height) |
789 | MW->resize(g_width - 4, g_height - 4); | 789 | MW->resize(g_width - 4, g_height - 4); |
790 | SV->showFullScreen(); | 790 | SV->showFullScreen(); |
791 | } | 791 | } |
792 | else | 792 | else |
793 | { | 793 | { |
794 | SV->showNormal(); | 794 | SV->showNormal(); |
795 | SV->showMaximized(); | 795 | SV->showMaximized(); |
796 | MW->resize(g_width, g_height); | 796 | MW->resize(g_width, g_height); |
797 | } | 797 | } |
798 | } | 798 | } |
799 | else if (MenuID == 3) // reset keyboard | 799 | else if (MenuID == 3) // reset keyboard |
800 | { | 800 | { |
801 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift | 801 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift |
802 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control | 802 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control |
803 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt | 803 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt |
804 | } | 804 | } |
805 | else if (MenuID == 4) // double click | 805 | else if (MenuID == 4) // double click |
806 | { | 806 | { |
807 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); | 807 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); |
808 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); | 808 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
809 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); | 809 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); |
810 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); | 810 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
811 | } | 811 | } |
812 | } | 812 | } |
813 | 813 | ||
814 | //***************************************************************************** | 814 | //***************************************************************************** |
815 | void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) | 815 | void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) |
816 | { | 816 | { |
817 | int x; | 817 | int x; |
818 | int y; | 818 | int y; |
819 | 819 | ||
820 | x = e->x(); | 820 | x = e->x(); |
821 | y = e->y(); | 821 | y = e->y(); |
822 | 822 | ||
823 | if (timer_id) | 823 | if (timer_id) |
824 | { | 824 | { |
825 | x = x - mx; | 825 | x = x - mx; |
826 | y = y - my; | 826 | y = y - my; |
827 | if (x < -10 || x > 10 || y < -10 || y > 10) | 827 | if (x < -10 || x > 10 || y < -10 || y > 10) |
828 | { | 828 | { |
829 | killTimer(timer_id); | 829 | killTimer(timer_id); |
830 | timer_id = 0; | 830 | timer_id = 0; |
831 | } | 831 | } |
832 | } | 832 | } |
833 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); | 833 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); |
834 | } | 834 | } |
835 | 835 | ||
836 | //***************************************************************************** | 836 | //***************************************************************************** |
837 | void QMyMainWindow::mousePressEvent(QMouseEvent* e) | 837 | void QMyMainWindow::mousePressEvent(QMouseEvent* e) |
838 | { | 838 | { |
839 | timer_id = startTimer(1000); | 839 | timer_id = startTimer(1000); |
840 | mx = e->x(); | 840 | mx = e->x(); |
841 | my = e->y(); | 841 | my = e->y(); |
842 | if (e->button() == LeftButton) | 842 | if (e->button() == LeftButton) |
843 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y()); | 843 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y()); |
844 | else if (e->button() == RightButton) | 844 | else if (e->button() == RightButton) |
845 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y()); | 845 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y()); |
846 | else if (e->button() == MidButton) | 846 | else if (e->button() == MidButton) |
847 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); | 847 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
848 | } | 848 | } |
849 | 849 | ||
850 | //***************************************************************************** | 850 | //***************************************************************************** |
851 | void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) | 851 | void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) |
852 | { | 852 | { |
853 | killTimer(timer_id); | 853 | killTimer(timer_id); |
854 | timer_id = 0; | 854 | timer_id = 0; |
855 | if (e->button() == LeftButton) | 855 | if (e->button() == LeftButton) |
856 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y()); | 856 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y()); |
857 | else if (e->button() == RightButton) | 857 | else if (e->button() == RightButton) |
858 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y()); | 858 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y()); |
859 | else if (e->button() == MidButton) | 859 | else if (e->button() == MidButton) |
860 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); | 860 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
861 | } | 861 | } |
862 | 862 | ||
863 | //***************************************************************************** | 863 | //***************************************************************************** |
864 | void QMyMainWindow::wheelEvent(QWheelEvent* e) | 864 | void QMyMainWindow::wheelEvent(QWheelEvent* e) |
865 | { | 865 | { |
866 | if (e->delta() > 0) | 866 | if (e->delta() > 0) |
867 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y()); | 867 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y()); |
868 | else if (e->delta() < 0) | 868 | else if (e->delta() < 0) |
869 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y()); | 869 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y()); |
870 | } | 870 | } |
871 | 871 | ||
872 | #define NOT(x) (255-(x)) | 872 | #define NOT(x) (255-(x)) |
873 | 873 | ||
874 | //***************************************************************************** | 874 | //***************************************************************************** |
875 | uint8 rop(int rop, uint8 src, uint8 dst) | 875 | uint8 rop(int rop, uint8 src, uint8 dst) |
876 | { | 876 | { |
877 | switch (rop) | 877 | switch (rop) |
878 | { | 878 | { |
879 | case 0x0: return 0; | 879 | case 0x0: return 0; |
880 | case 0x1: return NOT (src | dst); | 880 | case 0x1: return NOT (src | dst); |
881 | case 0x2: return NOT (src) & dst; | 881 | case 0x2: return NOT (src) & dst; |
882 | case 0x3: return NOT (src); | 882 | case 0x3: return NOT (src); |
883 | case 0x4: return src & NOT (dst); | 883 | case 0x4: return src & NOT (dst); |
884 | case 0x5: return NOT (dst); | 884 | case 0x5: return NOT (dst); |
885 | case 0x6: return src ^ dst; | 885 | case 0x6: return src ^ dst; |
886 | case 0x7: return NOT (src & dst); | 886 | case 0x7: return NOT (src & dst); |
887 | case 0x8: return src & dst; | 887 | case 0x8: return src & dst; |
888 | case 0x9: return NOT (src) ^ dst; | 888 | case 0x9: return NOT (src) ^ dst; |
889 | case 0xa: return dst; | 889 | case 0xa: return dst; |
890 | case 0xb: return NOT (src) | dst; | 890 | case 0xb: return NOT (src) | dst; |
891 | case 0xc: return src; | 891 | case 0xc: return src; |
892 | case 0xd: return src | NOT (dst); | 892 | case 0xd: return src | NOT (dst); |
893 | case 0xe: return src | dst; | 893 | case 0xe: return src | dst; |
894 | case 0xf: return NOT (0); | 894 | case 0xf: return NOT (0); |
895 | } | 895 | } |
896 | return dst; | 896 | return dst; |
897 | } | 897 | } |
898 | 898 | ||
899 | //***************************************************************************** | 899 | //***************************************************************************** |
900 | uint8 get_pixel(int x, int y) | 900 | uint8 get_pixel(int x, int y) |
901 | { | 901 | { |
902 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) | 902 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
903 | return BS[y * g_width + x]; | 903 | return BS[y * g_width + x]; |
904 | else | 904 | else |
905 | return 0; | 905 | return 0; |
906 | } | 906 | } |
907 | 907 | ||
908 | //***************************************************************************** | 908 | //***************************************************************************** |
909 | void set_pixel(int x, int y, uint8 pixel, int op = 0xc) | 909 | void set_pixel(int x, int y, uint8 pixel, int op = 0xc) |
910 | { | 910 | { |
911 | if (x >= clipx && x < (clipx + clipcx) && y >= clipy && y < (clipy + clipcy)) | 911 | if (x >= clipx && x < (clipx + clipcx) && y >= clipy && y < (clipy + clipcy)) |
912 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) | 912 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
913 | if (op == 0xc) | 913 | if (op == 0xc) |
914 | BS[y * g_width + x] = pixel; | 914 | BS[y * g_width + x] = pixel; |
915 | else | 915 | else |
916 | BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]); | 916 | BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]); |
917 | } | 917 | } |
918 | 918 | ||
919 | //****************************************************************************** | 919 | //****************************************************************************** |
920 | // adjust coordinates for cliping rect | 920 | // adjust coordinates for cliping rect |
921 | bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy) | 921 | bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy) |
922 | { | 922 | { |
923 | int dx, dy; | 923 | int dx, dy; |
924 | QRect InRect(*x, *y, *cx, *cy); | 924 | QRect InRect(*x, *y, *cx, *cy); |
925 | QRect OutRect; | 925 | QRect OutRect; |
926 | QRect CRect(clipx, clipy, clipcx, clipcy); | 926 | QRect CRect(clipx, clipy, clipcx, clipcy); |
927 | OutRect = InRect.intersect(CRect); | 927 | OutRect = InRect.intersect(CRect); |
928 | if (OutRect.isEmpty()) | 928 | if (OutRect.isEmpty()) |
929 | return false; | 929 | return false; |
930 | dx = OutRect.x() - InRect.x(); | 930 | dx = OutRect.x() - InRect.x(); |
931 | dy = OutRect.y() - InRect.y(); | 931 | dy = OutRect.y() - InRect.y(); |
932 | *x = OutRect.x(); | 932 | *x = OutRect.x(); |
933 | *y = OutRect.y(); | 933 | *y = OutRect.y(); |
934 | *cx = OutRect.width(); | 934 | *cx = OutRect.width(); |
935 | *cy = OutRect.height(); | 935 | *cy = OutRect.height(); |
936 | if (srcx != NULL) | 936 | if (srcx != NULL) |
937 | *srcx = *srcx + dx; | 937 | *srcx = *srcx + dx; |
938 | if (srcy != NULL) | 938 | if (srcy != NULL) |
939 | *srcy = *srcy + dy; | 939 | *srcy = *srcy + dy; |
940 | return true; | 940 | return true; |
941 | } | 941 | } |
942 | 942 | ||
943 | //***************************************************************************** | 943 | //***************************************************************************** |
944 | void QMyMainWindow::paintEvent(QPaintEvent* pe) | 944 | void QMyMainWindow::paintEvent(QPaintEvent* pe) |
945 | { | 945 | { |
946 | QImage* Image; | 946 | QImage* Image; |
947 | QPainter* Painter; | 947 | QPainter* Painter; |
948 | QRect Rect; | 948 | QRect Rect; |