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

Dialog for editing Segments settings, for DigitizeStateSegment. More...

#include <DlgSettingsSegments.h>

Inheritance diagram for DlgSettingsSegments:
Inheritance graph
Collaboration diagram for DlgSettingsSegments:
Collaboration graph

Public Member Functions

 DlgSettingsSegments (MainWindow &mainWindow)
 Single constructor.
 
virtual ~DlgSettingsSegments ()
 
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.
 
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 Segments settings, for DigitizeStateSegment.

Definition at line 27 of file DlgSettingsSegments.h.

Constructor & Destructor Documentation

◆ DlgSettingsSegments()

DlgSettingsSegments::DlgSettingsSegments ( MainWindow & mainWindow)

Single constructor.

Definition at line 39 of file DlgSettingsSegments.cpp.

39 :
40 DlgSettingsAbstractBase (tr ("Segment Fill"),
41 "DlgSettingsSegments",
43 m_scenePreview (nullptr),
44 m_viewPreview (nullptr),
45 m_modelSegmentsBefore (nullptr),
46 m_modelSegmentsAfter (nullptr),
47 m_loading (false)
48{
49 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::DlgSettingsSegments";
50
51 QWidget *subPanel = createSubPanel ();
52 finishPanel (subPanel);
53}
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

◆ ~DlgSettingsSegments()

DlgSettingsSegments::~DlgSettingsSegments ( )
virtual

Definition at line 55 of file DlgSettingsSegments.cpp.

56{
57 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::~DlgSettingsSegments";
58}

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsSegments::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 133 of file DlgSettingsSegments.cpp.

134{
135}

◆ createSubPanel()

QWidget * DlgSettingsSegments::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 216 of file DlgSettingsSegments.cpp.

217{
218 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::createSubPanel";
219
220 QWidget *subPanel = new QWidget ();
221 QGridLayout *layout = new QGridLayout (subPanel);
222 subPanel->setLayout (layout);
223
224 layout->setColumnStretch (0, 1); // Empty first column
225 layout->setColumnStretch (1, 0); // Labels
226 layout->setColumnStretch (2, 0); // User controls
227 layout->setColumnStretch (3, 1); // Empty last column
228
229 int row = 0;
230 createControls(layout, row);
231 createPreview (layout, row);
232 QPixmap pixmap = QPixmap::fromImage (createPreviewImage());
233 m_scenePreview->addPixmap (pixmap);
234
235 return subPanel;
236}

◆ handleOk()

void DlgSettingsSegments::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 238 of file DlgSettingsSegments.cpp.

239{
240 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::handleOk";
241
242 CmdSettingsSegments *cmd = new CmdSettingsSegments (mainWindow (),
243 cmdMediator ().document(),
244 *m_modelSegmentsBefore,
245 *m_modelSegmentsAfter);
246 cmdMediator ().push (cmd);
247
248 hide ();
249}
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ load()

void DlgSettingsSegments::load ( CmdMediator & cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 251 of file DlgSettingsSegments.cpp.

252{
253 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::load";
254
255 // Loading starts here
256 m_loading = true;
257
259
260 // Flush old data
261 delete m_modelSegmentsBefore;
262 delete m_modelSegmentsAfter;
263
264 // Save new data
265 m_modelSegmentsBefore = new DocumentModelSegments (cmdMediator.document());
266 m_modelSegmentsAfter = new DocumentModelSegments (cmdMediator.document());
267
268 // Sanity checks. Incoming defaults must be acceptable to the local limits
270 ENGAUGE_ASSERT (MIN_LENGTH_MAX >= m_modelSegmentsAfter->minLength ());
272 ENGAUGE_ASSERT (POINT_SEPARATION_MAX >= m_modelSegmentsAfter->pointSeparation());
273
274 // Populate controls
275 m_spinPointSeparation->setValue (qFloor (m_modelSegmentsAfter->pointSeparation()));
276 m_spinMinLength->setValue (qFloor (m_modelSegmentsAfter->minLength()));
277 m_chkFillCorners->setChecked (m_modelSegmentsAfter->fillCorners ());
278 m_spinLineWidth->setValue (qFloor (m_modelSegmentsAfter->lineWidth()));
279
280 int indexLineColor = m_cmbLineColor->findData(QVariant (m_modelSegmentsAfter->lineColor()));
281 ENGAUGE_ASSERT (indexLineColor >= 0);
282 m_cmbLineColor->setCurrentIndex(indexLineColor);
283
284 // Loading finishes here
285 m_loading = false;
286
287 updateControls();
288 enableOk (false); // Disable Ok button since there not yet any changes
289 updatePreview();
290}
const int MIN_LENGTH_MAX
const int POINT_SEPARATION_MIN
const int POINT_SEPARATION_MAX
const int MIN_LENGTH_MIN
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void enableOk(bool enable)
Let leaf subclass control the Ok button.

◆ setSmallDialogs()

void DlgSettingsSegments::setSmallDialogs ( bool smallDialogs)
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 292 of file DlgSettingsSegments.cpp.

293{
294 if (!smallDialogs) {
295 setMinimumHeight (MINIMUM_HEIGHT);
296 }
297}
const int MINIMUM_HEIGHT

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