Engauge Digitizer 2
Loading...
Searching...
No Matches
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.
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.
virtual void createOptionalSaveDefault (QHBoxLayout *layout)=0
 Let subclass define an optional Save As Default button.
virtual QWidget * createSubPanel ()=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 24 of file DlgSettingsAbstractBase.h.

Constructor & Destructor Documentation

◆ DlgSettingsAbstractBase()

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

Single constructor.

Definition at line 27 of file DlgSettingsAbstractBase.cpp.

29 :
30 QDialog (&mainWindow),
31 m_mainWindow (mainWindow),
32 m_cmdMediator (nullptr),
33 m_dialogName (dialogName),
34 m_disableOkAtStartup (true)
35{
36 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsAbstractBase::DlgSettingsAbstractBase"
37 << " name=" << m_dialogName.toLatin1().data();
38
39 setWindowTitle (title);
40 setModal (true);
41
42 // Linux Mint seems to not show help button
43 //setWindowFlag (Qt::Window, true);
44 //setWindowFlag (Qt::WindowContextHelpButtonHint, true);
45 //setWindowFlag (Qt::WindowCloseButtonHint, true);
46 //setWindowFlag (Qt::WindowMinimizeButtonHint, false);
47 //setWindowFlag (Qt::WindowMaximizeButtonHint, false);
48 setWindowFlags (Qt::Window | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint);
49}
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 51 of file DlgSettingsAbstractBase.cpp.

52{
53 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsAbstractBase::~DlgSettingsAbstractBase"
54 << " name=" << m_dialogName.toLatin1().data();
55}

Member Function Documentation

◆ addPixmap()

void DlgSettingsAbstractBase::addPixmap ( QGraphicsScene & scene,
const QPixmap & pixmap )
protected

Adds pixmap to the scene.

The scene is resized so when a larger image is followed by a smaller image, none of the old image appears around the smaller new image

Definition at line 57 of file DlgSettingsAbstractBase.cpp.

59{
60 scene.addPixmap (pixmap);
61 scene.setSceneRect (0,
62 0,
63 pixmap.width(),
64 pixmap.height());
65}

◆ cmdMediator()

CmdMediator & DlgSettingsAbstractBase::cmdMediator ( )
protected

Provide access to Document information wrapped inside CmdMediator.

Definition at line 67 of file DlgSettingsAbstractBase.cpp.

68{
69 ENGAUGE_CHECK_PTR (m_cmdMediator);
70
71 return *m_cmdMediator;
72}
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.

◆ createOptionalSaveDefault()

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

◆ createSubPanel()

virtual QWidget * DlgSettingsAbstractBase::createSubPanel ( )
protectedpure virtual

◆ createWhatsThis()

void DlgSettingsAbstractBase::createWhatsThis ( QGridLayout * layout,
ButtonWhatsThis * button,
int row,
int column )
protected

Create a WhatsThis button in a grid layout.

Definition at line 74 of file DlgSettingsAbstractBase.cpp.

78{
79 button = new ButtonWhatsThis ();
80 connect (button, SIGNAL (clicked ()), this, SLOT (slotWhatsThis()));
81 layout->addWidget (button, row, column, 1, 1, Qt::AlignRight | Qt::AlignTop);
82
83 // Prevent huge space after row with this button, especially with DlgSettingsMainWindow
84 layout->setRowStretch (row, 0);
85}

◆ 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 87 of file DlgSettingsAbstractBase.cpp.

88{
89 m_btnOk->setEnabled (enable);
90}

◆ 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 92 of file DlgSettingsAbstractBase.cpp.

