14 #include <QApplication>
18 #include <QDoubleSpinBox>
19 #include <QGraphicsScene>
20 #include <QGridLayout>
24 #include <QPushButton>
44 "DlgSettingsMainWindow",
46 m_modelMainWindowBefore (nullptr),
47 m_modelMainWindowAfter (nullptr)
61 void DlgSettingsMainWindow::createControls (QGridLayout *layout,
66 const int COLUMN0 = 0;
68 QLabel *labelZoomFactor =
new QLabel (QString (
"%1:").arg (tr (
"Initial zoom")));
69 layout->addWidget (labelZoomFactor, row, 1);
71 m_cmbZoomFactor =
new QComboBox;
83 m_cmbZoomFactor->setWhatsThis(tr (
"Initial Zoom\n\n"
84 "Select the initial zoom factor when a new document is loaded. Either the previous "
85 "zoom can be kept, or the specified zoom can be applied."));
86 connect (m_cmbZoomFactor, SIGNAL (currentTextChanged (
const QString)),
this, SLOT (slotZoomFactor(
const QString)));
87 layout->addWidget (m_cmbZoomFactor, row++, 2);
89 QLabel *labelZoomControl =
new QLabel (QString (
"%1:").arg (tr (
"Zoom control")));
90 layout->addWidget (labelZoomControl, row, 1);
92 m_cmbZoomControl =
new QComboBox;
97 m_cmbZoomControl->setWhatsThis (tr (
"Zoom Control\n\n"
98 "Select which inputs are used to zoom in and out."));
99 connect (m_cmbZoomControl, SIGNAL (currentTextChanged (
const QString)),
this, SLOT (slotZoomControl(
const QString)));
100 layout->addWidget (m_cmbZoomControl, row++, 2);
102 QLabel *labelLocale =
new QLabel (QString (
"%1:").arg (tr (
"Locale (requires restart)")));
103 layout->addWidget (labelLocale, row, 1);
106 m_cmbLocale =
new QComboBox;
107 m_cmbLocale->setWhatsThis(tr (
"Locale\n\n"
108 "Select the locale that will be used in numbers (immediately), and the language in the user "
109 "interface (after restart).\n\n"
110 "The locale determines how numbers are formatted. Specifically, either commas or "
111 "periods will be used as group delimiters in each number entered "
112 "by the user, displayed in the user interface, or exported to a file."));
113 QStringList qmFilenames;
114 qmFilenames << gatherQmFilenames ();
115 for (
int i = 0; i < qmFilenames.size(); i++) {
116 QString localeSelector = qmFilenames [i];
117 localeSelector.truncate (localeSelector.lastIndexOf (
'.'));
118 localeSelector.remove (0, localeSelector.indexOf (
'_') + 1);
119 QLocale locale (localeSelector);
121 m_cmbLocale->addItem (label, locale);
123 m_cmbLocale->model()->sort(COLUMN0);
124 connect (m_cmbLocale, SIGNAL (currentIndexChanged (
int)),
this, SLOT (slotLocale (
int)));
125 layout->addWidget (m_cmbLocale, row++, 2);
127 QLabel *labelImportCropping =
new QLabel (QString (
"%1:").arg (tr (
"Import cropping")));
128 layout->addWidget (labelImportCropping, row, 1);
130 m_cmbImportCropping =
new QComboBox;
131 m_cmbImportCropping->setWhatsThis (tr (
"Import Cropping\n\n"
132 "Enables or disables cropping of the imported image when importing. Cropping the image is useful "
133 "for removing unimportant information around a graph, but less useful when the graph already fills "
134 "the entire image.\n\n"
135 "This setting only has an effect when Engauge has been built with support for pdf files."));
140 connect (m_cmbImportCropping, SIGNAL (currentIndexChanged (
int)),
this, SLOT (slotImportCropping (
int)));
141 layout->addWidget (m_cmbImportCropping, row++, 2);
144 QLabel *labelPdfResolution =
new QLabel (QString (
"%1:").arg (tr (
"Import PDF resolution (dots per inch)")));
145 layout->addWidget (labelPdfResolution, row, 1);
147 m_cmbPdfResolution =
new QComboBox;
148 m_cmbPdfResolution->setWhatsThis (tr (
"Import PDF Resolution\n\n"
149 "Imported Portable Document Format (PDF) files will be converted to this pixel resolution "
150 "in dots per inch (DPI), where each pixel is one dot. A higher value increases the picture resolution "
151 "and may also improve numeric digitizing accuracy. However, a very high value can make the image so "
152 "large that Engauge will slow down."));
153 m_cmbPdfResolution->addItem (
"75", 75);
154 m_cmbPdfResolution->addItem (
"100", 100);
155 m_cmbPdfResolution->addItem (
"150", 150);
156 m_cmbPdfResolution->addItem (
"200", 200);
157 m_cmbPdfResolution->addItem (
"250", 250);
158 m_cmbPdfResolution->addItem (
"300", 300);
159 connect (m_cmbPdfResolution, SIGNAL (currentTextChanged (QString)),
this, SLOT (slotPdfResolution (QString)));
160 layout->addWidget (m_cmbPdfResolution, row++, 2);
163 QLabel *labelMaximumGridLines =
new QLabel (QString (
"%1:").arg (tr (
"Maximum grid lines")));
164 layout->addWidget (labelMaximumGridLines, row, 1);
166 m_spinMaximumGridLines =
new QSpinBox;
168 m_spinMaximumGridLines->setWhatsThis (tr (
"Maximum Grid Lines\n\n"
169 "Maximum number of grid lines to be processed. This limit is applied when the step value is too "
170 "small for the start and stop values, which would result in too many grid lines visually and "
171 "possibly extremely long processing time (since each grid line would have to be processed)"));
172 connect (m_spinMaximumGridLines, SIGNAL (valueChanged (
int)),
this, (SLOT (slotMaximumGridLines (
int))));
173 layout->addWidget (m_spinMaximumGridLines, row++, 2);
175 QLabel *labelHighlightOpacity =
new QLabel (QString (
"%1:").arg (tr (
"Highlight opacity")));
176 layout->addWidget (labelHighlightOpacity, row, 1);
178 m_spinHighlightOpacity =
new QDoubleSpinBox;
179 m_spinHighlightOpacity->setRange (0, 1);
180 m_spinHighlightOpacity->setSingleStep (0.1);
181 m_spinHighlightOpacity->setWhatsThis (tr (
"Highlight Opacity\n\n"
182 "Opacity to be applied when the cursor is over a curve or axis point in Select mode. The change in "
183 "appearance shows when the point can be selected."));
184 connect (m_spinHighlightOpacity, SIGNAL (valueChanged (
double)),
this, SLOT (slotHighlightOpacity(
double)));
185 layout->addWidget (m_spinHighlightOpacity, row++, 2);
187 QLabel *labelRecent =
new QLabel (QString (
"%1:").arg (tr (
"Recent file list")));
188 layout->addWidget (labelRecent, row, 1);
190 m_btnRecentClear =
new QPushButton (tr (
"Clear"));
191 m_btnRecentClear->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
192 m_btnRecentClear->setWhatsThis (tr (
"Recent File List Clear\n\n"
193 "Clear the recent file list in the File menu."));
194 connect (m_btnRecentClear, SIGNAL (pressed ()), &
mainWindow(), SLOT (slotRecentFileClear ()));
195 connect (m_btnRecentClear, SIGNAL (pressed ()),
this, SLOT (slotRecentFileClear()));
196 layout->addWidget (m_btnRecentClear, row++, 2);
198 QLabel *labelTitleBarFormat =
new QLabel (QString (
"%1:").arg (tr (
"Include title bar path")));
199 layout->addWidget (labelTitleBarFormat, row, 1);
201 m_chkTitleBarFormat =
new QCheckBox;
202 m_chkTitleBarFormat->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
203 m_chkTitleBarFormat->setWhatsThis (tr (
"Title Bar Filename\n\n"
204 "Includes or excludes the path and file extension from the filename in the title bar."));
205 connect (m_chkTitleBarFormat, SIGNAL (toggled (
bool)),
this, SLOT (slotTitleBarFormat(
bool)));
206 layout->addWidget (m_chkTitleBarFormat, row++, 2);
208 QLabel *labelSmallDialogs =
new QLabel (QString (
"%1:").arg (tr (
"Allow small dialogs")));
209 layout->addWidget (labelSmallDialogs, row, 1);
211 m_chkSmallDialogs =
new QCheckBox;
212 m_chkSmallDialogs->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
213 m_chkSmallDialogs->setWhatsThis (tr (
"Allow Small Dialogs\n\n"
214 "Allows settings dialogs to be made very small so they fit on small computer screens."));
215 connect (m_chkSmallDialogs, SIGNAL (toggled (
bool)),
this, SLOT (slotSmallDialogs (
bool)));
216 layout->addWidget (m_chkSmallDialogs, row++, 2);
218 QLabel *labelDragDropExport =
new QLabel (QString (
"%1:").arg (tr (
"Allow drag and drop export")));
219 layout->addWidget (labelDragDropExport, row, 1);
221 m_chkDragDropExport =
new QCheckBox;
222 m_chkDragDropExport->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
223 m_chkDragDropExport->setWhatsThis (tr (
"Allow Drag and Drop Export\n\n"
224 "Allows drag and drop export from the Curve Fitting Window and Geometry Window tables.\n\n"
225 "When drag and drop is disabled, a rectangular set of table cells can be selected using click and "
226 "drag. When drag and drop is enabled, a rectangular set of table cells can be selected using Click "
227 "then Shift+Click, since click and drag starts the drag operation."));
228 connect (m_chkDragDropExport, SIGNAL (toggled (
bool)),
this, SLOT (slotDragDropExport (
bool)));
229 layout->addWidget (m_chkDragDropExport, row++, 2);
231 QLabel *labelImageReplaceRenamesDocument =
new QLabel (QString (
"%1:").arg (tr (
"Image replace renames document")));
232 layout->addWidget (labelImageReplaceRenamesDocument, row, 1);
234 m_chkImageReplaceRenamesDocument =
new QCheckBox;
235 m_chkImageReplaceRenamesDocument->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
236 m_chkImageReplaceRenamesDocument->setWhatsThis (tr (
"Image Replace Renames Document\n\n"
237 "When an image is imported to replace the current image, the document "
238 "will be renamed if this is true, otherwise the name will stay the same."));
239 connect (m_chkImageReplaceRenamesDocument, SIGNAL (toggled (
bool)),
this, SLOT (slotImageReplaceRenamesDocument (
bool)));
240 layout->addWidget (m_chkImageReplaceRenamesDocument, row++, 2);
242 QLabel *labelSignificantDigits =
new QLabel (QString (
"%1:").arg (tr (
"Significant digits")));
243 layout->addWidget (labelSignificantDigits, row, 1);
245 m_spinSignificantDigits =
new QSpinBox;
247 m_spinSignificantDigits->setWhatsThis (tr (
"Significant Digits\n\n"
248 "Number of digits of precision in floating point numbers. This value affects "
249 "calculations for curve fits, since intermediate results smaller than a "
250 "threshold T indicate that a polynomial curve with a specific order cannot be "
251 "fitted to the data. The threshold T is computed from the maximum matrix "
252 "element M and significant digits S as T = M / 10^S."));
253 connect (m_spinSignificantDigits, SIGNAL (valueChanged (
int)),
this, SLOT (slotSignificantDigits (
int)));
254 layout->addWidget (m_spinSignificantDigits, row++, 2);
266 QWidget *subPanel =
new QWidget ();
267 QGridLayout *layout =
new QGridLayout (subPanel);
268 subPanel->setLayout (layout);
270 layout->setColumnStretch(0, 1);
271 layout->setColumnStretch(1, 0);
272 layout->setColumnStretch(2, 0);
273 layout->setColumnStretch(3, 1);
276 createControls (layout, row);
281 QStringList DlgSettingsMainWindow::gatherQmFilenames ()
const
286 QStringList filenames = translationPath.entryList (QStringList (
"engauge_*.qm"));
315 delete m_modelMainWindowBefore;
316 delete m_modelMainWindowAfter;
323 int index = m_cmbZoomFactor->findData (m_modelMainWindowAfter->
zoomFactorInitial());
324 m_cmbZoomFactor->setCurrentIndex (index);
325 index = m_cmbZoomControl->findData (m_modelMainWindowAfter->
zoomControl());
326 m_cmbZoomControl->setCurrentIndex (index);
328 index = m_cmbLocale->findText (locLabel);
332 index = m_cmbLocale->findText (locLabel);
334 m_cmbLocale->setCurrentIndex(index);
335 index = m_cmbImportCropping->findData (m_modelMainWindowAfter->
importCropping());
336 m_cmbImportCropping->setCurrentIndex (index);
339 index = m_cmbPdfResolution->findData (m_modelMainWindowAfter->
pdfResolution());
340 m_cmbPdfResolution->setCurrentIndex(index);
342 m_spinMaximumGridLines->setValue (m_modelMainWindowAfter->
maximumGridLines());
343 m_spinHighlightOpacity->setValue (m_modelMainWindowAfter->
highlightOpacity());
344 m_chkSmallDialogs->setChecked (m_modelMainWindowAfter->
smallDialogs());
345 m_chkDragDropExport->setChecked (m_modelMainWindowAfter->
dragDropExport());
346 m_spinSignificantDigits->setValue (m_modelMainWindowAfter->
significantDigits ());
357 void DlgSettingsMainWindow::slotDragDropExport (
bool)
365 void DlgSettingsMainWindow::slotHighlightOpacity(
double)
373 void DlgSettingsMainWindow::slotImageReplaceRenamesDocument (
bool)
381 void DlgSettingsMainWindow::slotImportCropping (
int index)
385 m_modelMainWindowAfter->
setImportCropping (static_cast<ImportCropping> (m_cmbImportCropping->itemData (index).toInt ()));
389 void DlgSettingsMainWindow::slotLocale (
int index)
393 QLocale locale = m_cmbLocale->itemData (index).toLocale();
395 m_modelMainWindowAfter->
setLocale (locale);
399 void DlgSettingsMainWindow::slotMaximumGridLines (
int limit)
407 void DlgSettingsMainWindow::slotPdfResolution(
const QString)
412 m_modelMainWindowAfter->
setPdfResolution(m_cmbPdfResolution->currentData().toInt());
417 void DlgSettingsMainWindow::slotRecentFileClear()
425 void DlgSettingsMainWindow::slotSignificantDigits(
int)
433 void DlgSettingsMainWindow::slotSmallDialogs (
bool)
437 m_modelMainWindowAfter->
setSmallDialogs (m_chkSmallDialogs->isChecked());
441 void DlgSettingsMainWindow::slotTitleBarFormat(
bool)
451 void DlgSettingsMainWindow::slotZoomControl(
const QString)
455 m_modelMainWindowAfter->
setZoomControl (static_cast<ZoomControl> (m_cmbZoomControl->currentData().toInt()));
459 void DlgSettingsMainWindow::slotZoomFactor(
const QString)
463 m_modelMainWindowAfter->
setZoomFactorInitial(static_cast<ZoomFactorInitial> (m_cmbZoomFactor->currentData().toInt()));
467 void DlgSettingsMainWindow::updateControls ()