Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
DlgSettingsAbstractBase Class Referenceabstract

Abstract base class for all Settings dialogs. More...

#include <DlgSettingsAbstractBase.h>

Inheritance diagram for DlgSettingsAbstractBase:
Inheritance graph
Collaboration diagram for DlgSettingsAbstractBase:
Collaboration graph

Public Member Functions

 DlgSettingsAbstractBase (const QString &title, const QString &dialogName, MainWindow &mainWindow)
 Single constructor.
 
virtual ~DlgSettingsAbstractBase ()
 

Protected Member Functions

CmdMediatorcmdMediator ()
 Provide access to Document information wrapped inside CmdMediator.
 
virtual void createOptionalSaveDefault (QHBoxLayout *layout)=0
 Let subclass define an optional Save As Default button.
 
virtual QWidgetcreateSubPanel ()=0
 Create dialog-specific panel to which base class will add Ok and Cancel buttons.
 
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.
 
virtual void handleOk ()=0
 Process slotOk.
 
virtual void load (CmdMediator &cmdMediator)=0
 Load settings from Document.
 
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.
 
virtual void setSmallDialogs (bool smallDialogs)=0
 If false then dialogs have a minimum size so all controls are visible.
 

Static Protected Attributes

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

Abstract base class for all Settings dialogs.

Definition at line 20 of file DlgSettingsAbstractBase.h.

Constructor & Destructor Documentation

◆ DlgSettingsAbstractBase()

DlgSettingsAbstractBase::DlgSettingsAbstractBase ( const QString & title,
const QString & dialogName,
MainWindow & mainWindow )

Single constructor.

Definition at line 24 of file DlgSettingsAbstractBase.cpp.

26 :
27 QDialog (&mainWindow),
28 m_mainWindow (mainWindow),
29 m_cmdMediator (nullptr),
30 m_dialogName (dialogName),
31 m_disableOkAtStartup (true)
32{
33 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsAbstractBase::DlgSettingsAbstractBase"
34 << " name=" << m_dialogName.toLatin1().data();
35
37 setModal (true);
38}
const int INNER_RADIUS_MIN
log4cpp::Category * mainCat
Definition Logger.cpp:14
MainWindow & mainWindow()
Get method for MainWindow.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~DlgSettingsAbstractBase()

DlgSettingsAbstractBase::~DlgSettingsAbstractBase ( )
virtual

Definition at line 40 of file DlgSettingsAbstractBase.cpp.

41{
42 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsAbstractBase::~DlgSettingsAbstractBase"
43 << " name=" << m_dialogName.toLatin1().data();
44}

Member Function Documentation

◆ cmdMediator()

CmdMediator & DlgSettingsAbstractBase::cmdMediator ( )
protected

Provide access to Document information wrapped inside CmdMediator.

Definition at line 46 of file DlgSettingsAbstractBase.cpp.

47{
48 ENGAUGE_CHECK_PTR (m_cmdMediator);
49
50 return *m_cmdMediator;
51}
#define ENGAUGE_CHECK_PTR(ptr)
#endif

◆ createOptionalSaveDefault()

virtual void DlgSettingsAbstractBase::createOptionalSaveDefault ( QHBoxLayout * layout)
protectedpure virtual

◆ createSubPanel()

virtual QWidget * DlgSettingsAbstractBase::createSubPanel ( )
protectedpure virtual

◆ enableOk()

void DlgSettingsAbstractBase::enableOk ( bool enable)
protected

Let leaf subclass control the Ok button.

This method is separate from the subclasses' updateControls, rather than part of that method since updateControls is not aware of when it is called at startup - at which point the ok button should ALWAYS be disabled since there are not yet any changes. In other words, we call this method at startup to override the ok button state that was just set by updateControls

Note - if this method is called with a constant value of true from updateControls, one of two cases applies: 1) There are no constraints to worry about (like a required text field cannot be empty) 2) There are constraints, but they are already handled by validators and/or other constraint logic

Definition at line 53 of file DlgSettingsAbstractBase.cpp.

54{
55 m_btnOk->setEnabled (enable);
56}

◆ finishPanel()

void DlgSettingsAbstractBase::finishPanel ( QWidget * subPanel,
int minimumWidth = MINIMUM_DIALOG_WIDTH,
int minimumHeightOrZero = 0 )
protected

Add Ok and Cancel buttons to subpanel to get the whole dialog.

Definition at line 58 of file DlgSettingsAbstractBase.cpp.

