[settings] make project metadata a class
This commit is contained in:
parent
9166e37c39
commit
3e2dfe2b3b
@ -34,42 +34,62 @@ ProjectSettings::ProjectSettings(QWidget *parent) : QDialog(parent) {
|
|||||||
l->addRow(tr("Subject id:"),subjectEdit);
|
l->addRow(tr("Subject id:"),subjectEdit);
|
||||||
l->addRow(tr("Setup:"), setupEdit);
|
l->addRow(tr("Setup:"), setupEdit);
|
||||||
l->addRow(tr("Comment:"), commentEdit);
|
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();
|
QVBoxLayout *vbox = new QVBoxLayout();
|
||||||
vbox->addLayout(l);
|
vbox->addLayout(l);
|
||||||
vbox->addWidget(bb);
|
vbox->addWidget(bb);
|
||||||
this->setLayout(vbox);
|
this->setLayout(vbox);
|
||||||
|
|
||||||
|
readMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectSettings::~ProjectSettings(){}
|
ProjectSettings::~ProjectSettings(){}
|
||||||
|
|
||||||
void ProjectSettings::accept() {
|
void ProjectSettings::readMetadata() {
|
||||||
this->metadata.projectName = projectEdit->text();
|
metadata.read(settings);
|
||||||
this->metadata.experiment = experimentEdit->text();
|
projectEdit->setText(metadata.project());
|
||||||
this->metadata.condition = conditionEdit->text();
|
experimentEdit->setText(metadata.experiment());
|
||||||
this->metadata.experimenter = experimenterEdit->text();
|
experimenterEdit->setText(metadata.experimenter());
|
||||||
this->metadata.subject = subjectEdit->text();
|
conditionEdit->setText(metadata.condition());
|
||||||
this->metadata.comment = commentEdit->text();
|
setupEdit->setText(metadata.setup());
|
||||||
this->metadata.setupName = setupEdit->text();
|
commentEdit->setText(metadata.comment());
|
||||||
|
subjectEdit->setText(metadata.subject());
|
||||||
|
}
|
||||||
|
|
||||||
settings.setValue("project/name", projectEdit->text());
|
void ProjectSettings::accept() {
|
||||||
settings.setValue("project/experiment", experimentEdit->text());
|
this->metadata.project(projectEdit->text());
|
||||||
settings.setValue("project/condition", conditionEdit->text());
|
this->metadata.experiment(experimentEdit->text());
|
||||||
settings.setValue("project/experimenter", experimenterEdit->text());
|
this->metadata.condition(conditionEdit->text());
|
||||||
settings.setValue("project/subject", subjectEdit->text());
|
this->metadata.experimenter(experimenterEdit->text());
|
||||||
settings.setValue("project/setup", setupEdit->text());
|
this->metadata.subject(subjectEdit->text());
|
||||||
settings.setValue("project/comment", commentEdit->text());
|
this->metadata.comment(commentEdit->text());
|
||||||
|
this->metadata.setup(setupEdit->text());
|
||||||
|
metadata.store(settings);
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectMetadata ProjectSettings::getMetadata() {
|
ProjectMetadata ProjectSettings::getMetadata() {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProjectMetadata::read(QSettings &settings) {
|
||||||
|
this->projectName = settings.value("project/name", "None").toString();
|
||||||
|
this->experimentName = settings.value("project/experiment", "None").toString();
|
||||||
|
this->cond = settings.value("project/condition", "None").toString();
|
||||||
|
this->experimenterName = settings.value("project/experimenter", "None").toString();
|
||||||
|
this->setupName = settings.value("project/setup", "None").toString();
|
||||||
|
this->cmmnt = settings.value("project/comment", "None").toString();
|
||||||
|
this->subj = settings.value("project/subject", "None").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProjectMetadata::store(QSettings &settings) {
|
||||||
|
settings.setValue("project/name", this->projectName);
|
||||||
|
settings.setValue("project/experiment", this->experimentName);
|
||||||
|
settings.setValue("project/condition", this->cond);
|
||||||
|
settings.setValue("project/experimenter", this->experimenterName);
|
||||||
|
settings.setValue("project/subject", this->subj);
|
||||||
|
settings.setValue("project/setup", this->setupName);
|
||||||
|
settings.setValue("project/comment", this->cmmnt);
|
||||||
|
}
|
||||||
|
@ -5,15 +5,79 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
struct ProjectMetadata
|
class ProjectMetadata {
|
||||||
{
|
public:
|
||||||
|
ProjectMetadata(){};
|
||||||
|
~ProjectMetadata(){};
|
||||||
|
|
||||||
|
void read(QSettings &settings);
|
||||||
|
|
||||||
|
void store(QSettings &settings);
|
||||||
|
|
||||||
|
void project(const QString &name) {
|
||||||
|
this->projectName = name;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString project() const {
|
||||||
|
return this->projectName;
|
||||||
|
};
|
||||||
|
|
||||||
|
void experiment(const QString &experiment) {
|
||||||
|
this->experimentName = experiment;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString experiment() const {
|
||||||
|
return this->experimentName;
|
||||||
|
};
|
||||||
|
|
||||||
|
void condition(const QString &condition) {
|
||||||
|
this->cond = condition;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString condition() const {
|
||||||
|
return this->cond;
|
||||||
|
};
|
||||||
|
|
||||||
|
void experimenter(const QString &experimenter) {
|
||||||
|
this->experimenterName = experimenter;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString experimenter() const {
|
||||||
|
return this->experimenterName;
|
||||||
|
};
|
||||||
|
|
||||||
|
void subject(const QString &subject) {
|
||||||
|
this->subj = subject;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString subject() const {
|
||||||
|
return this->subj;
|
||||||
|
};
|
||||||
|
|
||||||
|
void setup(const QString &setup){
|
||||||
|
this->setupName = setup;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString setup() const {
|
||||||
|
return this->setupName;
|
||||||
|
};
|
||||||
|
|
||||||
|
void comment(const QString &comment) {
|
||||||
|
this->cmmnt = comment;
|
||||||
|
};
|
||||||
|
|
||||||
|
QString comment() const {
|
||||||
|
return this->cmmnt;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
QString projectName;
|
QString projectName;
|
||||||
QString experimenter;
|
QString experimenterName;
|
||||||
QString experiment;
|
QString experimentName;
|
||||||
QString condition;
|
QString cond;
|
||||||
QString subject;
|
QString subj;
|
||||||
QString setupName;
|
QString setupName;
|
||||||
QString comment;
|
QString cmmnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -28,11 +92,12 @@ class ProjectSettings : public QDialog
|
|||||||
ProjectMetadata getMetadata();
|
ProjectMetadata getMetadata();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectMetadata metadata;
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
ProjectMetadata metadata;
|
||||||
QLineEdit *projectEdit, *experimentEdit, *experimenterEdit, *subjectEdit, *setupEdit, *conditionEdit, *commentEdit;
|
QLineEdit *projectEdit, *experimentEdit, *experimenterEdit, *subjectEdit, *setupEdit, *conditionEdit, *commentEdit;
|
||||||
|
|
||||||
void accept();
|
void accept();
|
||||||
|
void readMetadata();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -422,8 +422,8 @@ void PylonRecorder::createActions() {
|
|||||||
storeSettingsAction->setStatusTip(tr("store current settings as defaults"));
|
storeSettingsAction->setStatusTip(tr("store current settings as defaults"));
|
||||||
connect(storeSettingsAction, &QAction::triggered, this, &PylonRecorder::storeSettings);
|
connect(storeSettingsAction, &QAction::triggered, this, &PylonRecorder::storeSettings);
|
||||||
|
|
||||||
projectSettingsAction = new QAction(tr("set project name"), this);
|
projectSettingsAction = new QAction(tr("project metadata"), this);
|
||||||
projectSettingsAction->setStatusTip(tr("Set the project name"));
|
projectSettingsAction->setStatusTip(tr("Edit project metadata"));
|
||||||
connect(projectSettingsAction, &QAction::triggered, this, &PylonRecorder::editProjectMetadata);
|
connect(projectSettingsAction, &QAction::triggered, this, &PylonRecorder::editProjectMetadata);
|
||||||
|
|
||||||
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
||||||
@ -734,5 +734,12 @@ void PylonRecorder::selectStorageLocation() {
|
|||||||
|
|
||||||
|
|
||||||
void PylonRecorder::editProjectMetadata(){
|
void PylonRecorder::editProjectMetadata(){
|
||||||
std::cerr << "EditProjectSettings" << std::endl;
|
ProjectSettings *dlg = new ProjectSettings(this);
|
||||||
|
|
||||||
|
dlg->setModal(true);
|
||||||
|
int res = dlg->exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
this->mdata = dlg->getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "imagebuffer.h"
|
#include "imagebuffer.h"
|
||||||
#include "grabber.h"
|
#include "grabber.h"
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
#include "projectsettings.h"
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#if defined(QT_PRINTSUPPORT_LIB)
|
#if defined(QT_PRINTSUPPORT_LIB)
|
||||||
@ -105,7 +106,8 @@ private:
|
|||||||
QAction *selectStorageAction, *storeSettingsAction;
|
QAction *selectStorageAction, *storeSettingsAction;
|
||||||
QAction *projectSettingsAction;
|
QAction *projectSettingsAction;
|
||||||
QString storageLocation = "";
|
QString storageLocation = "";
|
||||||
|
ProjectMetadata mdata;
|
||||||
|
|
||||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user