1 #include "CmdMediator.h"
2 #include "CmdSettingsGeneral.h"
3 #include "DlgSettingsGeneral.h"
4 #include "EngaugeAssert.h"
6 #include "MainWindow.h"
8 #include <QGraphicsScene>
13 #include <QPushButton>
22 m_modelGeneralBefore (0),
23 m_modelGeneralAfter (0)
25 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::DlgSettingsGeneral";
31 DlgSettingsGeneral::~DlgSettingsGeneral()
33 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::~DlgSettingsGeneral";
36 void DlgSettingsGeneral::createControls (QGridLayout *layout,
39 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::createControls";
41 QLabel *labelCursorSize =
new QLabel (
"Cursor size (pixels):");
42 layout->addWidget (labelCursorSize, row, 1);
44 m_spinCursorSize =
new QSpinBox;
45 m_spinCursorSize->setMinimum (1);
46 m_spinCursorSize->setWhatsThis (tr (
"Effective Cursor Size\n\n"
47 "This is the effective width and height of the cursor when clicking on a pixel that is "
48 "not part of the background.\n\n"
49 "This parameter is used in the Color Picker and Point Match modes"));
50 connect (m_spinCursorSize, SIGNAL (valueChanged (
int)),
this, SLOT (slotCursorSize (
int)));
51 layout->addWidget (m_spinCursorSize, row++, 2);
53 QLabel *labelExtraPrecision =
new QLabel (
"Extra precision (digits):");
54 layout->addWidget (labelExtraPrecision, row, 1);
56 m_spinExtraPrecision =
new QSpinBox;
57 m_spinExtraPrecision->setMinimum (0);
58 m_spinExtraPrecision->setWhatsThis (tr (
"Extra Digits of Precision\n\n"
59 "This is the number of additional digits of precision appended after the significant "
60 "digits determined by the digitization accuracy at that point. The digitization accuracy "
61 "at any point equals the change in graph coordinates from moving one pixel in each direction. "
62 "Appending extra digits does not improve the accuracy of the numbers. More information can "
63 "be found in discussions of accuracy versus precision.\n\n"
64 "This parameter is used on the coordinates in the Status Bar and during Export"));
65 connect (m_spinExtraPrecision, SIGNAL (valueChanged (
int)),
this, SLOT (slotExtraPrecision (
int)));
66 layout->addWidget (m_spinExtraPrecision, row++, 2);
71 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::createOptionalSaveDefault";
73 m_btnSaveDefault =
new QPushButton (
"Save As Default");
74 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults, according to the curve name selection."));
75 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
76 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
81 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::createSubPanel";
83 QWidget *subPanel =
new QWidget ();
84 QGridLayout *layout =
new QGridLayout (subPanel);
85 subPanel->setLayout (layout);
87 layout->setColumnStretch(0, 1);
88 layout->setColumnStretch(1, 0);
89 layout->setColumnStretch(2, 0);
90 layout->setColumnStretch(3, 1);
93 createControls (layout, row);
100 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::handleOk";
104 *m_modelGeneralBefore,
105 *m_modelGeneralAfter);
113 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::load";
118 if (m_modelGeneralBefore != 0) {
119 delete m_modelGeneralBefore;
121 if (m_modelGeneralAfter != 0) {
122 delete m_modelGeneralAfter;
130 m_spinCursorSize->setValue (m_modelGeneralAfter->
cursorSize());
131 m_spinExtraPrecision->setValue (m_modelGeneralAfter->
extraPrecision());
137 void DlgSettingsGeneral::slotCursorSize (
int cursorSize)
139 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::slotCursorSize";
145 void DlgSettingsGeneral::slotExtraPrecision (
int extraPrecision)
147 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::slotExtraPrecision";
153 void DlgSettingsGeneral::slotSaveDefault()
155 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsGeneral::slotSaveDefault";
157 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
158 settings.beginGroup (SETTINGS_GROUP_GENERAL);
160 settings.setValue (SETTINGS_GENERAL_CURSOR_SIZE,
162 settings.setValue (SETTINGS_GENERAL_EXTRA_PRECISION,
164 settings.endGroup ();
167 void DlgSettingsGeneral::updateControls ()
Model for DlgSettingsGeneral and CmdSettingsGeneral.
void setCursorSize(int cursorSize)
Set method for effective cursor size.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
int cursorSize() const
Get method for effective cursor size.
virtual void handleOk()
Process slotOk.
DlgSettingsGeneral(MainWindow &mainWindow)
Single constructor.
Command for DlgSettingsGeneral.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
Abstract base class for all Settings dialogs.
int extraPrecision() const
Get method for extra digits of precsion.
void setExtraPrecision(int extraPrecision)
Set method for extra digits of precision.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.