61{
62 const int STRETCH_OFF = 0, STRETCH_ON = 1;
63
64 m_scroll = new QScrollArea (this);
65 m_scroll->setStyleSheet ("QScrollArea { border: 0; margin: 0; padding: 0;}"); // Need QScrollArea or interior frames are affected
66 m_scroll->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
67 m_scroll->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
68 m_scroll->setSizePolicy (QSizePolicy::Minimum,
69 QSizePolicy::Minimum);
70 m_scroll->setMinimumWidth (minimumWidth);
71
72 QWidget *viewport = new QWidget (this);
73 m_scroll->setWidget (viewport);
74 m_scroll->setWidgetResizable (true);
75
77 scrollLayout->addWidget (m_scroll);
78 setLayout (scrollLayout);
79
81 viewport->setLayout (panelLayout);
82
83 panelLayout->addWidget (subPanel);
84 panelLayout->setStretch (panelLayout->count () - 1, STRETCH_ON);
85
86 QWidget *panelButtons = new QWidget (this);
88
90
92
95 buttonLayout->addWidget (widgetRightSide);
96
97 QSpacerItem *spacerExpanding = new QSpacerItem (40, 5, QSizePolicy::Expanding, QSizePolicy::Expanding);
99
100 m_btnOk = new QPushButton (tr ("Ok"));
101 m_btnOk->setEnabled (false); // Nothing to save initially
102 layoutRightSide->addWidget (m_btnOk, 0, Qt::AlignRight);
103 connect (m_btnOk, SIGNAL (released ()), this, SLOT (slotOk ()));
104
105 QSpacerItem *spacerFixed = new QSpacerItem (40, 5, QSizePolicy::Fixed, QSizePolicy::Fixed);
106 layoutRightSide->addItem (spacerFixed);
107
108 m_btnCancel = new QPushButton (tr ("Cancel"));
109 layoutRightSide->addWidget (m_btnCancel, 0, Qt::AlignRight);
110 connect (m_btnCancel, SIGNAL (released ()), this, SLOT (slotCancel ()));
111
112 panelLayout->addWidget (panelButtons, STRETCH_ON);
113 panelLayout->setStretch (panelLayout->count () - 1, STRETCH_OFF);
114
115 setSizePolicy (QSizePolicy::Minimum,
116 QSizePolicy::Minimum);
117
118 if (minimumHeightOrZero > 0) {
119 m_scroll->setMinimumHeight (minimumHeightOrZero);
120 }
121}
virtual void createOptionalSaveDefault(QHBoxLayout *layout)=0
Let subclass define an optional Save As Default button.

◆ handleOk()

virtual void DlgSettingsAbstractBase::handleOk ( )
protectedpure virtual

◆ load()

virtual void DlgSettingsAbstractBase::load ( CmdMediator & cmdMediator)
protectedpure virtual

◆ mainWindow() [1/2]

MainWindow & DlgSettingsAbstractBase::mainWindow ( )
protected

Get method for MainWindow.

Definition at line 123 of file DlgSettingsAbstractBase.cpp.

124{
125 return m_mainWindow;
126}

◆ mainWindow() [2/2]

const MainWindow & DlgSettingsAbstractBase::mainWindow ( ) const
protected

Const get method for MainWindow.

Definition at line 128 of file DlgSettingsAbstractBase.cpp.

129{
130 return m_mainWindow;
131}

◆ populateColorComboWithoutTransparent()

void DlgSettingsAbstractBase::populateColorComboWithoutTransparent ( QComboBox & combo)
protected

Add colors in color palette to combobox, without transparent entry at end.

Definition at line 133 of file DlgSettingsAbstractBase.cpp.

◆ populateColorComboWithTransparent()

void DlgSettingsAbstractBase::populateColorComboWithTransparent ( QComboBox & combo)
protected

Add colors in color palette to combobox, with transparent entry at end.

Definition at line 153 of file DlgSettingsAbstractBase.cpp.

154{
156 combo.addItem ("Transparent", QVariant (COLOR_PALETTE_TRANSPARENT));
157}
@ COLOR_PALETTE_TRANSPARENT
void populateColorComboWithoutTransparent(QComboBox &combo)
Add colors in color palette to combobox, without transparent entry at end.

◆ setCmdMediator()

void DlgSettingsAbstractBase::setCmdMediator ( CmdMediator & cmdMediator)
protected

Store CmdMediator for easy access by the leaf class.

Definition at line 166 of file DlgSettingsAbstractBase.cpp.

167{
168 m_cmdMediator = &cmdMediator;
169}
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ setDisableOkAtStartup()

void DlgSettingsAbstractBase::setDisableOkAtStartup ( bool disableOkAtStartup)
protected

Override the default Ok button behavior applied in showEvent.

Definition at line 171 of file DlgSettingsAbstractBase.cpp.

172{
173 m_disableOkAtStartup = disableOkAtStartup;
174}

◆ setSmallDialogs()

virtual void DlgSettingsAbstractBase::setSmallDialogs ( bool smallDialogs)
protectedpure virtual

Member Data Documentation

◆ MINIMUM_DIALOG_WIDTH

int DlgSettingsAbstractBase::MINIMUM_DIALOG_WIDTH = 380
staticprotected

Dialog layout constant that guarantees every widget has sufficient room. Can be increased by finishPanel.

Definition at line 63 of file DlgSettingsAbstractBase.h.

◆ MINIMUM_PREVIEW_HEIGHT

int DlgSettingsAbstractBase::MINIMUM_PREVIEW_HEIGHT = 100
staticprotected

Dialog layout constant that guarantees preview has sufficent room.

Definition at line 66 of file DlgSettingsAbstractBase.h.


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