diff --git a/projectsettings.cpp b/projectsettings.cpp index debc79d..af0871c 100644 --- a/projectsettings.cpp +++ b/projectsettings.cpp @@ -34,42 +34,62 @@ ProjectSettings::ProjectSettings(QWidget *parent) : QDialog(parent) { 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); + + readMetadata(); } 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(); +void ProjectSettings::readMetadata() { + metadata.read(settings); + projectEdit->setText(metadata.project()); + experimentEdit->setText(metadata.experiment()); + experimenterEdit->setText(metadata.experimenter()); + conditionEdit->setText(metadata.condition()); + setupEdit->setText(metadata.setup()); + commentEdit->setText(metadata.comment()); + subjectEdit->setText(metadata.subject()); +} - 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()); +void ProjectSettings::accept() { + this->metadata.project(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.setup(setupEdit->text()); + metadata.store(settings); QDialog::accept(); } ProjectMetadata ProjectSettings::getMetadata() { return metadata; -} \ No newline at end of file +} + + +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); +} diff --git a/projectsettings.h b/projectsettings.h index 7ed5120..0a57aba 100644 --- a/projectsettings.h +++ b/projectsettings.h @@ -5,15 +5,79 @@ #include #include -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 experimenter; - QString experiment; - QString condition; - QString subject; + QString experimenterName; + QString experimentName; + QString cond; + QString subj; QString setupName; - QString comment; + QString cmmnt; }; @@ -28,11 +92,12 @@ class ProjectSettings : public QDialog ProjectMetadata getMetadata(); private: - ProjectMetadata metadata; QSettings settings; + ProjectMetadata metadata; QLineEdit *projectEdit, *experimentEdit, *experimenterEdit, *subjectEdit, *setupEdit, *conditionEdit, *commentEdit; void accept(); + void readMetadata(); }; diff --git a/pylonrecorder.cpp b/pylonrecorder.cpp index dba217f..dc8d15d 100644 --- a/pylonrecorder.cpp +++ b/pylonrecorder.cpp @@ -422,8 +422,8 @@ void PylonRecorder::createActions() { storeSettingsAction->setStatusTip(tr("store current settings as defaults")); connect(storeSettingsAction, &QAction::triggered, this, &PylonRecorder::storeSettings); - projectSettingsAction = new QAction(tr("set project name"), this); - projectSettingsAction->setStatusTip(tr("Set the project name")); + projectSettingsAction = new QAction(tr("project metadata"), this); + projectSettingsAction->setStatusTip(tr("Edit project metadata")); connect(projectSettingsAction, &QAction::triggered, this, &PylonRecorder::editProjectMetadata); QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings")); @@ -734,5 +734,12 @@ void PylonRecorder::selectStorageLocation() { 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(); + } + } diff --git a/pylonrecorder.h b/pylonrecorder.h index 4895f0a..404e160 100644 --- a/pylonrecorder.h +++ b/pylonrecorder.h @@ -11,6 +11,7 @@ #include "imagebuffer.h" #include "grabber.h" #include "writer.h" +#include "projectsettings.h" #include #if defined(QT_PRINTSUPPORT_LIB) @@ -105,7 +106,8 @@ private: QAction *selectStorageAction, *storeSettingsAction; QAction *projectSettingsAction; QString storageLocation = ""; - + ProjectMetadata mdata; + #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) QPrinter printer; #endif