| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#include "xrdoptionsdialog.h" |
| 7 |
#include "ui_xrdoptionsdialog.h" |
| 8 |
|
| 9 |
#include <QtCore/QSettings> |
| 10 |
|
| 11 |
namespace Avogadro::QtPlugins { |
| 12 |
|
| 13 |
XrdOptionsDialog::XrdOptionsDialog(QWidget* aParent) |
| 14 |
: QDialog(aParent), m_ui(new Ui::XrdOptionsDialog) |
| 15 |
{ |
| 16 |
m_ui->setupUi(this); |
| 17 |
|
| 18 |
// Read the settings |
| 19 |
QSettings settings; |
| 20 |
m_ui->spin_wavelength->setValue( |
| 21 |
settings.value("plotxrdoptions/wavelength", 1.505600).toDouble()); |
| 22 |
m_ui->spin_peakWidth->setValue( |
| 23 |
settings.value("plotxrdoptions/peakWidth", 0.529580).toDouble()); |
| 24 |
m_ui->spin_numDataPoints->setValue( |
| 25 |
settings.value("plotxrdoptions/numDataPoints", 1000).toUInt()); |
| 26 |
m_ui->spin_max2Theta->setValue( |
| 27 |
settings.value("plotxrdoptions/max2Theta", 162.0).toDouble()); |
| 28 |
} |
| 29 |
|
| 30 |
XrdOptionsDialog::~XrdOptionsDialog() = default; |
| 31 |
|
| 32 |
double XrdOptionsDialog::wavelength() const |
| 33 |
{ |
| 34 |
return m_ui->spin_wavelength->value(); |
| 35 |
} |
| 36 |
|
| 37 |
double XrdOptionsDialog::peakWidth() const |
| 38 |
{ |
| 39 |
return m_ui->spin_peakWidth->value(); |
| 40 |
} |
| 41 |
|
| 42 |
size_t XrdOptionsDialog::numDataPoints() const |
| 43 |
{ |
| 44 |
return m_ui->spin_numDataPoints->value(); |
| 45 |
} |
| 46 |
|
| 47 |
double XrdOptionsDialog::max2Theta() const |
| 48 |
{ |
| 49 |
return m_ui->spin_max2Theta->value(); |
| 50 |
} |
| 51 |
|
| 52 |
void XrdOptionsDialog::accept() |
| 53 |
{ |
| 54 |
// Write the settings and accept |
| 55 |
QSettings settings; |
| 56 |
settings.setValue("plotxrdoptions/wavelength", wavelength()); |
| 57 |
settings.setValue("plotxrdoptions/peakWidth", peakWidth()); |
| 58 |
settings.setValue("plotxrdoptions/numDataPoints", |
| 59 |
static_cast<qlonglong>(numDataPoints())); |
| 60 |
settings.setValue("plotxrdoptions/max2Theta", max2Theta()); |
| 61 |
|
| 62 |
QDialog::accept(); |
| 63 |
} |
| 64 |
|
| 65 |
} // namespace Avogadro::QtPlugins |