95{
96 const int STRETCH_OFF = 0, STRETCH_ON = 1;
97
98 m_scroll = new QScrollArea (this);
99 m_scroll->setStyleSheet ("QScrollArea { border: 0; margin: 0; padding: 0;}"); // Need QScrollArea or interior frames are affected
100 m_scroll->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
101 m_scroll->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
102 m_scroll->setSizePolicy (QSizePolicy::Minimum,
103 QSizePolicy::Minimum);
104 m_scroll->setMinimumWidth (minimumWidth);
105
106 QWidget *viewport = new QWidget (this);
107 m_scroll->setWidget (viewport);
108 m_scroll->setWidgetResizable (true);
109
110 QHBoxLayout *scrollLayout = new QHBoxLayout (this);
111 scrollLayout->addWidget (m_scroll);
112 setLayout (scrollLayout);
113
114 QVBoxLayout *panelLayout = new QVBoxLayout (viewport);
115 viewport->setLayout (panelLayout);
116
117 panelLayout->addWidget (subPanel);
118 panelLayout->setStretch (panelLayout->count () - 1, STRETCH_ON);
119
120 QWidget *panelButtons = new QWidget (this);
121 QHBoxLayout *buttonLayout = new QHBoxLayout (panelButtons);
122
123 createOptionalSaveDefault(buttonLayout);
124
125 QHBoxLayout *layoutRightSide = new QHBoxLayout;
126
127 QWidget *widgetRightSide = new QWidget;
128 widgetRightSide->setLayout (layoutRightSide);
129 buttonLayout->addWidget (widgetRightSide);
130
131 QSpacerItem *spacerExpanding = new QSpacerItem (40, 5, QSizePolicy::Expanding, QSizePolicy::Expanding);
132 layoutRightSide->addItem (spacerExpanding);
133
134 m_btnOk = new QPushButton (tr ("Ok"));
135 m_btnOk->setEnabled (false); // Nothing to save initially
136 layoutRightSide->addWidget (m_btnOk, 0, Qt::AlignRight);
137 connect (m_btnOk, SIGNAL (released ()), this, SLOT (slotOk ()));
138
139 QSpacerItem *spacerFixed = new QSpacerItem (40, 5, QSizePolicy::Fixed, QSizePolicy::Fixed);
140 layoutRightSide->addItem (spacerFixed);
141
142 m_btnCancel = new QPushButton (tr ("Cancel"));
143 layoutRightSide->addWidget (m_btnCancel, 0, Qt::AlignRight);
144 connect (m_btnCancel, SIGNAL (released ()), this, SLOT (slotCancel ()));
145
146 panelLayout->addWidget (panelButtons, STRETCH_ON);
147 panelLayout->setStretch (panelLayout->count () - 1, STRETCH_OFF);
148
149 setSizePolicy (QSizePolicy::Minimum,
150 QSizePolicy::Minimum);
151
152 if (minimumHeightOrZero > 0) {
153 m_scroll->setMinimumHeight (minimumHeightOrZero);
154 }
155}
virtual void createOptionalSaveDefault(QHBoxLayout *layout)=0
Let subclass define an optional Save As Default button.

◆ handleOk()

◆ load()

◆ mainWindow() [1/2]

MainWindow & DlgSettingsAbstractBase::mainWindow ( )
protected

Get method for MainWindow.

Definition at line 157 of file DlgSettingsAbstractBase.cpp.

158{
159 return m_mainWindow;
160}

◆ mainWindow() [2/2]

const MainWindow & DlgSettingsAbstractBase::mainWindow ( ) const
protected

Const get method for MainWindow.

Definition at line 162 of file DlgSettingsAbstractBase.cpp.

163{
164 return m_mainWindow;
165}

◆ populateColorComboWithoutTransparent()

void DlgSettingsAbstractBase::populateColorComboWithoutTransparent ( QComboBox & combo)
protected

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

Definition at line 167 of file DlgSettingsAbstractBase.cpp.

168{
170 QVariant (COLOR_PALETTE_BLUE));
172 QVariant (COLOR_PALETTE_BLACK));
174 QVariant (COLOR_PALETTE_CYAN));
176 QVariant (COLOR_PALETTE_GOLD));
178 QVariant (COLOR_PALETTE_GREEN));
180 QVariant (COLOR_PALETTE_MAGENTA));
182 QVariant (COLOR_PALETTE_RED));
184 QVariant (COLOR_PALETTE_YELLOW));
185}
QString colorPaletteToString(ColorPalette colorPalette)
@ COLOR_PALETTE_GREEN
@ COLOR_PALETTE_MAGENTA
@ COLOR_PALETTE_BLACK
@ COLOR_PALETTE_GOLD
@ COLOR_PALETTE_RED
@ COLOR_PALETTE_BLUE
@ COLOR_PALETTE_CYAN
@ COLOR_PALETTE_YELLOW

◆ populateColorComboWithTransparent()

void DlgSettingsAbstractBase::populateColorComboWithTransparent ( QComboBox & combo)
protected

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

Definition at line 187 of file DlgSettingsAbstractBase.cpp.

188{
190 combo.addItem ("Transparent", QVariant (COLOR_PALETTE_TRANSPARENT));
191}
@ 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 200 of file DlgSettingsAbstractBase.cpp.

201{
202 m_cmdMediator = &cmdMediator;
203}
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 205 of file DlgSettingsAbstractBase.cpp.

206{
207 m_disableOkAtStartup = disableOkAtStartup;
208}

◆ 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 78 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 81 of file DlgSettingsAbstractBase.h.


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