Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
DlgSettingsAbstractBase.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef DLG_SETTINGS_ABSTRACT_BASE_H
8 #define DLG_SETTINGS_ABSTRACT_BASE_H
9 
10 #include <QDialog>
11 #include <QObject>
12 
13 class CmdMediator;
14 class MainWindow;
15 class QComboBox;
16 class QHBoxLayout;
17 class QScrollArea;
18 
20 class DlgSettingsAbstractBase : public QDialog
21 {
22  Q_OBJECT;
23 
24 public:
26  DlgSettingsAbstractBase(const QString &title,
27  const QString &dialogName,
29  virtual ~DlgSettingsAbstractBase();
30 
31 protected:
34 
36  virtual void createOptionalSaveDefault (QHBoxLayout *layout) = 0;
37 
39  virtual QWidget *createSubPanel () = 0;
40 
49  void enableOk (bool enable);
50 
52  void finishPanel (QWidget *subPanel,
53  int minimumWidth = MINIMUM_DIALOG_WIDTH);
54 
56  virtual void handleOk () = 0;
57 
59  virtual void load (CmdMediator &cmdMediator) = 0;
60 
63 
66 
69 
71  const MainWindow &mainWindow () const;
72 
74  void populateColorComboWithoutTransparent (QComboBox &combo);
75 
77  void populateColorComboWithTransparent (QComboBox &combo);
78 
80  void setCmdMediator (CmdMediator &cmdMediator);
81 
83  void setDisableOkAtStartup(bool disableOkAtStartup);
84 
85 private slots:
86 
88  void slotCancel();
89 
91  void slotOk ();
92 
93 private:
95 
96  void saveGeometryToSettings ();
97 
99  virtual void showEvent (QShowEvent *event);
100 
101  QScrollArea *m_scroll;
102  MainWindow &m_mainWindow;
103  CmdMediator *m_cmdMediator; // Cannot be const since Document gets a command pushed if dialog is ok'ed
104  QPushButton *m_btnCancel;
105  QPushButton *m_btnOk;
106 
107  const QString m_dialogName;
108  bool m_disableOkAtStartup;
109 };
110 
111 #endif // DLG_SETTINGS_ABSTRACT_BASE_H
static int MINIMUM_DIALOG_WIDTH
Dialog layout constant that guarantees every widget has sufficient room. Can be increased by finishPa...
void setDisableOkAtStartup(bool disableOkAtStartup)
Override the default Ok button behavior applied in showEvent.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)=0
Let subclass define an optional Save As Default button.
void populateColorComboWithoutTransparent(QComboBox &combo)
Add colors in color palette to combobox, without transparent entry at end.
virtual QWidget * createSubPanel()=0
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
virtual void load(CmdMediator &cmdMediator)=0
Load settings from Document.
Command queue stack.
Definition: CmdMediator.h:23
virtual void handleOk()=0
Process slotOk.
void populateColorComboWithTransparent(QComboBox &combo)
Add colors in color palette to combobox, with transparent entry at end.
Abstract base class for all Settings dialogs.
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:83
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.