author | zecke <zecke> | 2005-02-14 17:53:31 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 17:53:31 (UTC) |
commit | 41881e3dcd695dc8ecdc5ef22cefd6f842858992 (patch) (unidiff) | |
tree | bd533c7e75700bbafb69ab8a7cd53eb031969080 | |
parent | 0e6780c400fbae2ccd8895e40480adb4273906ae (diff) | |
download | opie-41881e3dcd695dc8ecdc5ef22cefd6f842858992.zip opie-41881e3dcd695dc8ecdc5ef22cefd6f842858992.tar.gz opie-41881e3dcd695dc8ecdc5ef22cefd6f842858992.tar.bz2 |
Remove the special Ok/Cancel handling and go with what QDialog provides
This also fixes crashes when the user clicked ok in the Dialog
-rw-r--r-- | noncore/net/opierdesktop/qtwin.cpp | 21 | ||||
-rw-r--r-- | noncore/net/opierdesktop/qtwin.h | 6 |
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 | |||
@@ -151,75 +151,64 @@ QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) | |||
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++; |
@@ -248,81 +237,77 @@ QMyDialog::~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 | //***************************************************************************** |
260 | void QMyDialog::ComboChanged(int index) | 249 | void 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 | //***************************************************************************** |
280 | void QMyDialog::OKClicked() | 269 | void 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(); |
292 | void QMyDialog::CancelClicked() | ||
293 | { | ||
294 | done(0); | ||
295 | } | 279 | } |
296 | 280 | ||
281 | |||
297 | //***************************************************************************** | 282 | //***************************************************************************** |
298 | void QMyDialog::AddClicked() | 283 | void 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 | //***************************************************************************** |
318 | void QMyDialog::EditClicked() | 303 | void 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(); |
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,96 +1,94 @@ | |||
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 | ||
12 | class QMyConnectionItem | 12 | class 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 | ||
23 | class QMyDialog: public QDialog | 23 | class 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 | ||
67 | class QMyScrollView: public QScrollView | 65 | class 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 | ||
83 | class QMyMainWindow: public QWidget | 81 | class 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: |