summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opierdesktop/qtwin.cpp21
-rw-r--r--noncore/net/opierdesktop/qtwin.h6
2 files changed, 5 insertions, 22 deletions
diff --git a/noncore/net/opierdesktop/qtwin.cpp b/noncore/net/opierdesktop/qtwin.cpp
index 181d275..54a5a03 100644
--- a/noncore/net/opierdesktop/qtwin.cpp
+++ b/noncore/net/opierdesktop/qtwin.cpp
@@ -1,552 +1,537 @@
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
41uint32 flags; 41uint32 flags;
42char server[64] = ""; 42char server[64] = "";
43char domain[16] = ""; 43char domain[16] = "";
44char password[16] = ""; 44char password[16] = "";
45char shell[128] = ""; 45char shell[128] = "";
46char directory[32] = ""; 46char directory[32] = "";
47 47
48extern int g_width; 48extern int g_width;
49extern int g_height; 49extern int g_height;
50extern int server_bpp; 50extern int server_bpp;
51extern BOOL fullscreen; 51extern BOOL fullscreen;
52extern char username[]; 52extern char username[];
53int global_sock; 53int global_sock;
54 54
55QSocketNotifier* SocketNotifier; 55QSocketNotifier* SocketNotifier;
56QPEApplication* App; 56QPEApplication* App;
57QMyMainWindow* MW; 57QMyMainWindow* MW;
58QMyScrollView* SV; 58QMyScrollView* SV;
59struct QColorMap 59struct QColorMap
60{ 60{
61 uint32 RGBColors[256]; 61 uint32 RGBColors[256];
62 int NumColors; 62 int NumColors;
63}; 63};
64QColorMap* CM; 64QColorMap* CM;
65uint8* BS; 65uint8* BS;
66int clipx; 66int clipx;
67int clipy; 67int clipy;
68int clipcx; 68int clipcx;
69int clipcy; 69int clipcy;
70 70
71struct bitmap 71struct 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
78BOOL owncolmap = False; 78BOOL owncolmap = False;
79 79
80//***************************************************************************** 80//*****************************************************************************
81void CleanString(QString* Item) 81void 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//*****************************************************************************
95QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) 95QMyDialog::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("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("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("Server IP");
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("Add");
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("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("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("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("Full Screen");
181 FullScreenCheckBox->move(10, 230); 181 FullScreenCheckBox->move(10, 230);
182 // ok button 182 // ok button
183 OKButton = new QPushButton(this);
184 OKButton->setText("OK");
185 OKButton->move(100, 240);
186 OKButton->resize(50, 20);
187 connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked()));
188 // cancel button
189 CancelButton = new QPushButton(this);
190 CancelButton->setText("Cancel");
191 CancelButton->move(160, 240);
192 CancelButton->resize(50, 20);
193 connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked()));
194 183
195 for (i = 0; i < 10; i++) 184 for (i = 0; i < 10; i++)
196 { 185 {
197 ConnectionList[i] = new QMyConnectionItem; 186 ConnectionList[i] = new QMyConnectionItem;
198 ConnectionList[i]->ServerName = ""; 187 ConnectionList[i]->ServerName = "";
199 ConnectionList[i]->UserName = ""; 188 ConnectionList[i]->UserName = "";
200 ConnectionList[i]->ServerIP = ""; 189 ConnectionList[i]->ServerIP = "";
201 ConnectionList[i]->Width = 0; 190 ConnectionList[i]->Width = 0;
202 ConnectionList[i]->Height = 0; 191 ConnectionList[i]->Height = 0;
203 ConnectionList[i]->FullScreen = 0; 192 ConnectionList[i]->FullScreen = 0;
204 } 193 }
205 home = getenv("HOME"); 194 home = getenv("HOME");
206 if (home != NULL) 195 if (home != NULL)
207 { 196 {
208 sprintf(Text, "%s/rdesktop.ini", home); 197 sprintf(Text, "%s/rdesktop.ini", home);
209 QFile* File = new QFile(Text); 198 QFile* File = new QFile(Text);
210 if (File->open(IO_ReadOnly)) 199 if (File->open(IO_ReadOnly))
211 { 200 {
212 i = -1; 201 i = -1;
213 while (!File->atEnd()) 202 while (!File->atEnd())
214 { 203 {
215 File->readLine(Line, 255); 204 File->readLine(Line, 255);
216 j = Line.find("="); 205 j = Line.find("=");
217 if (j > 0) 206 if (j > 0)
218 { 207 {
219 ItemName = Line.mid(0, j); 208 ItemName = Line.mid(0, j);
220 CleanString(&ItemName); 209 CleanString(&ItemName);
221 ItemValue = Line.mid(j + 1); 210 ItemValue = Line.mid(j + 1);
222 CleanString(&ItemValue); 211 CleanString(&ItemValue);
223 if (ItemName == "Server") 212 if (ItemName == "Server")
224 { 213 {
225 i++; 214 i++;
226 ConnectionList[i]->ServerName = ItemValue; 215 ConnectionList[i]->ServerName = ItemValue;
227 ListBox->insertItem(ItemValue); 216 ListBox->insertItem(ItemValue);
228 } 217 }
229 else if (ItemName == "UserName") 218 else if (ItemName == "UserName")
230 ConnectionList[i]->UserName = ItemValue; 219 ConnectionList[i]->UserName = ItemValue;
231 else if (ItemName == "Width") 220 else if (ItemName == "Width")
232 ConnectionList[i]->Width = ItemValue.toInt(); 221 ConnectionList[i]->Width = ItemValue.toInt();
233 else if (ItemName == "Height") 222 else if (ItemName == "Height")
234 ConnectionList[i]->Height = ItemValue.toInt(); 223 ConnectionList[i]->Height = ItemValue.toInt();
235 else if (ItemName == "IP") 224 else if (ItemName == "IP")
236 ConnectionList[i]->ServerIP = ItemValue; 225 ConnectionList[i]->ServerIP = ItemValue;
237 else if (ItemName == "FullScreen") 226 else if (ItemName == "FullScreen")
238 ConnectionList[i]->FullScreen = (ItemValue != "0"); 227 ConnectionList[i]->FullScreen = (ItemValue != "0");
239 } 228 }
240 } 229 }
241 } 230 }
242 delete File; 231 delete File;
243 } 232 }
244} 233}
245 234
246//***************************************************************************** 235//*****************************************************************************
247QMyDialog::~QMyDialog() 236QMyDialog::~QMyDialog()
248{ 237{
249 QMyConnectionItem* Item; 238 QMyConnectionItem* Item;
250 int i; 239 int i;
251 240
252 for (i = 0; i < 10; i++) 241 for (i = 0; i < 10; i++)
253 { 242 {
254 Item = ConnectionList[i]; 243 Item = ConnectionList[i];
255 delete Item; 244 delete Item;
256 } 245 }
257} 246}
258 247
259//***************************************************************************** 248//*****************************************************************************
260void QMyDialog::ComboChanged(int index) 249void QMyDialog::ComboChanged(int index)
261{ 250{
262 if (index == 0) 251 if (index == 0)
263 { 252 {
264 WidthEdit->setText("240"); 253 WidthEdit->setText("240");
265 HeightEdit->setText("320"); 254 HeightEdit->setText("320");
266 } 255 }
267 if (index == 1) 256 if (index == 1)
268 { 257 {
269 WidthEdit->setText("640"); 258 WidthEdit->setText("640");
270 HeightEdit->setText("480"); 259 HeightEdit->setText("480");
271 } 260 }
272 else if (index == 2) 261 else if (index == 2)
273 { 262 {
274 WidthEdit->setText("800"); 263 WidthEdit->setText("800");
275 HeightEdit->setText("600"); 264 HeightEdit->setText("600");
276 } 265 }
277} 266}
278 267
279//***************************************************************************** 268//*****************************************************************************
280void QMyDialog::OKClicked() 269void QMyDialog::accept()
281{ 270{
282 ServerName = ServerNameEdit->text(); 271 ServerName = ServerNameEdit->text();
283 UserName = UserNameEdit->text(); 272 UserName = UserNameEdit->text();
284 Width = WidthEdit->text().toInt(); 273 Width = WidthEdit->text().toInt();
285 Height = HeightEdit->text().toInt(); 274 Height = HeightEdit->text().toInt();
286 ServerIP = IPEdit->text(); 275 ServerIP = IPEdit->text();
287 FullScreen = FullScreenCheckBox->isChecked(); 276 FullScreen = FullScreenCheckBox->isChecked();
288 done(1);
289}
290 277
291//***************************************************************************** 278 QDialog::accept();
292void QMyDialog::CancelClicked()
293{
294 done(0);
295} 279}
296 280
281
297//***************************************************************************** 282//*****************************************************************************
298void QMyDialog::AddClicked() 283void QMyDialog::AddClicked()
299{ 284{
300 int i; 285 int i;
301 QMyConnectionItem* Item; 286 QMyConnectionItem* Item;
302 287
303 i = ListBox->count(); 288 i = ListBox->count();
304 if (i < 10) 289 if (i < 10)
305 { 290 {
306 ListBox->insertItem(ServerNameEdit->text()); 291 ListBox->insertItem(ServerNameEdit->text());
307 Item = ConnectionList[i]; 292 Item = ConnectionList[i];
308 Item->ServerName = ServerNameEdit->text(); 293 Item->ServerName = ServerNameEdit->text();
309 Item->UserName = UserNameEdit->text(); 294 Item->UserName = UserNameEdit->text();
310 Item->Width = WidthEdit->text().toInt(); 295 Item->Width = WidthEdit->text().toInt();
311 Item->Height = HeightEdit->text().toInt(); 296 Item->Height = HeightEdit->text().toInt();
312 Item->ServerIP = IPEdit->text(); 297 Item->ServerIP = IPEdit->text();
313 Item->FullScreen = FullScreenCheckBox->isChecked(); 298 Item->FullScreen = FullScreenCheckBox->isChecked();
314 } 299 }
315} 300}
316 301
317//***************************************************************************** 302//*****************************************************************************
318void QMyDialog::EditClicked() 303void QMyDialog::EditClicked()
319{ 304{
320 int i; 305 int i;
321 QMyConnectionItem* Item; 306 QMyConnectionItem* Item;
322 307
323 i = ListBox->currentItem(); 308 i = ListBox->currentItem();
324 if (i >= 0) 309 if (i >= 0)
325 { 310 {
326 Item = ConnectionList[i]; 311 Item = ConnectionList[i];
327 Item->ServerName = ServerNameEdit->text(); 312 Item->ServerName = ServerNameEdit->text();
328 Item->UserName = UserNameEdit->text(); 313 Item->UserName = UserNameEdit->text();
329 Item->Width = WidthEdit->text().toInt(); 314 Item->Width = WidthEdit->text().toInt();
330 Item->Height = HeightEdit->text().toInt(); 315 Item->Height = HeightEdit->text().toInt();
331 Item->ServerIP = IPEdit->text(); 316 Item->ServerIP = IPEdit->text();
332 Item->FullScreen = FullScreenCheckBox->isChecked(); 317 Item->FullScreen = FullScreenCheckBox->isChecked();
333 ListBox->changeItem(ServerNameEdit->text(), i); 318 ListBox->changeItem(ServerNameEdit->text(), i);
334 } 319 }
335} 320}
336 321
337//***************************************************************************** 322//*****************************************************************************
338void WriteString(QFile* File, QString* Line) 323void WriteString(QFile* File, QString* Line)
339{ 324{
340 File->writeBlock((const char*)(*Line), Line->length()); 325 File->writeBlock((const char*)(*Line), Line->length());
341} 326}
342 327
343//***************************************************************************** 328//*****************************************************************************
344void QMyDialog::SaveClicked() 329void QMyDialog::SaveClicked()
345{ 330{
346 int i, j; 331 int i, j;
347 QMyConnectionItem* Item; 332 QMyConnectionItem* Item;
348 QString Line; 333 QString Line;
349 char* home; 334 char* home;
350 char Text[256]; 335 char Text[256];
351 QFile* File; 336 QFile* File;
352 337
353 home = getenv("HOME"); 338 home = getenv("HOME");
354 if (home != NULL) 339 if (home != NULL)
355 { 340 {
356 sprintf(Text, "%s/rdesktop.ini", home); 341 sprintf(Text, "%s/rdesktop.ini", home);
357 File = new QFile(Text); 342 File = new QFile(Text);
358 if (File->open(IO_Truncate | IO_ReadWrite)) 343 if (File->open(IO_Truncate | IO_ReadWrite))
359 { 344 {
360 i = ListBox->count(); 345 i = ListBox->count();
361 for (j = 0; j < i; j++) 346 for (j = 0; j < i; j++)
362 { 347 {
363 Item = ConnectionList[j]; 348 Item = ConnectionList[j];
364 Line = "Server="; 349 Line = "Server=";
365 Line += Item->ServerName; 350 Line += Item->ServerName;
366 Line += (char)10; 351 Line += (char)10;
367 WriteString(File, &Line); 352 WriteString(File, &Line);
368 Line = "UserName="; 353 Line = "UserName=";
369 Line += Item->UserName; 354 Line += Item->UserName;
370 Line += (char)10; 355 Line += (char)10;
371 WriteString(File, &Line); 356 WriteString(File, &Line);
372 Line = "Width="; 357 Line = "Width=";
373 sprintf(Text, "%d", Item->Width); 358 sprintf(Text, "%d", Item->Width);
374 Line += Text; 359 Line += Text;
375 Line += (char)10; 360 Line += (char)10;
376 WriteString(File, &Line); 361 WriteString(File, &Line);
377 Line = "Height="; 362 Line = "Height=";
378 sprintf(Text, "%d", Item->Height); 363 sprintf(Text, "%d", Item->Height);
379 Line += Text; 364 Line += Text;
380 Line += (char)10; 365 Line += (char)10;
381 WriteString(File, &Line); 366 WriteString(File, &Line);
382 Line = "IP="; 367 Line = "IP=";
383 Line += Item->ServerIP; 368 Line += Item->ServerIP;
384 Line += (char)10; 369 Line += (char)10;
385 WriteString(File, &Line); 370 WriteString(File, &Line);
386 Line = "FullScreen="; 371 Line = "FullScreen=";
387 if (Item->FullScreen) 372 if (Item->FullScreen)
388 Line += "1"; 373 Line += "1";
389 else 374 else
390 Line += "0"; 375 Line += "0";
391 Line += (char)10; 376 Line += (char)10;
392 WriteString(File, &Line); 377 WriteString(File, &Line);
393 } 378 }
394 } 379 }
395 File->flush(); 380 File->flush();
396 File->close(); 381 File->close();
397 delete File; 382 delete File;
398 } 383 }
399} 384}
400 385
401//***************************************************************************** 386//*****************************************************************************
402void QMyDialog::RemoveClicked() 387void QMyDialog::RemoveClicked()
403{ 388{
404 int i, j, c; 389 int i, j, c;
405 QMyConnectionItem* Item1; 390 QMyConnectionItem* Item1;
406 QMyConnectionItem* Item2; 391 QMyConnectionItem* Item2;
407 392
408 i = ListBox->currentItem(); 393 i = ListBox->currentItem();
409 if (i >= 0) 394 if (i >= 0)
410 { 395 {
411 c = ListBox->count(); 396 c = ListBox->count();
412 for (j = i; j < c - 1; j++) 397 for (j = i; j < c - 1; j++)
413 { 398 {
414 Item1 = ConnectionList[i]; 399 Item1 = ConnectionList[i];
415 Item2 = ConnectionList[i + 1]; 400 Item2 = ConnectionList[i + 1];
416 Item1->ServerName = Item2->ServerName; 401 Item1->ServerName = Item2->ServerName;
417 Item1->UserName = Item2->UserName; 402 Item1->UserName = Item2->UserName;
418 Item1->Width = Item2->Width; 403 Item1->Width = Item2->Width;
419 Item1->Height = Item2->Height; 404 Item1->Height = Item2->Height;
420 Item1->ServerIP = Item2->ServerIP; 405 Item1->ServerIP = Item2->ServerIP;
421 Item1->FullScreen = Item2->FullScreen; 406 Item1->FullScreen = Item2->FullScreen;
422 } 407 }
423 ListBox->removeItem(i); 408 ListBox->removeItem(i);
424 } 409 }
425} 410}
426 411
427//***************************************************************************** 412//*****************************************************************************
428void QMyDialog::ListBoxChanged() 413void QMyDialog::ListBoxChanged()
429{ 414{
430 int i; 415 int i;
431 QMyConnectionItem* Item; 416 QMyConnectionItem* Item;
432 char Text[100]; 417 char Text[100];
433 418
434 i = ListBox->currentItem(); 419 i = ListBox->currentItem();
435 if (i >= 0 && i < 10) 420 if (i >= 0 && i < 10)
436 { 421 {
437 Item = ConnectionList[i]; 422 Item = ConnectionList[i];
438 ServerNameEdit->setText(Item->ServerName); 423 ServerNameEdit->setText(Item->ServerName);
439 UserNameEdit->setText(Item->UserName); 424 UserNameEdit->setText(Item->UserName);
440 sprintf(Text, "%d", Item->Width); 425 sprintf(Text, "%d", Item->Width);
441 WidthEdit->setText(Text); 426 WidthEdit->setText(Text);
442 sprintf(Text, "%d", Item->Height); 427 sprintf(Text, "%d", Item->Height);
443 HeightEdit->setText(Text); 428 HeightEdit->setText(Text);
444 IPEdit->setText(Item->ServerIP); 429 IPEdit->setText(Item->ServerIP);
445 FullScreenCheckBox->setChecked(Item->FullScreen != 0); 430 FullScreenCheckBox->setChecked(Item->FullScreen != 0);
446 } 431 }
447} 432}
448 433
449//***************************************************************************** 434//*****************************************************************************
450void QMyDialog::ListBoxSelected(int /*index*/) 435void QMyDialog::ListBoxSelected(int /*index*/)
451{ 436{
452} 437}
453 438
454//***************************************************************************** 439//*****************************************************************************
455void GetScanCode(QKeyEvent* e, int* ScanCode, int* code) 440void GetScanCode(QKeyEvent* e, int* ScanCode, int* code)
456{ 441{
457 int key; 442 int key;
458 int mod; 443 int mod;
459 int ascii; 444 int ascii;
460 445
461 key = e->key(); 446 key = e->key();
462 mod = e->state(); 447 mod = e->state();
463 ascii = e->ascii(); 448 ascii = e->ascii();
464 449
465 *ScanCode = 0; 450 *ScanCode = 0;
466 *code = mod; // 8 shift, 16 control, 32 alt 451 *code = mod; // 8 shift, 16 control, 32 alt
467 452
468 switch (key) 453 switch (key)
469 { 454 {
470 case 4096: // esc 455 case 4096: // esc
471 case 4097: // tab 456 case 4097: // tab
472 case 4099: // backspace 457 case 4099: // backspace
473 case 4100: // enter 458 case 4100: // enter
474 case 4101: // enter 459 case 4101: // enter
475 case 4103: // delete 460 case 4103: // delete
476 ascii = 0; 461 ascii = 0;
477 } 462 }
478 463
479 if (ascii == 0) 464 if (ascii == 0)
480 { 465 {
481 switch (key) 466 switch (key)
482 { 467 {
483 case 4096: *ScanCode = 0x01; break; // esc 468 case 4096: *ScanCode = 0x01; break; // esc
484 case 4097: *ScanCode = 0x0f; break; // tab 469 case 4097: *ScanCode = 0x0f; break; // tab
485 case 4099: *ScanCode = 0x0e; break; // backspace 470 case 4099: *ScanCode = 0x0e; break; // backspace
486 case 4100: *ScanCode = 0x1c; break; // enter 471 case 4100: *ScanCode = 0x1c; break; // enter
487 case 4101: *ScanCode = 0x1c; break; // enter 472 case 4101: *ScanCode = 0x1c; break; // enter
488 case 4112: *ScanCode = 0xc7; break; // home 473 case 4112: *ScanCode = 0xc7; break; // home
489 case 4113: *ScanCode = 0xcf; break; // end 474 case 4113: *ScanCode = 0xcf; break; // end
490 case 4102: *ScanCode = 0xd2; break; // insert 475 case 4102: *ScanCode = 0xd2; break; // insert
491 case 4103: *ScanCode = 0xd3; break; // delete 476 case 4103: *ScanCode = 0xd3; break; // delete
492 case 4118: *ScanCode = 0xc9; break; // page up 477 case 4118: *ScanCode = 0xc9; break; // page up
493 case 4119: *ScanCode = 0xd1; break; // page down 478 case 4119: *ScanCode = 0xd1; break; // page down
494 case 4117: *ScanCode = 0xd0; break; // down arrow 479 case 4117: *ScanCode = 0xd0; break; // down arrow
495 case 4115: *ScanCode = 0xc8; break; // up arrow 480 case 4115: *ScanCode = 0xc8; break; // up arrow
496 case 4114: *ScanCode = 0xcb; break; // left arrow 481 case 4114: *ScanCode = 0xcb; break; // left arrow
497 case 4116: *ScanCode = 0xcd; break; // right arrow 482 case 4116: *ScanCode = 0xcd; break; // right arrow
498 case 4128: *ScanCode = 0x2a; break; // shift 483 case 4128: *ScanCode = 0x2a; break; // shift
499 case 4131: *ScanCode = 0x38; break; // alt 484 case 4131: *ScanCode = 0x38; break; // alt
500 case 4129: *ScanCode = 0x1d; break; // ctrl 485 case 4129: *ScanCode = 0x1d; break; // ctrl
501 } 486 }
502 if (*ScanCode != 0) 487 if (*ScanCode != 0)
503 return; 488 return;
504 } 489 }
505 490
506 switch (ascii) 491 switch (ascii)
507 { 492 {
508 // first row 493 // first row
509 case 'q': *ScanCode = 0x10; break; 494 case 'q': *ScanCode = 0x10; break;
510 case 'Q': *ScanCode = 0x10; *code |= 8; break; 495 case 'Q': *ScanCode = 0x10; *code |= 8; break;
511 case '1': *ScanCode = 0x02; break; 496 case '1': *ScanCode = 0x02; break;
512 case 'w': *ScanCode = 0x11; break; 497 case 'w': *ScanCode = 0x11; break;
513 case 'W': *ScanCode = 0x11; *code |= 8; break; 498 case 'W': *ScanCode = 0x11; *code |= 8; break;
514 case '2': *ScanCode = 0x03; break; 499 case '2': *ScanCode = 0x03; break;
515 case 'e': *ScanCode = 0x12; break; 500 case 'e': *ScanCode = 0x12; break;
516 case 'E': *ScanCode = 0x12; *code |= 8; break; 501 case 'E': *ScanCode = 0x12; *code |= 8; break;
517 case '3': *ScanCode = 0x04; break; 502 case '3': *ScanCode = 0x04; break;
518 case 'r': *ScanCode = 0x13; break; 503 case 'r': *ScanCode = 0x13; break;
519 case 'R': *ScanCode = 0x13; *code |= 8; break; 504 case 'R': *ScanCode = 0x13; *code |= 8; break;
520 case '4': *ScanCode = 0x05; break; 505 case '4': *ScanCode = 0x05; break;
521 case 't': *ScanCode = 0x14; break; 506 case 't': *ScanCode = 0x14; break;
522 case 'T': *ScanCode = 0x14; *code |= 8; break; 507 case 'T': *ScanCode = 0x14; *code |= 8; break;
523 case '5': *ScanCode = 0x06; break; 508 case '5': *ScanCode = 0x06; break;
524 case 'y': *ScanCode = 0x15; break; 509 case 'y': *ScanCode = 0x15; break;
525 case 'Y': *ScanCode = 0x15; *code |= 8; break; 510 case 'Y': *ScanCode = 0x15; *code |= 8; break;
526 case '6': *ScanCode = 0x07; break; 511 case '6': *ScanCode = 0x07; break;
527 case 'u': *ScanCode = 0x16; break; 512 case 'u': *ScanCode = 0x16; break;
528 case 'U': *ScanCode = 0x16; *code |= 8; break; 513 case 'U': *ScanCode = 0x16; *code |= 8; break;
529 case '7': *ScanCode = 0x08; break; 514 case '7': *ScanCode = 0x08; break;
530 case 'i': *ScanCode = 0x17; break; 515 case 'i': *ScanCode = 0x17; break;
531 case 'I': *ScanCode = 0x17; *code |= 8; break; 516 case 'I': *ScanCode = 0x17; *code |= 8; break;
532 case '8': *ScanCode = 0x09; break; 517 case '8': *ScanCode = 0x09; break;
533 case 'o': *ScanCode = 0x18; break; 518 case 'o': *ScanCode = 0x18; break;
534 case 'O': *ScanCode = 0x18; *code |= 8; break; 519 case 'O': *ScanCode = 0x18; *code |= 8; break;
535 case '9': *ScanCode = 0x0a; break; 520 case '9': *ScanCode = 0x0a; break;
536 case 'p': *ScanCode = 0x19; break; 521 case 'p': *ScanCode = 0x19; break;
537 case 'P': *ScanCode = 0x19; *code |= 8; break; 522 case 'P': *ScanCode = 0x19; *code |= 8; break;
538 case '0': *ScanCode = 0x0b; break; 523 case '0': *ScanCode = 0x0b; break;
539 // second row 524 // second row
540 case 'a': *ScanCode = 0x1e; break; 525 case 'a': *ScanCode = 0x1e; break;
541 case 'A': *ScanCode = 0x1e; *code |= 8; break; 526 case 'A': *ScanCode = 0x1e; *code |= 8; break;
542 case '!': *ScanCode = 0x02; *code |= 8; break; 527 case '!': *ScanCode = 0x02; *code |= 8; break;
543 case 's': *ScanCode = 0x1f; break; 528 case 's': *ScanCode = 0x1f; break;
544 case 'S': *ScanCode = 0x1f; *code |= 8; break; 529 case 'S': *ScanCode = 0x1f; *code |= 8; break;
545 case '@': *ScanCode = 0x03; *code |= 8; break; 530 case '@': *ScanCode = 0x03; *code |= 8; break;
546 case 'd': *ScanCode = 0x20; break; 531 case 'd': *ScanCode = 0x20; break;
547 case 'D': *ScanCode = 0x20; *code |= 8; break; 532 case 'D': *ScanCode = 0x20; *code |= 8; break;
548 case '#': *ScanCode = 0x04; *code |= 8; break; 533 case '#': *ScanCode = 0x04; *code |= 8; break;
549 case 'f': *ScanCode = 0x21; break; 534 case 'f': *ScanCode = 0x21; break;
550 case 'F': *ScanCode = 0x21; *code |= 8; break; 535 case 'F': *ScanCode = 0x21; *code |= 8; break;
551 case '$': *ScanCode = 0x05; *code |= 8; break; 536 case '$': *ScanCode = 0x05; *code |= 8; break;
552 case 'g': *ScanCode = 0x22; break; 537 case 'g': *ScanCode = 0x22; break;
diff --git a/noncore/net/opierdesktop/qtwin.h b/noncore/net/opierdesktop/qtwin.h
index 38ad190..7a2110b 100644
--- a/noncore/net/opierdesktop/qtwin.h
+++ b/noncore/net/opierdesktop/qtwin.h
@@ -1,105 +1,103 @@
1 1
2#include <qwidget.h> 2#include <qwidget.h>
3#include <qscrollview.h> 3#include <qscrollview.h>
4#include <qdialog.h> 4#include <qdialog.h>
5#include <qlistbox.h> 5#include <qlistbox.h>
6#include <qlineedit.h> 6#include <qlineedit.h>
7#include <qcombobox.h> 7#include <qcombobox.h>
8#include <qlabel.h> 8#include <qlabel.h>
9#include <qcheckbox.h> 9#include <qcheckbox.h>
10#include <qpopupmenu.h> 10#include <qpopupmenu.h>
11 11
12class QMyConnectionItem 12class QMyConnectionItem
13{ 13{
14 public: 14 public:
15 QString ServerName; 15 QString ServerName;
16 QString UserName; 16 QString UserName;
17 QString ServerIP; 17 QString ServerIP;
18 int Width; 18 int Width;
19 int Height; 19 int Height;
20 int FullScreen; 20 int FullScreen;
21}; 21};
22 22
23class QMyDialog: public QDialog 23class QMyDialog: public QDialog
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26 public: 26 public:
27 QMyDialog(QWidget*); 27 QMyDialog(QWidget*);
28 ~QMyDialog(); 28 ~QMyDialog();
29 public: 29 public:
30 QListBox* ListBox; 30 QListBox* ListBox;
31 QPushButton* OKButton;
32 QPushButton* CancelButton;
33 QLabel* Label1; 31 QLabel* Label1;
34 QLineEdit* ServerNameEdit; 32 QLineEdit* ServerNameEdit;
35 QLabel* Label2; 33 QLabel* Label2;
36 QLineEdit* UserNameEdit; 34 QLineEdit* UserNameEdit;
37 QLabel* Label3; 35 QLabel* Label3;
38 QLineEdit* IPEdit; 36 QLineEdit* IPEdit;
39 QLineEdit* WidthEdit; 37 QLineEdit* WidthEdit;
40 QLineEdit* HeightEdit; 38 QLineEdit* HeightEdit;
41 QComboBox* WidthHeightBox; 39 QComboBox* WidthHeightBox;
42 QPushButton* AddButton; 40 QPushButton* AddButton;
43 QPushButton* EditButton; 41 QPushButton* EditButton;
44 QPushButton* SaveButton; 42 QPushButton* SaveButton;
45 QPushButton* RemoveButton; 43 QPushButton* RemoveButton;
46 QCheckBox* FullScreenCheckBox; 44 QCheckBox* FullScreenCheckBox;
47 public slots: 45 public slots:
48 void ComboChanged(int); 46 void ComboChanged(int);
49 void OKClicked();
50 void CancelClicked();
51 void AddClicked(); 47 void AddClicked();
52 void EditClicked(); 48 void EditClicked();
53 void SaveClicked(); 49 void SaveClicked();
54 void RemoveClicked(); 50 void RemoveClicked();
55 void ListBoxChanged(); 51 void ListBoxChanged();
56 void ListBoxSelected(int); 52 void ListBoxSelected(int);
57 public: 53 public:
58 QString ServerName; 54 QString ServerName;
59 QString UserName; 55 QString UserName;
60 QString ServerIP; 56 QString ServerIP;
61 int Width; 57 int Width;
62 int Height; 58 int Height;
63 int FullScreen; 59 int FullScreen;
64 QMyConnectionItem* ConnectionList[10]; 60 QMyConnectionItem* ConnectionList[10];
61 protected slots:
62 void accept();
65}; 63};
66 64
67class QMyScrollView: public QScrollView 65class QMyScrollView: public QScrollView
68{ 66{
69 Q_OBJECT 67 Q_OBJECT
70 public: 68 public:
71 QMyScrollView(); 69 QMyScrollView();
72 ~QMyScrollView(); 70 ~QMyScrollView();
73 void keyPressEvent(QKeyEvent*); 71 void keyPressEvent(QKeyEvent*);
74 void keyReleaseEvent(QKeyEvent*); 72 void keyReleaseEvent(QKeyEvent*);
75 void showEvent(QShowEvent*); 73 void showEvent(QShowEvent*);
76 void show(); 74 void show();
77 void polish(); 75 void polish();
78 void timerEvent(QTimerEvent*); 76 void timerEvent(QTimerEvent*);
79 public: 77 public:
80 int timer_id; 78 int timer_id;
81}; 79};
82 80
83class QMyMainWindow: public QWidget 81class QMyMainWindow: public QWidget
84{ 82{
85 Q_OBJECT 83 Q_OBJECT
86 public: 84 public:
87 QMyMainWindow(); 85 QMyMainWindow();
88 ~QMyMainWindow(); 86 ~QMyMainWindow();
89 void paintEvent(QPaintEvent*); 87 void paintEvent(QPaintEvent*);
90 void mouseMoveEvent(QMouseEvent*); 88 void mouseMoveEvent(QMouseEvent*);
91 void mousePressEvent(QMouseEvent*); 89 void mousePressEvent(QMouseEvent*);
92 void mouseReleaseEvent(QMouseEvent*); 90 void mouseReleaseEvent(QMouseEvent*);
93 void wheelEvent(QWheelEvent*); 91 void wheelEvent(QWheelEvent*);
94 void closeEvent(QCloseEvent*); 92 void closeEvent(QCloseEvent*);
95 void timerEvent(QTimerEvent*); 93 void timerEvent(QTimerEvent*);
96 public slots: 94 public slots:
97 void dataReceived(); 95 void dataReceived();
98 void MemuClicked(int); 96 void MemuClicked(int);
99 public: 97 public:
100 QPopupMenu* PopupMenu; 98 QPopupMenu* PopupMenu;
101 int timer_id; 99 int timer_id;
102 int mx; 100 int mx;
103 int my; 101 int my;
104}; 102};
105 103