00001 /****************************************************************************************************** 00002 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 00003 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 00004 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 00005 ******************************************************************************************************/ 00006 00007 #ifndef DLG_SETTINGS_ABSTRACT_BASE_H 00008 #define DLG_SETTINGS_ABSTRACT_BASE_H 00009 00010 #include <QDialog> 00011 #include <QObject> 00012 00013 class CmdMediator; 00014 class MainWindow; 00015 class QComboBox; 00016 class QHBoxLayout; 00017 class QScrollArea; 00018 00020 class DlgSettingsAbstractBase : public QDialog 00021 { 00022 Q_OBJECT; 00023 00024 public: 00026 DlgSettingsAbstractBase(const QString &title, 00027 const QString &dialogName, 00028 MainWindow &mainWindow); 00029 virtual ~DlgSettingsAbstractBase(); 00030 00031 protected: 00033 CmdMediator &cmdMediator (); 00034 00036 virtual void createOptionalSaveDefault (QHBoxLayout *layout) = 0; 00037 00039 virtual QWidget *createSubPanel () = 0; 00040 00049 void enableOk (bool enable); 00050 00052 void finishPanel (QWidget *subPanel, 00053 int minimumWidth = MINIMUM_DIALOG_WIDTH, 00054 int minimumHeightOrZero = 0); 00055 00057 virtual void handleOk () = 0; 00058 00060 virtual void load (CmdMediator &cmdMediator) = 0; 00061 00063 static int MINIMUM_DIALOG_WIDTH; 00064 00066 static int MINIMUM_PREVIEW_HEIGHT; 00067 00069 MainWindow &mainWindow (); 00070 00072 const MainWindow &mainWindow () const; 00073 00075 void populateColorComboWithoutTransparent (QComboBox &combo); 00076 00078 void populateColorComboWithTransparent (QComboBox &combo); 00079 00081 void setCmdMediator (CmdMediator &cmdMediator); 00082 00084 void setDisableOkAtStartup(bool disableOkAtStartup); 00085 00087 virtual void setSmallDialogs (bool smallDialogs) = 0; 00088 00089 private slots: 00090 00092 void slotCancel(); 00093 00095 void slotOk (); 00096 00097 private: 00098 DlgSettingsAbstractBase(); 00099 00100 void saveGeometryToSettings (); 00101 00103 virtual void showEvent (QShowEvent *event); 00104 00105 QScrollArea *m_scroll; 00106 MainWindow &m_mainWindow; 00107 CmdMediator *m_cmdMediator; // Cannot be const since Document gets a command pushed if dialog is ok'ed 00108 QPushButton *m_btnCancel; 00109 QPushButton *m_btnOk; 00110 00111 const QString m_dialogName; 00112 bool m_disableOkAtStartup; 00113 }; 00114 00115 #endif // DLG_SETTINGS_ABSTRACT_BASE_H