recordpage.cpp
157 lines
| 5.6 KiB
| text/x-c
|
CppLexer
/ gse_lesia / recordpage.cpp
r58 | #include "recordpage.h" | |||
RecordPage::RecordPage(QWidget *parent) : | ||||
QWidget(parent) | ||||
{ | ||||
logFileEn = false; | ||||
radiobutton_swf_f0 = new QRadioButton("swf_f0"); | ||||
radiobutton_swf_f1 = new QRadioButton("swf_f1"); | ||||
radiobutton_swf_f2 = new QRadioButton("swf_f2"); | ||||
radiobutton_cwf_f1 = new QRadioButton("cwf_f1"); | ||||
radiobutton_cwf_f2 = new QRadioButton("cwf_f2"); | ||||
radiobutton_cwf_f3 = new QRadioButton("cwf_f3"); | ||||
r60 | radiobutton_asm_f0 = new QRadioButton("asm_f0"); | |||
r58 | ||||
radiobutton_swf_f0->setAutoExclusive(false); | ||||
radiobutton_swf_f1->setAutoExclusive(false); | ||||
radiobutton_swf_f2->setAutoExclusive(false); | ||||
radiobutton_cwf_f1->setAutoExclusive(false); | ||||
radiobutton_cwf_f2->setAutoExclusive(false); | ||||
radiobutton_cwf_f3->setAutoExclusive(false); | ||||
r60 | radiobutton_asm_f0->setAutoExclusive(false); | |||
r58 | ||||
label_currentDir = new QLabel("Current Dir: -"); | ||||
button_chooseDir = new QPushButton("choose dir"); | ||||
button_storeWfrm = new QPushButton(tr("REC")); | ||||
groupbox_waveforms = new QGroupBox("waveforms"); | ||||
r60 | groupbox_matrices = new QGroupBox("spectral matrices"); | |||
r58 | groupbox_directory = new QGroupBox("directory"); | |||
vboxlayout_waveforms = new QVBoxLayout(); | ||||
r60 | vboxlayout_matrices = new QVBoxLayout(); | |||
r58 | vboxlayout_directory = new QVBoxLayout(); | |||
mainLayout = new QGridLayout(); | ||||
this->readSettings(); | ||||
vboxlayout_waveforms->addWidget(radiobutton_swf_f0); | ||||
vboxlayout_waveforms->addWidget(radiobutton_swf_f1); | ||||
vboxlayout_waveforms->addWidget(radiobutton_swf_f2); | ||||
vboxlayout_waveforms->addWidget(radiobutton_cwf_f1); | ||||
vboxlayout_waveforms->addWidget(radiobutton_cwf_f2); | ||||
vboxlayout_waveforms->addWidget(radiobutton_cwf_f3); | ||||
vboxlayout_waveforms->addStretch(); | ||||
r60 | ||||
vboxlayout_matrices->addWidget(radiobutton_asm_f0); | ||||
vboxlayout_matrices->addStretch(); | ||||
r58 | vboxlayout_directory->addWidget(button_storeWfrm); | |||
vboxlayout_directory->addWidget(button_chooseDir); | ||||
vboxlayout_directory->addWidget(label_currentDir); | ||||
vboxlayout_directory->addStretch(); | ||||
groupbox_waveforms->setLayout(vboxlayout_waveforms); | ||||
r60 | groupbox_matrices->setLayout(vboxlayout_matrices); | |||
r58 | groupbox_directory->setLayout(vboxlayout_directory); | |||
mainLayout->addWidget(groupbox_directory, 0, 0, 1, 1); | ||||
mainLayout->addWidget(groupbox_waveforms, 0, 1, 1, 1); | ||||
r60 | mainLayout->addWidget(groupbox_matrices, 0, 2, 1, 1); | |||
r58 | mainLayout->setRowStretch(1, 1); | |||
r60 | mainLayout->setColumnStretch(3, 1); | |||
r58 | ||||
this->setLayout(mainLayout); | ||||
connect(this->button_chooseDir, SIGNAL(clicked()), this, SLOT(chooseDir())); | ||||
connect(this->button_storeWfrm, SIGNAL(clicked()), this, SLOT(storeWfrm())); | ||||
} | ||||
RecordPage::~RecordPage() | ||||
{ | ||||
this->writeSettings(); | ||||
} | ||||
void RecordPage::chooseDir() | ||||
{ | ||||
QString tmpDefaultStorageDirectory; | ||||
tmpDefaultStorageDirectory = QFileDialog::getExistingDirectory(this, | ||||
"choose the directory", | ||||
QDir::homePath(), | ||||
QFileDialog::ShowDirsOnly); | ||||
if( !tmpDefaultStorageDirectory.isEmpty() ) | ||||
{ | ||||
defaultStorageDirectory = tmpDefaultStorageDirectory; | ||||
} | ||||
label_currentDir->setText(defaultStorageDirectory); | ||||
emit signal_defaultStorageDirectoryUpdated( defaultStorageDirectory ); | ||||
} | ||||
void RecordPage::storeWfrm() | ||||
{ | ||||
if (logFileEn == false) | ||||
{ | ||||
// enable storage | ||||
button_storeWfrm->setText(tr("STOP")); | ||||
logFileEn = true; | ||||
if (radiobutton_swf_f0->isChecked()) emit signal_store_swf_f0(); | ||||
if (radiobutton_swf_f1->isChecked()) emit signal_store_swf_f1(); | ||||
if (radiobutton_swf_f2->isChecked()) emit signal_store_swf_f2(); | ||||
if (radiobutton_cwf_f1->isChecked()) emit signal_store_cwf_f1(); | ||||
if (radiobutton_cwf_f2->isChecked()) emit signal_store_cwf_f2(); | ||||
if (radiobutton_cwf_f3->isChecked()) emit signal_store_cwf_f3(); | ||||
r60 | if (radiobutton_asm_f0->isChecked()) emit signal_store_asm_f0(); | |||
r58 | radiobutton_swf_f0->setEnabled(false); | |||
radiobutton_swf_f1->setEnabled(false); | ||||
radiobutton_swf_f2->setEnabled(false); | ||||
radiobutton_cwf_f1->setEnabled(false); | ||||
radiobutton_cwf_f2->setEnabled(false); | ||||
radiobutton_cwf_f3->setEnabled(false); | ||||
r60 | radiobutton_asm_f0->setEnabled(false); | |||
r58 | } | |||
else | ||||
{ | ||||
// disable storage | ||||
button_storeWfrm->setText(tr("REC")); | ||||
logFileEn = false; | ||||
if (radiobutton_swf_f0->isChecked()) emit signal_store_swf_f0(); | ||||
if (radiobutton_swf_f1->isChecked()) emit signal_store_swf_f1(); | ||||
if (radiobutton_swf_f2->isChecked()) emit signal_store_swf_f2(); | ||||
if (radiobutton_cwf_f1->isChecked()) emit signal_store_cwf_f1(); | ||||
if (radiobutton_cwf_f2->isChecked()) emit signal_store_cwf_f2(); | ||||
if (radiobutton_cwf_f3->isChecked()) emit signal_store_cwf_f3(); | ||||
r60 | if (radiobutton_asm_f0->isChecked()) emit signal_store_asm_f0(); | |||
r58 | radiobutton_swf_f0->setEnabled(true); | |||
radiobutton_swf_f1->setEnabled(true); | ||||
radiobutton_swf_f2->setEnabled(true); | ||||
radiobutton_cwf_f1->setEnabled(true); | ||||
radiobutton_cwf_f2->setEnabled(true); | ||||
radiobutton_cwf_f3->setEnabled(true); | ||||
r60 | radiobutton_asm_f0->setEnabled(true); | |||
r58 | } | |||
} | ||||
void RecordPage::readSettings() | ||||
{ | ||||
QSettings settings("lpp", "lfrsgse"); | ||||
defaultStorageDirectory = settings.value( "storageDirectory", QDir::homePath() ).toString(); | ||||
label_currentDir->setText( defaultStorageDirectory ); | ||||
emit signal_defaultStorageDirectoryUpdated( defaultStorageDirectory ); | ||||
} | ||||
void RecordPage::writeSettings() | ||||
{ | ||||
QSettings settings("lpp", "lfrsgse"); | ||||
settings.setValue("storageDirectory", defaultStorageDirectory); | ||||
} | ||||
void RecordPage::closeEvent(QCloseEvent *event) | ||||
{ | ||||
event->accept(); | ||||
} | ||||