[settings] projectSettings dialog
This commit is contained in:
parent
d16b00bb9c
commit
9166e37c39
75
projectsettings.cpp
Normal file
75
projectsettings.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "projectsettings.h"
|
||||
#include <QFormLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <iostream>
|
||||
|
||||
ProjectSettings::ProjectSettings(QWidget *parent) : QDialog(parent) {
|
||||
QDialogButtonBox* bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
QPushButton* okBtn = bb->button(QDialogButtonBox::Ok);
|
||||
okBtn->setAutoDefault(true);
|
||||
okBtn->setDefault(true);
|
||||
connect(okBtn, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
|
||||
QPushButton* cancelBtn = bb->button(QDialogButtonBox::Cancel);
|
||||
cancelBtn->setAutoDefault(false);
|
||||
cancelBtn->setDefault(false);
|
||||
connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
|
||||
projectEdit = new QLineEdit();
|
||||
subjectEdit = new QLineEdit();
|
||||
experimentEdit = new QLineEdit();
|
||||
experimenterEdit = new QLineEdit();
|
||||
conditionEdit = new QLineEdit();
|
||||
commentEdit = new QLineEdit();
|
||||
subjectEdit = new QLineEdit();
|
||||
setupEdit = new QLineEdit();
|
||||
|
||||
QFormLayout *l = new QFormLayout();
|
||||
l->addRow(tr("Project name:"), projectEdit);
|
||||
l->addRow(tr("Experimenter:"), experimenterEdit);
|
||||
l->addRow(tr("Experiment name:"), experimentEdit);
|
||||
l->addRow(tr("Experimental condition:"), conditionEdit);
|
||||
l->addRow(tr("Subject id:"),subjectEdit);
|
||||
l->addRow(tr("Setup:"), setupEdit);
|
||||
l->addRow(tr("Comment:"), commentEdit);
|
||||
|
||||
projectEdit->setText(settings.value("project/name", "None").toString());
|
||||
experimentEdit->setText(settings.value("project/experiment", "None").toString());
|
||||
experimenterEdit->setText(settings.value("project/experimenter", "None").toString());
|
||||
conditionEdit->setText(settings.value("project/condition", "None").toString());
|
||||
setupEdit->setText(settings.value("project/setup", "None").toString());
|
||||
commentEdit->setText(settings.value("project/comment", "None").toString());
|
||||
subjectEdit->setText(settings.value("project/subject", "None").toString());
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout();
|
||||
vbox->addLayout(l);
|
||||
vbox->addWidget(bb);
|
||||
this->setLayout(vbox);
|
||||
}
|
||||
|
||||
ProjectSettings::~ProjectSettings(){}
|
||||
|
||||
void ProjectSettings::accept() {
|
||||
this->metadata.projectName = projectEdit->text();
|
||||
this->metadata.experiment = experimentEdit->text();
|
||||
this->metadata.condition = conditionEdit->text();
|
||||
this->metadata.experimenter = experimenterEdit->text();
|
||||
this->metadata.subject = subjectEdit->text();
|
||||
this->metadata.comment = commentEdit->text();
|
||||
this->metadata.setupName = setupEdit->text();
|
||||
|
||||
settings.setValue("project/name", projectEdit->text());
|
||||
settings.setValue("project/experiment", experimentEdit->text());
|
||||
settings.setValue("project/condition", conditionEdit->text());
|
||||
settings.setValue("project/experimenter", experimenterEdit->text());
|
||||
settings.setValue("project/subject", subjectEdit->text());
|
||||
settings.setValue("project/setup", setupEdit->text());
|
||||
settings.setValue("project/comment", commentEdit->text());
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
ProjectMetadata ProjectSettings::getMetadata() {
|
||||
return metadata;
|
||||
}
|
39
projectsettings.h
Normal file
39
projectsettings.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef PROJECTSETTINGS_H
|
||||
#define PROJECTSETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QSettings>
|
||||
|
||||
struct ProjectMetadata
|
||||
{
|
||||
QString projectName;
|
||||
QString experimenter;
|
||||
QString experiment;
|
||||
QString condition;
|
||||
QString subject;
|
||||
QString setupName;
|
||||
QString comment;
|
||||
};
|
||||
|
||||
|
||||
//! [0]
|
||||
class ProjectSettings : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectSettings(QWidget *parent = nullptr);
|
||||
~ProjectSettings();
|
||||
|
||||
ProjectMetadata getMetadata();
|
||||
|
||||
private:
|
||||
ProjectMetadata metadata;
|
||||
QSettings settings;
|
||||
QLineEdit *projectEdit, *experimentEdit, *experimenterEdit, *subjectEdit, *setupEdit, *conditionEdit, *commentEdit;
|
||||
|
||||
void accept();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user