Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgSettingsMainWindow Class Reference

Dialog for editing main window settings, which are entirely independent of all documents. More...

#include <DlgSettingsMainWindow.h>

Inheritance diagram for DlgSettingsMainWindow:
Inheritance graph
Collaboration diagram for DlgSettingsMainWindow:
Collaboration graph

Public Member Functions

 DlgSettingsMainWindow (MainWindow &mainWindow)
 Single constructor.
virtual ~DlgSettingsMainWindow ()
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.
virtual void load (CmdMediator &cmdMediator)
 Load settings from Document.
void loadMainWindowModel (CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow)
 Replaced load method since the main window settings are independent of document, unlike other DlgSettings* classes.
virtual void setSmallDialogs (bool smallDialogs)
 If false then dialogs have a minimum size so all controls are visible.
Public Member Functions inherited from DlgSettingsAbstractBase
 DlgSettingsAbstractBase (const QString &title, const QString &dialogName, MainWindow &mainWindow)
 Single constructor.
virtual ~DlgSettingsAbstractBase ()

Protected Member Functions

virtual void handleOk ()
 Process slotOk.
Protected Member Functions inherited from DlgSettingsAbstractBase
CmdMediatorcmdMediator ()
 Provide access to Document information wrapped inside CmdMediator.
void enableOk (bool enable)
 Let leaf subclass control the Ok button.
