14#include <QApplication>
18#include <QDoubleSpinBox>
19#include <QGraphicsScene>
50 "DlgSettingsMainWindow",
52 m_modelMainWindowBefore (nullptr),
53 m_modelMainWindowAfter (nullptr)
67void DlgSettingsMainWindow::createControls (QGridLayout *layout,
72 const int COLUMN0 = 0;
74 QLabel *labelZoomFactor =
new QLabel (QString (
"%1:").arg (tr (
"Initial zoom")));
75 layout->addWidget (labelZoomFactor, row, 1);
77 m_cmbZoomFactor =
new QComboBox;
89 m_cmbZoomFactor->setWhatsThis(tr (
"Initial Zoom\n\n"
90 "Select the initial zoom factor when a new document is loaded. Either the previous "
91 "zoom can be kept, or the specified zoom can be applied."));
92 connect (m_cmbZoomFactor, SIGNAL (currentTextChanged (
const QString)),
this, SLOT (slotZoomFactor(
const QString)));
93 layout->addWidget (m_cmbZoomFactor, row++, 2);
95 QLabel *labelZoomControl =
new QLabel (QString (
"%1:").arg (tr (
"Zoom control")));
96 layout->addWidget (labelZoomControl, row, 1);
98 m_cmbZoomControl =
new QComboBox;
103 m_cmbZoomControl->setWhatsThis (tr (
"Zoom Control\n\n"
104 "Select which inputs are used to zoom in and out."));
105 connect (m_cmbZoomControl, SIGNAL (currentTextChanged (
const QString)),
this, SLOT (slotZoomControl(
const QString)));
106 layout->addWidget (m_cmbZoomControl, row++, 2);
108 QLabel *labelLocale =
new QLabel (QString (
"%1:").arg (tr (
"Locale (requires restart)")));
109 layout->addWidget (labelLocale, row, 1);
112 m_cmbLocale =
new QComboBox;
113 m_cmbLocale->setWhatsThis(tr (
"Locale\n\n"
114 "Select the locale that will be used in numbers (immediately), and the language in the user "
115 "interface (after restart).\n\n"
116 "The locale determines how numbers are formatted. Specifically, either commas or "
117 "periods will be used as group delimiters in each number entered "
118 "by the user, displayed in the user interface, or exported to a file."));
119 QStringList qmFilenames;
120 qmFilenames << gatherQmFilenames ();
121 for (
int i = 0; i < qmFilenames.size(); i++) {
122 QString localeSelector = qmFilenames [i];
123 localeSelector.truncate (localeSelector.lastIndexOf (
'.'));
124 localeSelector.remove (0, localeSelector.indexOf (
'_') + 1);
125 QLocale locale (localeSelector);
127 m_cmbLocale->addItem (label, locale);
129 m_cmbLocale->model()->sort(COLUMN0);
130 connect (m_cmbLocale, SIGNAL (currentIndexChanged (
int)),
this, SLOT (slotLocale (
int)));
131 layout->addWidget (m_cmbLocale, row++, 2);
133 QLabel *labelImportCropping =
new QLabel (QString (
"%1:").arg (tr (
"Import cropping")));
134 layout->addWidget (labelImportCropping, row, 1);
136 m_cmbImportCropping =
new QComboBox;
137 m_cmbImportCropping->setWhatsThis (tr (
"Import Cropping\n\n"
138 "Enables or disables cropping of the imported image when importing. Cropping the image is useful "
139 "for removing unimportant information around a graph, but less useful when the graph already fills "
140 "the entire image.\n\n"
141 "This setting only has an effect when Engauge has been built with support for pdf files."));
142 ImportCroppingUtilBase importCroppingUtil;
146 connect (m_cmbImportCropping, SIGNAL (currentIndexChanged (
int)),
this, SLOT (slotImportCropping (
int)));
147 layout->addWidget (m_cmbImportCropping, row++, 2);
150 QLabel *labelPdfResolution =
new QLabel (QString (
"%1:").arg (tr (
"Import PDF resolution (dots per inch)")));
151 layout->addWidget (labelPdfResolution, row, 1);
153 m_cmbPdfResolution =
new QComboBox;
154 m_cmbPdfResolution->setWhatsThis (tr (
"Import PDF Resolution\n\n"
155 "Imported Portable Document Format (PDF) files will be converted to this pixel resolution "
156 "in dots per inch (DPI), where each pixel is one dot. A higher value increases the picture resolution "
157 "and may also improve numeric digitizing accuracy. However, a very high value can make the image so "
158 "large that Engauge will slow down."));
159 m_cmbPdfResolution->addItem (
"75", 75);
160 m_cmbPdfResolution->addItem (
"100", 100);
161 m_cmbPdfResolution->addItem (
"150", 150);
162 m_cmbPdfResolution->addItem (
"200", 200);
163 m_cmbPdfResolution->addItem (
"250", 250);
164 m_cmbPdfResolution->addItem (
"300", 300);
165 connect (m_cmbPdfResolution, SIGNAL (currentTextChanged (QString)),
this, SLOT (slotPdfResolution (QString)));
166 layout->addWidget (m_cmbPdfResolution, row++, 2);
169 QLabel *labelMaximumGridLines =
new QLabel (QString (
"%1:").arg (tr (
"Maximum grid lines")));
170 layout->addWidget (labelMaximumGridLines, row, 1);
172 m_spinMaximumGridLines =
new QSpinBox;
174 m_spinMaximumGridLines->setWhatsThis (tr (
"Maximum Grid Lines\n\n"
175 "Maximum number of grid lines to be processed. This limit is applied when the step value is too "
176 "small for the start and stop values, which would result in too many grid lines visually and "
177 "possibly extremely long processing time (since each grid line would have to be processed)"));
178 connect (m_spinMaximumGridLines, SIGNAL (valueChanged (
int)),
this, (SLOT (slotMaximumGridLines (
int))));
179 layout->addWidget (m_spinMaximumGridLines, row++, 2);
181 QLabel *labelExportedPoints =
new QLabel (QString (
"%1:").arg (tr (
"Maximum exported points per curve")));
182 layout->addWidget (labelExportedPoints, row, 1);
184 m_spinMaximumExportedPointsPerCurve =
new QSpinBox;
187 m_spinMaximumExportedPointsPerCurve->setWhatsThis (tr (
"Maximum Exported Points per Curve\n\n"
188 "This is the maximum number of points allowed in each exported curve. No points are "
189 "exported when this is exceeded. This limit prevents delays and overly large file sizes due "
190 "to curves that have too many points."));
191 connect (m_spinMaximumExportedPointsPerCurve, SIGNAL (valueChanged (
int)),
this, SLOT (slotMaximumExportedPointsPerCurve (
int)));
192 layout->addWidget (m_spinMaximumExportedPointsPerCurve, row++, 2);
194 QLabel *labelHighlightOpacity =
new QLabel (QString (
"%1:").arg (tr (
"Highlight opacity")));
195 layout->addWidget (labelHighlightOpacity, row, 1);
197 m_spinHighlightOpacity =
new QDoubleSpinBox;
198 m_spinHighlightOpacity->setRange (0, 1);
199 m_spinHighlightOpacity->setSingleStep (0.1);
200 m_spinHighlightOpacity->setWhatsThis (tr (
"Highlight Opacity\n\n"
201 "Opacity to be applied when the cursor is over a curve or axis point in Select mode. The change in "
202 "appearance shows when the point can be selected."));
203 connect (m_spinHighlightOpacity, SIGNAL (valueChanged (
double)),
this, SLOT (slotHighlightOpacity(
double)));
204 layout->addWidget (m_spinHighlightOpacity, row++, 2);
206 QLabel *labelRecent =
new QLabel (QString (
"%1:").arg (tr (
"Recent file list")));
207 layout->addWidget (labelRecent, row, 1);
209 m_btnRecentClear =
new QPushButton (tr (
"Clear"));
210 m_btnRecentClear->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
211 m_btnRecentClear->setWhatsThis (tr (
"Recent File List Clear\n\n"
212 "Clear the recent file list in the File menu."));
213 connect (m_btnRecentClear, SIGNAL (pressed ()), &
mainWindow(), SLOT (slotRecentFileClear ()));
214 connect (m_btnRecentClear, SIGNAL (pressed ()),
this, SLOT (slotRecentFileClear()));
215 layout->addWidget (m_btnRecentClear, row++, 2);
217 QLabel *labelTitleBarFormat =
new QLabel (QString (
"%1:").arg (tr (
"Include title bar path")));
218 layout->addWidget (labelTitleBarFormat, row, 1);
220 m_chkTitleBarFormat =
new QCheckBox;
221 m_chkTitleBarFormat->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
222 m_chkTitleBarFormat->setWhatsThis (tr (
"Title Bar Filename\n\n"
223 "Includes or excludes the path and file extension from the filename in the title bar."));
224 connect (m_chkTitleBarFormat, SIGNAL (toggled (
bool)),
this, SLOT (slotTitleBarFormat(
bool)));
225 layout->addWidget (m_chkTitleBarFormat, row++, 2);
227 QLabel *labelSmallDialogs =
new QLabel (QString (
"%1:").arg (tr (
"Allow small dialogs")));
228 layout->addWidget (labelSmallDialogs, row, 1);
230 m_chkSmallDialogs =
new QCheckBox;
231 m_chkSmallDialogs->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
232 m_chkSmallDialogs->setWhatsThis (tr (
"Allow Small Dialogs\n\n"
233 "Allows settings dialogs to be made very small so they fit on small computer screens."));
234 connect (m_chkSmallDialogs, SIGNAL (toggled (
bool)),
this, SLOT (slotSmallDialogs (
bool)));
235 layout->addWidget (m_chkSmallDialogs, row++, 2);
237 QLabel *labelDragDropExport =
new QLabel (QString (
"%1:").arg (tr (
"Allow drag and drop export")));
238 layout->addWidget (labelDragDropExport, row, 1);
240 m_chkDragDropExport =
new QCheckBox;
241 m_chkDragDropExport->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
242 m_chkDragDropExport->setWhatsThis (tr (
"Allow Drag and Drop Export\n\n"
243 "Allows drag and drop export from the Curve Fitting Window and Geometry Window tables.\n\n"
244 "When drag and drop is disabled, a rectangular set of table cells can be selected using click and "
245 "drag. When drag and drop is enabled, a rectangular set of table cells can be selected using Click "
246 "then Shift+Click, since click and drag starts the drag operation."));
247 connect (m_chkDragDropExport, SIGNAL (toggled (
bool)),
this, SLOT (slotDragDropExport (
bool)));
248 layout->addWidget (m_chkDragDropExport, row++, 2);
250 QLabel *labelImageReplaceRenamesDocument =
new QLabel (QString (
"%1:").arg (tr (
"Image replace renames document")));
251 layout->addWidget (labelImageReplaceRenamesDocument, row, 1);
253 m_chkImageReplaceRenamesDocument =
new QCheckBox;
254 m_chkImageReplaceRenamesDocument->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
255 m_chkImageReplaceRenamesDocument->setWhatsThis (tr (
"Image Replace Renames Document\n\n"
256 "When an image is imported to replace the current image, the document "
257 "will be renamed if this is true, otherwise the name will stay the same."));
258 connect (m_chkImageReplaceRenamesDocument, SIGNAL (toggled (
bool)),
this, SLOT (slotImageReplaceRenamesDocument (
bool)));
259 layout->addWidget (m_chkImageReplaceRenamesDocument, row++, 2);
261 QLabel *labelSignificantDigits =
new QLabel (QString (
"%1:").arg (tr (
"Significant digits")));
262 layout->addWidget (labelSignificantDigits, row, 1);
264 m_spinSignificantDigits =
new QSpinBox;
266 m_spinSignificantDigits->setWhatsThis (tr (
"Significant Digits\n\n"
267 "Number of digits of precision in floating point numbers. This value affects "
268 "calculations for curve fits, since intermediate results smaller than a "
269 "threshold T indicate that a polynomial curve with a specific order cannot be "
270 "fitted to the data. The threshold T is computed from the maximum matrix "
271 "element M and significant digits S as T = M / 10^S."));
272 connect (m_spinSignificantDigits, SIGNAL (valueChanged (
int)),
this, SLOT (slotSignificantDigits (
int)));
273 layout->addWidget (m_spinSignificantDigits, row++, 2);
275 QLabel *labelGuidelineColor =
new QLabel (QString (
"%1:").arg (tr (
"Guideline color")));
276 layout->addWidget (labelGuidelineColor, row, 1);
278 m_cmbGuidelineColor =
new QComboBox;
279 m_cmbGuidelineColor->setWhatsThis (tr (
"Guidelines Color\n\n"
280 "Set the color of the guidelines that can be dragged from the edges of the scene, and used "
283 connect (m_cmbGuidelineColor, SIGNAL (activated (
const QString &)),
this, SLOT (slotGuidelineColor (
const QString &)));
284 layout->addWidget (m_cmbGuidelineColor, row++, 2);
296 QWidget *subPanel =
new QWidget ();
297 QGridLayout *layout =
new QGridLayout (subPanel);
298 subPanel->setLayout (layout);
300 layout->setColumnStretch(0, 1);
301 layout->setColumnStretch(1, 0);
302 layout->setColumnStretch(2, 0);
303 layout->setColumnStretch(3, 1);
306 createControls (layout, row);
311QStringList DlgSettingsMainWindow::gatherQmFilenames ()
const
316 QStringList filenames = translationPath.entryList (QStringList (
"engauge_*.qm"));
345 delete m_modelMainWindowBefore;
346 delete m_modelMainWindowAfter;
353 int index = m_cmbZoomFactor->findData (m_modelMainWindowAfter->zoomFactorInitial());
354 m_cmbZoomFactor->setCurrentIndex (index);
355 index = m_cmbZoomControl->findData (m_modelMainWindowAfter->zoomControl());
356 m_cmbZoomControl->setCurrentIndex (index);
358 index = m_cmbLocale->findText (locLabel);
362 index = m_cmbLocale->findText (locLabel);
364 m_cmbLocale->setCurrentIndex(index);
365 index = m_cmbImportCropping->findData (m_modelMainWindowAfter->importCropping());
366 m_cmbImportCropping->setCurrentIndex (index);
369 index = m_cmbPdfResolution->findData (m_modelMainWindowAfter->pdfResolution());
370 m_cmbPdfResolution->setCurrentIndex(index);
372 m_spinMaximumGridLines->setValue (m_modelMainWindowAfter->maximumGridLines());
373 m_spinHighlightOpacity->setValue (m_modelMainWindowAfter->highlightOpacity());
374 m_chkSmallDialogs->setChecked (m_modelMainWindowAfter->smallDialogs());
375 m_chkDragDropExport->setChecked (m_modelMainWindowAfter->dragDropExport());
376 m_spinSignificantDigits->setValue (m_modelMainWindowAfter->significantDigits ());
377 m_chkImageReplaceRenamesDocument->setChecked (m_modelMainWindowAfter->imageReplaceRenamesDocument());
378 m_spinMaximumExportedPointsPerCurve->setValue (m_modelMainWindowAfter->maximumExportedPointsPerCurve());
380 int indexColor = m_cmbGuidelineColor->findData(QVariant(m_modelMainWindowAfter->guidelineColor()));
382 m_cmbGuidelineColor->setCurrentIndex(indexColor);
392void DlgSettingsMainWindow::slotDragDropExport (
bool)
400void DlgSettingsMainWindow::slotGuidelineColor (QString
const &)
404 m_modelMainWindowAfter->setGuidelineColor(
static_cast<ColorPalette> (m_cmbGuidelineColor->currentData().toInt()));
408void DlgSettingsMainWindow::slotHighlightOpacity(
double)
412 m_modelMainWindowAfter->setHighlightOpacity (m_spinHighlightOpacity->value());
416void DlgSettingsMainWindow::slotImageReplaceRenamesDocument (
bool)
420 m_modelMainWindowAfter->setImageReplaceRenamesDocument (m_chkImageReplaceRenamesDocument->isChecked());
424void DlgSettingsMainWindow::slotImportCropping (
int index)
428 m_modelMainWindowAfter->setImportCropping (
static_cast<ImportCropping> (m_cmbImportCropping->itemData (index).toInt ()));
432void DlgSettingsMainWindow::slotLocale (
int index)
436 QLocale locale = m_cmbLocale->itemData (index).toLocale();
438 m_modelMainWindowAfter->setLocale (locale);
442void DlgSettingsMainWindow::slotMaximumExportedPointsPerCurve (
int limit)
446 m_modelMainWindowAfter->setMaximumExportedPointsPerCurve (limit);
450void DlgSettingsMainWindow::slotMaximumGridLines (
int limit)
454 m_modelMainWindowAfter->setMaximumGridLines (limit);
458void DlgSettingsMainWindow::slotPdfResolution(
const QString)
463 m_modelMainWindowAfter->setPdfResolution(m_cmbPdfResolution->currentData().toInt());
468void DlgSettingsMainWindow::slotRecentFileClear()
476void DlgSettingsMainWindow::slotSignificantDigits(
int)
480 m_modelMainWindowAfter->setSignificantDigits(m_spinSignificantDigits->value ());
484void DlgSettingsMainWindow::slotSmallDialogs (
bool)
488 m_modelMainWindowAfter->setSmallDialogs (m_chkSmallDialogs->isChecked());
492void DlgSettingsMainWindow::slotTitleBarFormat(
bool)
496 m_modelMainWindowAfter->setMainTitleBarFormat(m_chkTitleBarFormat->isChecked() ?
502void DlgSettingsMainWindow::slotZoomControl(
const QString)
506 m_modelMainWindowAfter->setZoomControl (
static_cast<ZoomControl> (m_cmbZoomControl->currentData().toInt()));
510void DlgSettingsMainWindow::slotZoomFactor(
const QString)
514 m_modelMainWindowAfter->setZoomFactorInitial(
static_cast<ZoomFactorInitial> (m_cmbZoomFactor->currentData().toInt()));
518void DlgSettingsMainWindow::updateControls ()
const int MAX_GRID_LINES_MIN
const int MAX_MAX_EXPORTED_POINTS_PER_CURVE
const int MINIMUM_DIALOG_WIDTH_MAIN_WINDOW
const int MIN_MAX_EXPORTED_POINTS_PER_CURVE
const int MAX_GRID_LINES_MAX
const int STEP_MAX_EXPORTED_POINTS_PER_CURVE
const int MAX_SIGNIFICANT_DIGITS
const int MIN_SIGNIFICANT_DIGITS
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
@ IMPORT_CROPPING_MULTIPAGE_PDFS
log4cpp::Category * mainCat
@ MAIN_TITLE_BAR_FORMAT_NO_PATH
@ MAIN_TITLE_BAR_FORMAT_PATH
Filename without path.
QString QLocaleToString(const QLocale &locale)
@ ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS
@ ZOOM_CONTROL_MENU_WHEEL
@ ZOOM_CONTROL_MENU_PLUSMINUS
const QString * LABEL_ZOOM_1_TO_4
const QString * LABEL_ZOOM_16_TO_1
const QString * LABEL_ZOOM_1_TO_2
const QString * LABEL_ZOOM_1_TO_8
const QString * LABEL_ZOOM_1_TO_1
const QString * LABEL_ZOOM_2_TO_1
const QString * LABEL_ZOOM_8_TO_1
const QString * LABEL_ZOOM_4_TO_1
const QString * LABEL_ZOOM_PREVIOUS
const QString * LABEL_ZOOM_FILL
const QString * LABEL_ZOOM_1_TO_16
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void populateColorComboWithoutTransparent(QComboBox &combo)
Add colors in color palette to combobox, without transparent entry at end.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
MainWindow & mainWindow()
Get method for MainWindow.
void loadMainWindowModel(CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow)
Replaced load method since the main window settings are independent of document, unlike other DlgSett...
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
DlgSettingsMainWindow(MainWindow &mainWindow)
Single constructor.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void handleOk()
Process slotOk.
virtual ~DlgSettingsMainWindow()
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
static QString importCroppingToString(ImportCropping importCropping)
Option as string for display to user.
Model for DlgSettingsMainWindow.
void setDragDropExport(bool dragDropExport)
Set method for drag and drop export.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
Update with new main window properties.
static QString qmDirectory()
Platform dependent directory containing qm translation files.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_ERROR_S(logger)