BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectSettingsView Class Reference

Description

Widget to define project settings.

Definition at line 27 of file ProjectSettingsView.h.

Inheritance diagram for ProjectSettingsView:
[legend]
Collaboration diagram for ProjectSettingsView:
[legend]

Public Member Functions

 ProjectSettingsView (QWidget *parentWidget, ProjectDocument *document)
 

Protected Member Functions

void showEvent (QShowEvent *) override
 

Private Member Functions

ProjectDocument::Functionalities functionalities () const
 
void onFunctionalityToggled ()
 
void onSingleInstrumentRadioToggled (bool newState)
 
void onSingleSampleRadioToggled (bool newState)
 
void storeAsDefaults ()
 
void updateInformation ()
 
void writeFunctionalityToUI ()
 
void writeOptionsToUI ()
 Write entries in OptionsItem to UI. More...
 

Private Attributes

ProjectDocumentm_document
 
Ui::ProjectSettingsView * m_ui
 

Constructor & Destructor Documentation

◆ ProjectSettingsView()

ProjectSettingsView::ProjectSettingsView ( QWidget *  parentWidget,
ProjectDocument document 
)

Definition at line 23 of file ProjectSettingsView.cpp.

24  : QWidget(parentWidget)
25  , m_ui(new Ui::ProjectSettingsView)
26  , m_document(document)
27 {
28  m_ui->setupUi(this);
29  m_ui->label_6->hide(); // #baTODO show again
30  m_ui->textEdit->hide();
31 
32  setAttribute(Qt::WA_StyledBackground, true);
33  setProperty("stylable", true); // for stylesheet addressing
34 
39 
40  connect(m_ui->singleInstrumentModeRadio, &QRadioButton::toggled, this,
42 
43  connect(m_ui->singleSampleModeRadio, &QRadioButton::toggled, this,
45 
46  connect(m_ui->gisasCheck, &QCheckBox::toggled, this,
48  connect(m_ui->offspecCheck, &QCheckBox::toggled, this,
50  connect(m_ui->reflectometryCheck, &QCheckBox::toggled, this,
52  connect(m_ui->depthCheck, &QCheckBox::toggled, this,
54 
55  connect(m_ui->storeAsDefaultsButton, &QPushButton::clicked, this,
57 
58  // #baTODO should be "informationModified" or so?
60 }
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
void modified()
Emitted for any modifications in the document.
Ui::ProjectSettingsView * m_ui
ProjectDocument * m_document
void onSingleSampleRadioToggled(bool newState)
void onSingleInstrumentRadioToggled(bool newState)

References GroupBoxCollapser::installIntoGroupBox(), m_document, m_ui, ProjectDocument::modified(), onFunctionalityToggled(), onSingleInstrumentRadioToggled(), onSingleSampleRadioToggled(), storeAsDefaults(), and updateInformation().

Here is the call graph for this function:

Member Function Documentation

◆ functionalities()

ProjectDocument::Functionalities ProjectSettingsView::functionalities ( ) const
private

Definition at line 169 of file ProjectSettingsView.cpp.

170 {
171  ProjectDocument::Functionalities f;
172  f.setFlag(ProjectDocument::Gisas, m_ui->gisasCheck->isChecked());
173  f.setFlag(ProjectDocument::Offspec, m_ui->offspecCheck->isChecked());
174  f.setFlag(ProjectDocument::Specular, m_ui->reflectometryCheck->isChecked());
175  f.setFlag(ProjectDocument::DepthProbe, m_ui->depthCheck->isChecked());
176  return f;
177 }

References ProjectDocument::DepthProbe, ProjectDocument::Gisas, m_ui, ProjectDocument::Offspec, and ProjectDocument::Specular.

Referenced by onFunctionalityToggled(), and storeAsDefaults().

◆ onFunctionalityToggled()

void ProjectSettingsView::onFunctionalityToggled ( )
private

Definition at line 153 of file ProjectSettingsView.cpp.

154 {
155  const auto f = functionalities();
156 
157  if (f == ProjectDocument::None) {
158  QMessageBox::warning(this, "Select functionality",
159  "You have to select at least one functionality. Changing "
160  "this setting is not possible.");
161 
163  return;
164  }
165 
167 }
void setFunctionalities(const Functionalities &f)
ProjectDocument::Functionalities functionalities() const
void warning(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
Definition: MessageBox.cpp:37

References functionalities(), m_document, ProjectDocument::None, ProjectDocument::setFunctionalities(), GUI::View::Helpers::warning(), and writeFunctionalityToUI().

Referenced by ProjectSettingsView().

Here is the call graph for this function:

◆ onSingleInstrumentRadioToggled()

void ProjectSettingsView::onSingleInstrumentRadioToggled ( bool  newState)
private

Definition at line 116 of file ProjectSettingsView.cpp.

117 {
118  if (newState) {
119  if (m_document->collectedItems()->collectedItems().size() > 1) {
120  QMessageBox::warning(this, "Select single instrument mode",
121  "This project already contains more than one instrument. Changing "
122  "this setting is not possible.");
123 
124  QSignalBlocker b1(m_ui->singleInstrumentModeRadio);
125  m_ui->multipleInstrumentModeRadio->setChecked(true);
126  return;
127  }
128 
130  } else
132 }
QVector< InstrumentItem * > collectedItems() const
void setSingleInstrumentMode(bool b)
InstrumentCollection * collectedItems() const

References InstrumentCollection::collectedItems(), ProjectDocument::collectedItems(), m_document, m_ui, ProjectDocument::setSingleInstrumentMode(), and GUI::View::Helpers::warning().

Referenced by ProjectSettingsView().

Here is the call graph for this function:

◆ onSingleSampleRadioToggled()

void ProjectSettingsView::onSingleSampleRadioToggled ( bool  newState)
private

Definition at line 135 of file ProjectSettingsView.cpp.

136 {
137  if (newState) {
138  if (m_document->sampleItems()->sampleItems().size() > 1) {
139  QMessageBox::warning(this, "Select single sample mode",
140  "This project already contains more than one sample. Changing "
141  "this setting is not possible.");
142 
143  QSignalBlocker b1(m_ui->singleSampleModeRadio);
144  m_ui->multipleSampleModeRadio->setChecked(true);
145  return;
146  }
147 
149  } else
151 }
QVector< MultiLayerItem * > sampleItems() const
void setSingleSampleMode(bool b)
MultiLayerItems * sampleItems()

References m_document, m_ui, ProjectDocument::sampleItems(), MultiLayerItems::sampleItems(), ProjectDocument::setSingleSampleMode(), and GUI::View::Helpers::warning().

Referenced by ProjectSettingsView().

Here is the call graph for this function:

◆ showEvent()

void ProjectSettingsView::showEvent ( QShowEvent *  )
overrideprotected

Definition at line 62 of file ProjectSettingsView.cpp.

63 {
65 }
void writeOptionsToUI()
Write entries in OptionsItem to UI.

References writeOptionsToUI().

Here is the call graph for this function:

◆ storeAsDefaults()

void ProjectSettingsView::storeAsDefaults ( )
private

Definition at line 109 of file ProjectSettingsView.cpp.

110 {
112  appSettings->setDefaultIsSingleInstrumentMode(m_ui->singleInstrumentModeRadio->isChecked());
113  appSettings->setDefaultIsSingleSampleMode(m_ui->singleSampleModeRadio->isChecked());
114 }
ApplicationSettings * appSettings
global pointer to the instance
QVariant toVariant(const ProjectDocument::Functionalities &f)
void setDefaultIsSingleInstrumentMode(bool b)
void setDefaultFunctionalities(const QVariant &functionalities)
void setDefaultIsSingleSampleMode(bool b)

References appSettings, functionalities(), m_ui, ApplicationSettings::setDefaultFunctionalities(), ApplicationSettings::setDefaultIsSingleInstrumentMode(), ApplicationSettings::setDefaultIsSingleSampleMode(), and toVariant().

Referenced by ProjectSettingsView().

Here is the call graph for this function:

◆ updateInformation()

void ProjectSettingsView::updateInformation ( )
private

Definition at line 96 of file ProjectSettingsView.cpp.

97 {
98  QString location = "[not saved yet]";
99 
100  QString name = m_document->projectName();
103  QDir::toNativeSeparators(m_document->projectFileName()));
104 
105  m_ui->currentProjectName->setText(name);
106  m_ui->currentProjectLocation->setText(location);
107 }
QString projectFileName() const
QString projectName() const
QString const & name(EShape k)
Definition: particles.cpp:20
QString withTildeHomePath(const QString &path)
Definition: Path.cpp:45

References ProjectDocument::hasValidNameAndPath(), m_document, m_ui, GUI::RealSpace::Particles::name(), ProjectDocument::projectFileName(), ProjectDocument::projectName(), and GUI::Util::Path::withTildeHomePath().

Referenced by ProjectSettingsView(), and writeOptionsToUI().

Here is the call graph for this function:

◆ writeFunctionalityToUI()

void ProjectSettingsView::writeFunctionalityToUI ( )
private

Definition at line 81 of file ProjectSettingsView.cpp.

82 {
83  const auto f = m_document->functionalities();
84 
85  QSignalBlocker b1(m_ui->gisasCheck);
86  QSignalBlocker b2(m_ui->offspecCheck);
87  QSignalBlocker b3(m_ui->reflectometryCheck);
88  QSignalBlocker b4(m_ui->depthCheck);
89 
90  m_ui->gisasCheck->setChecked(f.testFlag(ProjectDocument::Gisas));
91  m_ui->offspecCheck->setChecked(f.testFlag(ProjectDocument::Offspec));
92  m_ui->reflectometryCheck->setChecked(f.testFlag(ProjectDocument::Specular));
93  m_ui->depthCheck->setChecked(f.testFlag(ProjectDocument::DepthProbe));
94 }
Functionalities functionalities() const

References ProjectDocument::DepthProbe, ProjectDocument::functionalities(), ProjectDocument::Gisas, m_document, m_ui, ProjectDocument::Offspec, and ProjectDocument::Specular.

Referenced by onFunctionalityToggled(), and writeOptionsToUI().

Here is the call graph for this function:

◆ writeOptionsToUI()

void ProjectSettingsView::writeOptionsToUI ( )
private

Write entries in OptionsItem to UI.

Definition at line 67 of file ProjectSettingsView.cpp.

68 {
69  QSignalBlocker b1(m_ui->singleInstrumentModeRadio);
70 
71  m_document->singleInstrumentMode() ? m_ui->singleInstrumentModeRadio->setChecked(true)
72  : m_ui->multipleInstrumentModeRadio->setChecked(true);
73 
74  m_document->singleSampleMode() ? m_ui->singleSampleModeRadio->setChecked(true)
75  : m_ui->multipleSampleModeRadio->setChecked(true);
76 
79 }
bool singleInstrumentMode() const
bool singleSampleMode() const

References m_document, m_ui, ProjectDocument::singleInstrumentMode(), ProjectDocument::singleSampleMode(), updateInformation(), and writeFunctionalityToUI().

Referenced by showEvent().

Here is the call graph for this function:

Member Data Documentation

◆ m_document

◆ m_ui


The documentation for this class was generated from the following files: