forked from LKislova/usb-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptionswidget.cpp
91 lines (76 loc) · 3.05 KB
/
optionswidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "optionswidget.h"
OptionsWidget::OptionsWidget(QWidget *parent, QSettings * settings)
: QDialog(parent){
setParent(parent);
this->settings = settings;
ok = new QPushButton(tr("OK"));
cancel = new QPushButton(tr("Cancel"));
apply = new QPushButton(tr("Apply"));
buttonsLayout = new QHBoxLayout();
buttonsLayout->addStretch(1);
buttonsLayout->addWidget(ok);
buttonsLayout->addSpacing(0);
buttonsLayout->addWidget(apply);
buttonsLayout->addSpacing(0);
buttonsLayout->addWidget(cancel);
buttonsLayout->addSpacing(0);
connect(apply, SIGNAL(clicked()),this,SLOT(writeSettings()));
connect(ok, SIGNAL(clicked()),this,SLOT(closeAndWriteSettings()));
connect(cancel, SIGNAL(clicked()),this,SLOT(closeAndReadSettings()));
/*
mainLayout = new QVBoxLayout(this);
editorLayout = new QVBoxLayout(this);
unitsLayout = new QVBoxLayout(this);
compileLayout = new QVBoxLayout(this);
warningsLayout = new QVBoxLayout(this);
createMachineLayout();
editorLayout->addLayout(buttonsLayout);
unitsLayout->addLayout(buttonsLayout);
compileLayout->addLayout(buttonsLayout);
warningsLayout->addLayout(buttonsLayout);
machineLayout->addLayout(buttonsLayout);*/
machineWidget = new MachineOptions(this);
mainWidget= new MainOptions(this);
tabWidget = new QTabWidget(this);
//tabWidget->addTab(editorLayout, tr("Редактор"));
tabWidget->addTab(machineWidget, tr("Станок"));
tabWidget->addTab(mainWidget, tr("Основное"));
//tabWidget->addTab(compileLayout, tr("Компиляция"));
//tabWidget->addTab(warningsLayout, tr("Аварийные"));
layout = new QVBoxLayout(this);
layout->addWidget(tabWidget);
layout->addLayout(buttonsLayout);
setLayout(layout);
readSettings();
setWindowTitle(tr("Настройки"));
}
void OptionsWidget::readSettings() {
double dim = settings->value("dimension", 1).toDouble();
double xArae = settings->value("x_arae", 1).toDouble();
double yArae = settings->value("y_arae", 1).toDouble();
double zArae = settings->value("z_arae", 1).toDouble();
double fArae = settings->value("f_arae", 1).toDouble();
double blankArae = settings->value("blank_arae", 1).toDouble();
mainWidget->setDimension(dim);
machineWidget->setXArea(xArae);
machineWidget->setYArea(yArae);
machineWidget->setZArea(zArae);
machineWidget->setFArea(fArae);
machineWidget->setBlankArea(blankArae);
}
void OptionsWidget::closeAndWriteSettings() {
writeSettings();
hide();
}
void OptionsWidget::closeAndReadSettings() {
readSettings();
hide();
}
void OptionsWidget::writeSettings() {
settings->setValue("dimension", mainWidget->getDimension());
settings->setValue("x_arae", machineWidget->getXArea());
settings->setValue("y_arae", machineWidget->getYArea());
settings->setValue("z_arae", machineWidget->getZArea());
settings->setValue("f_arae", machineWidget->getFArea());
settings->setValue("blank_arae", machineWidget->getBlankArea());
}