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 addPixmap (QGraphicsScene &scene, const QPixmap &pixmap)
 Adds pixmap to the scene.
void createWhatsThis (QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
 Create a WhatsThis button in a grid layout.
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.

This uses a timer for the inactive opacity previewing so changing that settings results in preview window temporarily showing the inactive opacity color, then the regular color returns

Definition at line 31 of file DlgSettingsSegments.h.

Constructor & Destructor Documentation

◆ DlgSettingsSegments()

DlgSettingsSegments::DlgSettingsSegments ( MainWindow & mainWindow)

Single constructor.

Definition at line 40 of file DlgSettingsSegments.cpp.

40 :
41 DlgSettingsAbstractBase (tr ("Segment Fill"),
42 "DlgSettingsSegments",
44 m_scenePreviewActive (nullptr),
45 m_scenePreviewInactive (nullptr),
46 m_viewPreviewActive (nullptr),
47 m_viewPreviewInactive (nullptr),
48 m_modelSegmentsBefore (nullptr),
49 m_modelSegmentsAfter (nullptr),
50 m_loading (false)
51{
52 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::DlgSettingsSegments";
53
54 QWidget *subPanel = createSubPanel ();
55 finishPanel (subPanel);
56}
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 58 of file DlgSettingsSegments.cpp.

59{
60 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::~DlgSettingsSegments";
61}

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsSegments::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 171 of file DlgSettingsSegments.cpp.

172{
173}

◆ createSubPanel()

QWidget * DlgSettingsSegments::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 269 of file DlgSettingsSegments.cpp.

270{
271 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::createSubPanel";
272
273 QWidget *subPanel = new QWidget ();
274 QGridLayout *layout = new QGridLayout (subPanel);
275 subPanel->setLayout (layout);
276
277 layout->setColumnStretch (0, 1); // Empty first column
278 layout->setColumnStretch (1, 0); // Labels
279 layout->setColumnStretch (2, 0); // User controls
280 layout->setColumnStretch (3, 1); // Empty last column
281
282 int row = 0;
283 createWhatsThis (layout,
284 m_btnWhatsThis,
285 row++,
286 3);
287 createControls(layout, row);
288 createPreview (layout, row);
289 QPixmap pixmap = QPixmap::fromImage (createPreviewImage());
290 addPixmap (*m_scenePreviewActive,
291 pixmap);
292 pixmap = QPixmap::fromImage (createPreviewImage());
293 addPixmap (*m_scenePreviewInactive,
294 pixmap);
295
296 return subPanel;
297}
void createWhatsThis(QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
Create a WhatsThis button in a grid layout.
void addPixmap(QGraphicsScene &scene, const QPixmap &pixmap)
Adds pixmap to the scene.

◆ handleOk()

void DlgSettingsSegments::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 299 of file DlgSettingsSegments.cpp.

300{
301 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::handleOk";
302
303 CmdSettingsSegments *cmd = new CmdSettingsSegments (mainWindow (),
304 cmdMediator ().document(),
305 *m_modelSegmentsBefore,
306 *m_modelSegmentsAfter);
307 cmdMediator ().push (cmd);
308
309 hide ();
310}
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 312 of file DlgSettingsSegments.cpp.

313{
314 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::load";
315
316 // Loading starts here
317 m_loading = true;
318
320
321 // Flush old data
322 delete m_modelSegmentsBefore;
323 delete m_modelSegmentsAfter;
324
325 // Save new data
326 m_modelSegmentsBefore = new DocumentModelSegments (cmdMediator.document());
327 m_modelSegmentsAfter = new DocumentModelSegments (cmdMediator.document());
328
329 // Sanity checks. Incoming defaults must be acceptable to the local limits
331 ENGAUGE_ASSERT (MIN_LENGTH_MAX >= m_modelSegmentsAfter->minLength ());
333 ENGAUGE_ASSERT (POINT_SEPARATION_MAX >= m_modelSegmentsAfter->pointSeparation());
334
335 // Populate controls
336 m_spinPointSeparation->setValue (qFloor (m_modelSegmentsAfter->pointSeparation()));
337 m_spinMinLength->setValue (qFloor (m_modelSegmentsAfter->minLength()));
338 m_chkFillCorners->setChecked (m_modelSegmentsAfter->fillCorners ());
339 m_spinLineWidthActive->setValue (qFloor (m_modelSegmentsAfter->lineWidthActive()));
340 m_spinLineWidthInactive->setValue (qFloor (m_modelSegmentsAfter->lineWidthInactive()));
341
342 int indexLineColor = m_cmbLineColor->findData(QVariant (m_modelSegmentsAfter->lineColor()));
343 ENGAUGE_ASSERT (indexLineColor >= 0);
344 m_cmbLineColor->setCurrentIndex(indexLineColor);
345
346 int indexInactiveOpacity = m_cmbInactiveOpacity->findData (QVariant (m_modelSegmentsAfter->inactiveOpacity()));
347 ENGAUGE_ASSERT (indexInactiveOpacity >= 0);
348 m_cmbInactiveOpacity->setCurrentIndex (indexInactiveOpacity);
349
350 // Loading finishes here
351 m_loading = false;
352
353 updateControls();
354 enableOk (false); // Disable Ok button since there not yet any changes
355 updatePreview();
356}
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.
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 358 of file DlgSettingsSegments.cpp.

359{
360 if (!smallDialogs) {
361 setMinimumHeight (MINIMUM_HEIGHT);
362 }
363}
const int MINIMUM_HEIGHT

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