| 1 | /*************************************************************************** |
| 2 | configure.h |
| 3 | ------------------- |
| 4 | Application configuration dialog |
| 5 | ------------------- |
| 6 | Copyright 2006-2008 David Johnson |
| 7 | All rights reserved. |
| 8 | |
| 9 | Redistribution and use in source and binary forms, with or without |
| 10 | modification, are permitted provided that the following conditions |
| 11 | are met: |
| 12 | |
| 13 | 1. Redistributions of source code must retain the above copyright |
| 14 | notice, this list of conditions and the following disclaimer. |
| 15 | |
| 16 | 2. Redistributions in binary form must reproduce the above copyright |
| 17 | notice, this list of conditions and the following disclaimer in the |
| 18 | documentation and/or other materials provided with the distribution. |
| 19 | |
| 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | ****************************************************************************/ |
| 32 | |
| 33 | #ifndef CONFIGURE_H |
| 34 | #define CONFIGURE_H |
| 35 | |
| 36 | #include <QDialog> |
| 37 | #include "ui_calcconfig.h" |
| 38 | #include "ui_generalconfig.h" |
| 39 | #include "ui_recipeconfig.h" |
| 40 | #include "configstate.h" |
| 41 | |
| 42 | class QDialogButtonBox; |
| 43 | class QTabWidget; |
| 44 | |
| 45 | class Configure : public QDialog |
| 46 | { |
| 47 | Q_OBJECT |
| 48 | public: |
| 49 | // constructor |
| 50 | Configure(QWidget* parent); |
| 51 | // destructor |
| 52 | virtual ~Configure(); |
| 53 | |
| 54 | // read in config to set states |
| 55 | void setState(const ConfigState &config); |
| 56 | |
| 57 | signals: |
| 58 | // send on apply button press |
| 59 | void calcApply(const CalcConfigState &state); |
| 60 | void generalApply(const GenConfigState &state); |
| 61 | void recipeApply(const RecipeConfigState &state); |
| 62 | // OK button pressed |
| 63 | void configureAccept(); |
| 64 | |
| 65 | private: |
| 66 | // set the state for the pages |
| 67 | void setCalcState(const CalcConfigState &state); |
| 68 | void setGeneralState(const GenConfigState &state); |
| 69 | void setRecipeState(const RecipeConfigState &state); |
| 70 | void defaults(); |
| 71 | void apply(); |
| 72 | |
| 73 | private slots: |
| 74 | // standard modeless dialog slots |
| 75 | void accept(); |
| 76 | void slotClicked(QAbstractButton *button); |
| 77 | // convert the batch size when units have changed |
| 78 | void convertBatchSpin(const QString &selection); |
| 79 | |
| 80 | private: |
| 81 | QTabWidget *tabwidget_; |
| 82 | QDialogButtonBox *buttonbox_; |
| 83 | Ui::CalcConfig *calc_; |
| 84 | Ui::GeneralConfig *general_; |
| 85 | Ui::RecipeConfig *recipe_; |
| 86 | ConfigState state_; |
| 87 | }; |
| 88 | |
| 89 | #endif // CONFIGURE_H |