author | zecke <zecke> | 2005-02-14 17:53:31 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 17:53:31 (UTC) |
commit | 41881e3dcd695dc8ecdc5ef22cefd6f842858992 (patch) (side-by-side diff) | |
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 @@ -135,210 +135,195 @@ QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) IPEdit->move(75, 180); IPEdit->resize(100, 20); // width and height WidthHeightBox = new QComboBox(this); WidthHeightBox->move(10, 210); WidthHeightBox->resize(100, 20); WidthHeightBox->insertItem("240x320"); WidthHeightBox->insertItem("640x480"); WidthHeightBox->insertItem("800x600"); connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); WidthHeightBox->setCurrentItem(1); WidthEdit = new QLineEdit(this); WidthEdit->move(110, 210); WidthEdit->resize(30, 20); WidthEdit->setText("800"); HeightEdit = new QLineEdit(this); HeightEdit->move(140, 210); HeightEdit->resize(30, 20); HeightEdit->setText("600"); // add to list button AddButton = new QPushButton(this); AddButton->move(180, 120); AddButton->resize(50, 20); AddButton->setText("Add"); connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); // change list item button EditButton = new QPushButton(this); EditButton->move(180, 140); EditButton->resize(50, 20); EditButton->setText("Edit"); connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); // save to file button SaveButton = new QPushButton(this); SaveButton->move(180, 160); SaveButton->resize(50, 20); SaveButton->setText("Save"); connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); // remove an item button RemoveButton = new QPushButton(this); RemoveButton->move(180, 180); RemoveButton->resize(50, 20); RemoveButton->setText("Remove"); connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); // full screen check box FullScreenCheckBox = new QCheckBox(this, "Full Screen"); FullScreenCheckBox->setText("Full Screen"); FullScreenCheckBox->move(10, 230); // ok button - OKButton = new QPushButton(this); - OKButton->setText("OK"); - OKButton->move(100, 240); - OKButton->resize(50, 20); - connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked())); - // cancel button - CancelButton = new QPushButton(this); - CancelButton->setText("Cancel"); - CancelButton->move(160, 240); - CancelButton->resize(50, 20); - connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked())); for (i = 0; i < 10; i++) { ConnectionList[i] = new QMyConnectionItem; ConnectionList[i]->ServerName = ""; ConnectionList[i]->UserName = ""; ConnectionList[i]->ServerIP = ""; ConnectionList[i]->Width = 0; ConnectionList[i]->Height = 0; ConnectionList[i]->FullScreen = 0; } home = getenv("HOME"); if (home != NULL) { sprintf(Text, "%s/rdesktop.ini", home); QFile* File = new QFile(Text); if (File->open(IO_ReadOnly)) { i = -1; while (!File->atEnd()) { File->readLine(Line, 255); j = Line.find("="); if (j > 0) { ItemName = Line.mid(0, j); CleanString(&ItemName); ItemValue = Line.mid(j + 1); CleanString(&ItemValue); if (ItemName == "Server") { i++; ConnectionList[i]->ServerName = ItemValue; ListBox->insertItem(ItemValue); } else if (ItemName == "UserName") ConnectionList[i]->UserName = ItemValue; else if (ItemName == "Width") ConnectionList[i]->Width = ItemValue.toInt(); else if (ItemName == "Height") ConnectionList[i]->Height = ItemValue.toInt(); else if (ItemName == "IP") ConnectionList[i]->ServerIP = ItemValue; else if (ItemName == "FullScreen") ConnectionList[i]->FullScreen = (ItemValue != "0"); } } } delete File; } } //***************************************************************************** QMyDialog::~QMyDialog() { QMyConnectionItem* Item; int i; for (i = 0; i < 10; i++) { Item = ConnectionList[i]; delete Item; } } //***************************************************************************** void QMyDialog::ComboChanged(int index) { if (index == 0) { WidthEdit->setText("240"); HeightEdit->setText("320"); } if (index == 1) { WidthEdit->setText("640"); HeightEdit->setText("480"); } else if (index == 2) { WidthEdit->setText("800"); HeightEdit->setText("600"); } } //***************************************************************************** -void QMyDialog::OKClicked() +void QMyDialog::accept() { ServerName = ServerNameEdit->text(); UserName = UserNameEdit->text(); Width = WidthEdit->text().toInt(); Height = HeightEdit->text().toInt(); ServerIP = IPEdit->text(); FullScreen = FullScreenCheckBox->isChecked(); - done(1); -} -//***************************************************************************** -void QMyDialog::CancelClicked() -{ - done(0); + QDialog::accept(); } + //***************************************************************************** void QMyDialog::AddClicked() { int i; QMyConnectionItem* Item; i = ListBox->count(); if (i < 10) { ListBox->insertItem(ServerNameEdit->text()); Item = ConnectionList[i]; Item->ServerName = ServerNameEdit->text(); Item->UserName = UserNameEdit->text(); Item->Width = WidthEdit->text().toInt(); Item->Height = HeightEdit->text().toInt(); Item->ServerIP = IPEdit->text(); Item->FullScreen = FullScreenCheckBox->isChecked(); } } //***************************************************************************** void QMyDialog::EditClicked() { int i; QMyConnectionItem* Item; i = ListBox->currentItem(); if (i >= 0) { Item = ConnectionList[i]; Item->ServerName = ServerNameEdit->text(); Item->UserName = UserNameEdit->text(); Item->Width = WidthEdit->text().toInt(); Item->Height = HeightEdit->text().toInt(); Item->ServerIP = IPEdit->text(); Item->FullScreen = FullScreenCheckBox->isChecked(); ListBox->changeItem(ServerNameEdit->text(), i); } } //***************************************************************************** void WriteString(QFile* File, QString* Line) { File->writeBlock((const char*)(*Line), Line->length()); } //***************************************************************************** void QMyDialog::SaveClicked() 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 @@ #include <qwidget.h> #include <qscrollview.h> #include <qdialog.h> #include <qlistbox.h> #include <qlineedit.h> #include <qcombobox.h> #include <qlabel.h> #include <qcheckbox.h> #include <qpopupmenu.h> class QMyConnectionItem { public: QString ServerName; QString UserName; QString ServerIP; int Width; int Height; int FullScreen; }; class QMyDialog: public QDialog { Q_OBJECT public: QMyDialog(QWidget*); ~QMyDialog(); public: QListBox* ListBox; - QPushButton* OKButton; - QPushButton* CancelButton; QLabel* Label1; QLineEdit* ServerNameEdit; QLabel* Label2; QLineEdit* UserNameEdit; QLabel* Label3; QLineEdit* IPEdit; QLineEdit* WidthEdit; QLineEdit* HeightEdit; QComboBox* WidthHeightBox; QPushButton* AddButton; QPushButton* EditButton; QPushButton* SaveButton; QPushButton* RemoveButton; QCheckBox* FullScreenCheckBox; public slots: void ComboChanged(int); - void OKClicked(); - void CancelClicked(); void AddClicked(); void EditClicked(); void SaveClicked(); void RemoveClicked(); void ListBoxChanged(); void ListBoxSelected(int); public: QString ServerName; QString UserName; QString ServerIP; int Width; int Height; int FullScreen; QMyConnectionItem* ConnectionList[10]; + protected slots: + void accept(); }; class QMyScrollView: public QScrollView { Q_OBJECT public: QMyScrollView(); ~QMyScrollView(); void keyPressEvent(QKeyEvent*); void keyReleaseEvent(QKeyEvent*); void showEvent(QShowEvent*); void show(); void polish(); void timerEvent(QTimerEvent*); public: int timer_id; }; class QMyMainWindow: public QWidget { Q_OBJECT public: QMyMainWindow(); ~QMyMainWindow(); void paintEvent(QPaintEvent*); void mouseMoveEvent(QMouseEvent*); void mousePressEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); void wheelEvent(QWheelEvent*); void closeEvent(QCloseEvent*); void timerEvent(QTimerEvent*); public slots: void dataReceived(); void MemuClicked(int); public: QPopupMenu* PopupMenu; int timer_id; int mx; int my; }; |