Implemented full snapshot saving in the GUI.
[aesalon.git] / gui / src / Configuration.cpp
blob40b22a1e7389a60c65fae32fdd72c5ab9e981db9
1 #include <QSettings>
2 #include "Configuration.h"
3 #include "Configuration.moc"
5 Configuration::Configuration(QWidget *parent) : QDialog(parent) {
6 QSizePolicy expanding;
7 expanding.setHorizontalPolicy(QSizePolicy::Expanding);
8 expanding.setVerticalPolicy(QSizePolicy::Expanding);
9 this->setSizePolicy(expanding);
10 this->setMinimumSize(600, 100);
11 this->setWindowTitle(tr("Configuration"));
13 QSettings settings;
14 main_layout = new QVBoxLayout();
15 form_layout = new QFormLayout();
16 form_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
18 aesalon_path_layout = new QHBoxLayout();
19 aesalon_path = new QLineEdit();
20 aesalon_path->setText(settings.value("aesalon-path").toString());
21 aesalon_path_layout->addWidget(aesalon_path);
23 aesalon_path_file_selector = new QFileDialog();
24 aesalon_path_file_selector->setDirectory(getenv("HOME"));
26 aesalon_path_select_dialog = new QPushButton(tr(". . ."));
27 connect(aesalon_path_select_dialog, SIGNAL(clicked(bool)), aesalon_path_file_selector, SLOT(exec()));
28 connect(aesalon_path_file_selector, SIGNAL(fileSelected(QString)), this, SLOT(change_aesalon_path(QString)));
30 aesalon_path_layout->addWidget(aesalon_path_select_dialog);
32 form_layout->addRow("Path to aesalon:", aesalon_path_layout);
34 xterm_path_layout = new QHBoxLayout();
35 xterm_path = new QLineEdit();
36 xterm_path->setText(settings.value("xterm-path").toString());
37 xterm_path_layout->addWidget(xterm_path);
39 xterm_path_file_selector = new QFileDialog();
40 xterm_path_file_selector->setDirectory(getenv("HOME"));
42 xterm_path_select_dialog = new QPushButton(tr(". . ."));
43 connect(xterm_path_select_dialog, SIGNAL(clicked(bool)), xterm_path_file_selector, SLOT(exec()));
44 connect(xterm_path_file_selector, SIGNAL(fileSelected(QString)), this, SLOT(change_xterm_path(QString)));
46 xterm_path_layout->addWidget(xterm_path_select_dialog);
48 form_layout->addRow("X terminal to use:", xterm_path_layout);
50 default_snapshot_interval = new QSpinBox();
51 default_snapshot_interval->setAlignment(Qt::AlignRight);
52 default_snapshot_interval->setMinimum(50);
53 default_snapshot_interval->setMaximum(60000);
54 default_snapshot_interval->setSuffix(tr("ms"));
55 default_snapshot_interval->setValue(settings.value("default-snapshot-interval", 1000).toInt());
56 form_layout->addRow("Default snapshot interval:", default_snapshot_interval);
58 default_full_snapshot_interval = new QSpinBox();
59 default_full_snapshot_interval->setAlignment(Qt::AlignRight);
60 default_full_snapshot_interval->setMinimum(1);
61 default_full_snapshot_interval->setMaximum(1000);
62 default_full_snapshot_interval->setPrefix(tr("Every "));
63 default_full_snapshot_interval->setSuffix(tr(" snapshot(s)"));
64 default_full_snapshot_interval->setValue(settings.value("default-full-snapshot-interval", 100).toInt());
65 form_layout->addRow(tr("Default full snapshot interval:"), default_full_snapshot_interval);
67 main_layout->addLayout(form_layout);
69 button_box = new QDialogButtonBox();
70 button_box->addButton(QDialogButtonBox::Save);
71 button_box->addButton(QDialogButtonBox::Cancel);
72 button_box->setCenterButtons(false);
73 connect(button_box, SIGNAL(accepted()), this, SLOT(accept()));
74 connect(button_box, SIGNAL(rejected()), this, SLOT(reject()));
76 main_layout->addWidget(button_box);
78 setLayout(main_layout);
81 void Configuration::accept() {
82 QSettings settings;
83 settings.setValue("aesalon-path", aesalon_path->text());
84 settings.setValue("xterm-path", xterm_path->text());
85 settings.setValue("default-snapshot-interval", default_snapshot_interval->value());
86 settings.setValue("default-full-snapshot-interval", default_full_snapshot_interval->value());
87 QDialog::accept();