comparison widgets/ItemEditDialog.cpp @ 282:4edaff85875d

* Add mouse actions to key and mouse reference dialog * Use QDialogButtonBox in all dialogs, for proper button ordering across platforms (requires Qt 4.2) * Fix #1733610 program does not exit if preferences dialog visible on close
author Chris Cannam
date Thu, 05 Jul 2007 11:07:01 +0000
parents 0f36cdf407a6
children b6397738444c
comparison
equal deleted inserted replaced
281:ac58acbd7482 282:4edaff85875d
21 #include <QGridLayout> 21 #include <QGridLayout>
22 #include <QHBoxLayout> 22 #include <QHBoxLayout>
23 #include <QLabel> 23 #include <QLabel>
24 #include <QPushButton> 24 #include <QPushButton>
25 #include <QGroupBox> 25 #include <QGroupBox>
26 #include <QDialogButtonBox>
26 27
27 #include <float.h> // for FLT_MIN/MAX 28 #include <float.h> // for FLT_MIN/MAX
28 29
29 30
30 ItemEditDialog::ItemEditDialog(size_t sampleRate, int options, 31 ItemEditDialog::ItemEditDialog(size_t sampleRate, int options,
170 if (options & ShowText) { 171 if (options & ShowText) {
171 m_textField->setFocus(Qt::OtherFocusReason); 172 m_textField->setFocus(Qt::OtherFocusReason);
172 } else if (options & ShowValue) { 173 } else if (options & ShowValue) {
173 m_valueSpinBox->setFocus(Qt::OtherFocusReason); 174 m_valueSpinBox->setFocus(Qt::OtherFocusReason);
174 } 175 }
175 176
176 QHBoxLayout *hbox = new QHBoxLayout; 177 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
177 grid->addLayout(hbox, row, 0, 1, 2); 178 grid->addWidget(bb, row, 0, 1, 2);
178 179
179 QPushButton *ok = new QPushButton(tr("OK")); 180 QPushButton *ok = new QPushButton(tr("OK"));
180 m_resetButton = new QPushButton(tr("Reset")); 181 m_resetButton = new QPushButton(tr("Reset"));
181 QPushButton *cancel = new QPushButton(tr("Cancel")); 182 QPushButton *cancel = new QPushButton(tr("Cancel"));
182 hbox->addStretch(10); 183 bb->addButton(ok, QDialogButtonBox::AcceptRole);
183 hbox->addWidget(ok); 184 bb->addButton(m_resetButton, QDialogButtonBox::ResetRole);
184 hbox->addWidget(m_resetButton); 185 bb->addButton(cancel, QDialogButtonBox::RejectRole);
185 hbox->addWidget(cancel);
186 ok->setDefault(true);
187 connect(ok, SIGNAL(clicked()), this, SLOT(accept())); 186 connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
188 connect(m_resetButton, SIGNAL(clicked()), this, SLOT(reset())); 187 connect(m_resetButton, SIGNAL(clicked()), this, SLOT(reset()));
189 connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); 188 connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
190 m_resetButton->setEnabled(false); 189 m_resetButton->setEnabled(false);
191 } 190 }