| 36 | namespace Gecode { namespace Gist { |
| 37 | |
| 38 | PreferencesDialog::PreferencesDialog(const Options& opt, QWidget *parent) |
| 39 | : QDialog(parent) { |
| 40 | QSettings settings("gecode.org", "Gist"); |
| 41 | hideFailed = settings.value("search/hideFailed", true).toBool(); |
| 42 | zoom = settings.value("search/zoom", false).toBool(); |
| 43 | copies = settings.value("search/copies", false).toBool(); |
| 44 | refresh = settings.value("search/refresh", 500).toInt(); |
| 45 | refreshPause = settings.value("search/refreshPause", 0).toInt(); |
| 46 | smoothScrollAndZoom = |
| 47 | settings.value("smoothScrollAndZoom", true).toBool(); |
| 48 | moveDuringSearch = false; |
| 49 | |
| 50 | c_d = opt.c_d; |
| 51 | a_d = opt.a_d; |
| 52 | |
| 53 | hideCheck = |
| 54 | new QCheckBox(tr("Hide failed subtrees automatically")); |
| 55 | hideCheck->setChecked(hideFailed); |
| 56 | zoomCheck = |
| 57 | new QCheckBox(tr("Automatic zoom enabled on start-up")); |
| 58 | zoomCheck->setChecked(zoom); |
| 59 | smoothCheck = |
| 60 | new QCheckBox(tr("Smooth scrolling and zooming")); |
| 61 | smoothCheck->setChecked(smoothScrollAndZoom); |
| 62 | |
| 63 | QPushButton* defButton = new QPushButton(tr("Defaults")); |
| 64 | QPushButton* cancelButton = new QPushButton(tr("Cancel")); |
| 65 | QPushButton* okButton = new QPushButton(tr("Ok")); |
| 66 | okButton->setDefault(true); |
| 67 | QHBoxLayout* buttonLayout = new QHBoxLayout(); |
| 68 | buttonLayout->addWidget(defButton); |
| 69 | buttonLayout->addWidget(cancelButton); |
| 70 | buttonLayout->addWidget(okButton); |
| 71 | |
| 72 | connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); |
| 73 | connect(defButton, SIGNAL(clicked()), this, SLOT(defaults())); |
| 74 | connect(okButton, SIGNAL(clicked()), this, SLOT(writeBack())); |
| 75 | |
| 76 | QLabel* refreshLabel = new QLabel(tr("Display refresh rate:")); |
| 77 | refreshBox = new QSpinBox(); |
| 78 | refreshBox->setRange(0, 1000000); |
| 79 | refreshBox->setValue(refresh); |
| 80 | refreshBox->setSingleStep(100); |
| 81 | QHBoxLayout* refreshLayout = new QHBoxLayout(); |
| 82 | refreshLayout->addWidget(refreshLabel); |
| 83 | refreshLayout->addWidget(refreshBox); |
| 84 | |
| 85 | slowBox = |
| 86 | new QCheckBox(tr("Slow down search")); |
| 87 | slowBox->setChecked(refreshPause > 0); |
| 88 | |
| 89 | refreshBox->setEnabled(refreshPause == 0); |
| 90 | |
| 91 | connect(slowBox, SIGNAL(stateChanged(int)), this, |
| 92 | SLOT(toggleSlow(int))); |
| 93 | |
| 94 | moveDuringSearchBox = |
| 95 | new QCheckBox(tr("Move cursor during search")); |