void finishPanel (QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
 Add Ok and Cancel buttons to subpanel to get the whole dialog.
MainWindowmainWindow ()
 Get method for MainWindow.
const MainWindowmainWindow () const
 Const get method for MainWindow.
void populateColorComboWithoutTransparent (QComboBox &combo)
 Add colors in color palette to combobox, without transparent entry at end.
void populateColorComboWithTransparent (QComboBox &combo)
 Add colors in color palette to combobox, with transparent entry at end.
void setCmdMediator (CmdMediator &cmdMediator)
 Store CmdMediator for easy access by the leaf class.
void setDisableOkAtStartup (bool disableOkAtStartup)
 Override the default Ok button behavior applied in showEvent.

Additional Inherited Members

Static Protected Attributes inherited from DlgSettingsAbstractBase
static int MINIMUM_DIALOG_WIDTH = 380
 Dialog layout constant that guarantees every widget has sufficient room. Can be increased by finishPanel.
static int MINIMUM_PREVIEW_HEIGHT = 100
 Dialog layout constant that guarantees preview has sufficent room.

Detailed Description

Dialog for editing main window settings, which are entirely independent of all documents.

Definition at line 24 of file DlgSettingsMainWindow.h.

Constructor & Destructor Documentation

◆ DlgSettingsMainWindow()

DlgSettingsMainWindow::DlgSettingsMainWindow ( MainWindow & mainWindow)

Single constructor.

Definition at line 48 of file DlgSettingsMainWindow.cpp.

48 :
49 DlgSettingsAbstractBase (tr ("Main Window"),
50 "DlgSettingsMainWindow",
52 m_modelMainWindowBefore (nullptr),
53 m_modelMainWindowAfter (nullptr)
54{
55 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsMainWindow::DlgSettingsMainWindow";
56
57 QWidget *subPanel = createSubPanel ();
58 finishPanel (subPanel,
60}
const int MINIMUM_DIALOG_WIDTH_MAIN_WINDOW
log4cpp::Category * mainCat
Definition Logger.cpp:14
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
MainWindow & mainWindow()
Get method for MainWindow.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~DlgSettingsMainWindow()

DlgSettingsMainWindow::~DlgSettingsMainWindow ( )
virtual

Definition at line 62 of file DlgSettingsMainWindow.cpp.

63{
64 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsMainWindow::~DlgSettingsMainWindow";
65}

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsMainWindow::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 287 of file DlgSettingsMainWindow.cpp.

288{
289 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsMainWindow::createOptionalSaveDefault";
290}

◆ createSubPanel()

QWidget * DlgSettingsMainWindow::createSubPanel ( )
virtual

Create dialog-specific panel to which base class will add Ok and Cancel buttons.

Implements DlgSettingsAbstractBase.

Definition at line 292 of file DlgSettingsMainWindow.cpp.

293{
294 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsMainWindow::createSubPanel";
295
296 QWidget *subPanel = new QWidget ();
297 QGridLayout *layout = new QGridLayout (subPanel);
298 subPanel->setLayout (layout);
299
300 layout->setColumnStretch(0, 1); // Empty first column
301 layout->setColumnStretch(1, 0); // Labels
302 layout->setColumnStretch(2, 0); // Values
303 layout->setColumnStretch(3, 1); // Empty first column
304
305 int row = 0;
306 createControls (layout, row);
307
308 return subPanel;
309}

◆ handleOk()

void DlgSettingsMainWindow::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 321 of file DlgSettingsMainWindow.cpp.

322{
323 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsMainWindow::handleOk";
324
325 mainWindow().updateSettingsMainWindow (*m_modelMainWindowAfter);
326
327 hide ();
328}
void updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
Update with new main window properties.

◆ load()

void DlgSettingsMainWindow::load ( CmdMediator & cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 330 of file DlgSettingsMainWindow.cpp.

331{
332 LOG4CPP_ERROR_S ((*mainCat)) << "DlgSettingsMainWindow::load";
333
334 ENGAUGE_ASSERT (false);
335}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
#define LOG4CPP_ERROR_S(logger)
Definition convenience.h:12

◆ loadMainWindowModel()

void DlgSettingsMainWindow::loadMainWindowModel ( CmdMediator & cmdMediator,
const MainWindowModel & modelMainWindow )

Replaced load method since the main window settings are independent of document, unlike other DlgSettings* classes.

Definition at line 337 of file DlgSettingsMainWindow.cpp.

339{
340 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsMainWindow::loadMainWindowModel";
341
343
344 // Flush old data
345 delete m_modelMainWindowBefore;
346 delete m_modelMainWindowAfter;
347
348 // Save new data
349 m_modelMainWindowBefore = new MainWindowModel (modelMainWindow);
350 m_modelMainWindowAfter = new MainWindowModel (modelMainWindow);
351
352 // Populate controls
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);
357 QString locLabel = QLocaleToString (m_modelMainWindowAfter->locale());
358 index = m_cmbLocale->findText (locLabel);
359 if (index < 0) {
360 // Somehow an invalid locale is selected. Fix it by setting to default
361 locLabel = QLocaleToString (QLocale::system().name());
362 index = m_cmbLocale->findText (locLabel);
363 }
364 m_cmbLocale->setCurrentIndex(index);
365 index = m_cmbImportCropping->findData (m_modelMainWindowAfter->importCropping());
366 m_cmbImportCropping->setCurrentIndex (index);
367 m_chkTitleBarFormat->setChecked (m_modelMainWindowAfter->mainTitleBarFormat() == MAIN_TITLE_BAR_FORMAT_PATH);
368#ifdef ENGAUGE_PDF
369 index = m_cmbPdfResolution->findData (m_modelMainWindowAfter->pdfResolution());
370 m_cmbPdfResolution->setCurrentIndex(index);
371#endif
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());
379
380 int indexColor = m_cmbGuidelineColor->findData(QVariant(m_modelMainWindowAfter->guidelineColor()));
381 ENGAUGE_ASSERT (indexColor >= 0);
382 m_cmbGuidelineColor->setCurrentIndex(indexColor);
383
384 updateControls ();
385 enableOk (false); // Disable Ok button since there not yet any changes
386}
@ MAIN_TITLE_BAR_FORMAT_PATH
Filename without path.
QString QLocaleToString(const QLocale &locale)
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void enableOk(bool enable)
Let leaf subclass control the Ok button.

◆ setSmallDialogs()

void DlgSettingsMainWindow::setSmallDialogs ( bool smallDialogs)
virtual

If false then dialogs have a minimum size so all controls are visible.

Implements DlgSettingsAbstractBase.

Definition at line 388 of file DlgSettingsMainWindow.cpp.

389{
390}

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