comparison widgets/RangeInputDialog.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 dd573e090eed
children
comparison
equal deleted inserted replaced
281:ac58acbd7482 282:4edaff85875d
17 17
18 #include <QDoubleSpinBox> 18 #include <QDoubleSpinBox>
19 #include <QGridLayout> 19 #include <QGridLayout>
20 #include <QLabel> 20 #include <QLabel>
21 #include <QHBoxLayout> 21 #include <QHBoxLayout>
22 #include <QDialogButtonBox>
22 #include <QPushButton> 23 #include <QPushButton>
23 24
24 RangeInputDialog::RangeInputDialog(QString title, QString message, 25 RangeInputDialog::RangeInputDialog(QString title, QString message,
25 QString unit, float min, float max, 26 QString unit, float min, float max,
26 QWidget *parent) : 27 QWidget *parent) :
53 m_rangeEnd->setSuffix(unit); 54 m_rangeEnd->setSuffix(unit);
54 grid->addWidget(m_rangeEnd, 1, 3); 55 grid->addWidget(m_rangeEnd, 1, 3);
55 connect(m_rangeEnd, SIGNAL(valueChanged(double)), 56 connect(m_rangeEnd, SIGNAL(valueChanged(double)),
56 this, SLOT(rangeEndChanged(double))); 57 this, SLOT(rangeEndChanged(double)));
57 58
58 QHBoxLayout *hbox = new QHBoxLayout; 59 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
59 grid->addLayout(hbox, 2, 0, 1, 5); 60 QDialogButtonBox::Cancel);
60 61 grid->addWidget(bb, 2, 0, 1, 5);
61 QPushButton *ok = new QPushButton(tr("OK"), this); 62 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
62 ok->setDefault(true); 63 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
63
64 QPushButton *cancel = new QPushButton(tr("Cancel"), this);
65
66 QSize bs = ok->sizeHint().expandedTo(cancel->sizeHint());
67 ok->setFixedSize(bs);
68 cancel->setFixedSize(bs);
69
70 hbox->addStretch();
71 hbox->addWidget(ok);
72 hbox->addWidget(cancel);
73
74 QObject::connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
75 QObject::connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
76 } 64 }
77 65
78 RangeInputDialog::~RangeInputDialog() 66 RangeInputDialog::~RangeInputDialog()
79 { 67 {
80 } 68 }