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 00019 class DlgSettingsAbstractBase : public QDialog 00020 { 00021 Q_OBJECT; 00022 00023 public: 00025 DlgSettingsAbstractBase(const QString &title, 00026 const QString &dialogName, 00027 MainWindow &mainWindow); 00028 virtual ~DlgSettingsAbstractBase(); 00029 00030 protected: 00032 CmdMediator &cmdMediator (); 00033 00035 virtual void createOptionalSaveDefault (QHBoxLayout *layout) = 0; 00036 00038 virtual QWidget *createSubPanel () = 0; 00039 00048 void enableOk (bool enable); 00049 00051 void finishPanel (QWidget *subPanel); 00052 00054 virtual void handleOk () = 0; 00055 00057 static int MINIMUM_DIALOG_WIDTH; 00058 00060 static int MINIMUM_PREVIEW_HEIGHT; 00061 00063 virtual void load (CmdMediator &cmdMediator) = 0; 00064 00066 MainWindow &mainWindow (); 00067 00069 const MainWindow &mainWindow () const; 00070 00072 void populateColorComboWithoutTransparent (QComboBox &combo); 00073 00075 void populateColorComboWithTransparent (QComboBox &combo); 00076 00078 void setCmdMediator (CmdMediator &cmdMediator); 00079 00081 void setDisableOkAtStartup(bool disableOkAtStartup); 00082 00083 private slots: 00085 virtual void showEvent (QShowEvent *event); 00086 00088 void slotCancel(); 00089 00091 void slotOk (); 00092 00093 private: 00094 DlgSettingsAbstractBase(); 00095 00096 void saveGeometryToSettings (); 00097 00098 MainWindow &m_mainWindow; 00099 CmdMediator *m_cmdMediator; // Cannot be const since Document gets a command pushed if dialog is ok'ed 00100 QPushButton *m_btnCancel; 00101 QPushButton *m_btnOk; 00102 00103 const QString m_dialogName; 00104 bool m_disableOkAtStartup; 00105 }; 00106 00107 #endif // DLG_SETTINGS_ABSTRACT_BASE_H