forked from Brewtarget/brewtarget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.h
418 lines (363 loc) · 12.7 KB
/
MainWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/*
* MainWindow.h is part of Brewtarget, and is Copyright the following
* authors 2009-2014
* - Dan Cavanagh <[email protected]>
* - Jeff Bailey <[email protected]>
* - Maxime Lavigne <[email protected]>
* - Mik Firestone <[email protected]>
* - Philip Greggory Lee <[email protected]>
* - Samuel Östling <[email protected]>
* - Ted Wright
*
* Brewtarget is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Brewtarget is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MAINWINDOW_H
#define _MAINWINDOW_H
class MainWindow;
#include <QWidget>
#include <QMainWindow>
#include <QString>
#include <QVariant>
#include <QFileDialog>
#include <QPalette>
#include <QCloseEvent>
#include <QPrinter>
#include <QPrintDialog>
#include <QTimer>
#include "ui_mainWindow.h"
#include <functional>
// Forward Declarations
class FermentableDialog;
class HopDialog;
class MiscDialog;
class YeastDialog;
class AboutDialog;
class Recipe;
class BeerColorWidget;
class FermentableEditor;
class MiscEditor;
class HopEditor;
class YeastEditor;
class EquipmentEditor;
class StyleEditor;
class OptionDialog;
class MashEditor;
class MashStepEditor;
class MashWizard;
class BrewDayScrollWidget;
class HtmlViewer;
class ScaleRecipeTool;
class RecipeFormatter;
class OgAdjuster;
class ConverterTool;
class HydrometerTool;
class TimerMainDialog;
class PrimingDialog;
class StrikeWaterDialog;
class RecipeExtrasWidget;
class RefractoDialog;
class MashDesigner;
class MashListModel;
class PitchDialog;
class BrewNoteWidget;
class FermentableTableModel;
class FermentableSortFilterProxyModel;
class HopTableModel;
class HopSortFilterProxyModel;
class MiscTableModel;
class MiscSortFilterProxyModel;
class YeastTableModel;
class YeastSortFilterProxyModel;
class MashStepTableModel;
class EquipmentListModel;
class StyleListModel;
class StyleSortFilterProxyModel;
class NamedMashEditor;
class BtDatePopup;
class WaterDialog;
class WaterListModel;
class WaterEditor;
/*!
* \class MainWindow
* \author Philip G. Lee
*
* \brief Brewtarget's main window. This is a view/controller class.
*/
class MainWindow : public QMainWindow, public Ui::mainWindow
{
Q_OBJECT
friend class OptionDialog;
public:
MainWindow(QWidget* parent=nullptr);
virtual ~MainWindow() {}
//! \brief Get the currently observed recipe.
Recipe* currentRecipe();
//! \brief Display a file dialog for writing xml files.
QFile* openForWrite(QString filterStr = "BeerXML files (*.xml)", QString defaultSuff = "xml");
bool verifyImport(QString tag, QString name);
bool verifyDelete(QString tab, QString name);
void setBrewNoteByIndex(const QModelIndex &index);
void setBrewNote(BrewNote* bNote);
public slots:
//! \brief Accepts Recipe changes, and takes appropriate action to show the changes.
void changed(QMetaProperty,QVariant);
void treeActivated(const QModelIndex &index);
//! \brief View the given recipe.
void setRecipe(Recipe* recipe);
//! \brief Update Recipe name to that given by the relevant widget.
void updateRecipeName();
//! \brief Update Recipe Style to that given by the relevant widget.
void updateRecipeStyle();
//! \brief Update Recipe Equipment to that given by the relevant widget.
void updateRecipeEquipment();
//! \brief Update Recipe batch size to that given by the relevant widget.
void updateRecipeBatchSize();
//! \brief Update Recipe boil size to that given by the relevant widget.
void updateRecipeBoilSize();
//! \brief Update Recipe boil time to that given by the relevant widget.
void updateRecipeBoilTime();
//! \brief Update Recipe efficiency to that given by the relevant widget.
void updateRecipeEfficiency();
//! \brief Update Recipe's mash
void updateRecipeMash();
//! \brief Update the main windows statusbar.
void updateStatus(const QString status);
//! \brief Close a brewnote tab if we must
void closeBrewNote(BrewNote*);
//! \brief Add given Fermentable to the Recipe.
void addFermentableToRecipe(Fermentable* ferm);
//! \brief Remove selected Fermentable(s) from the Recipe.
void removeSelectedFermentable();
//! \brief Edit selected Fermentable.
void editSelectedFermentable();
//! \brief Show the pitch dialog.
void showPitchDialog();
//! \brief Add given Hop to the Recipe.
void addHopToRecipe(Hop *hop);
//! \brief Remove selected Hop(s) from the Recipe.
void removeSelectedHop();
//! \brief Edit selected Hop.
void editSelectedHop();
//! \brief Add given Misc to the Recipe.
void addMiscToRecipe(Misc* misc);
//! \brief Remove selected Misc(s) from the Recipe.
void removeSelectedMisc();
//! \brief Edit selected Misc.
void editSelectedMisc();
//! \brief Add given Yeast to the Recipe.
void addYeastToRecipe(Yeast* yeast);
//! \brief Remove selected Yeast(s) from the Recipe.
void removeSelectedYeast();
//! \brief Edit selected Yeast
void editSelectedYeast();
//! \brief Add a new mash step to the recipe.
void addMashStep();
//! \brief Move currently selected mash step down.
void moveSelectedMashStepUp();
//! \brief Move currently selected mash step up.
void moveSelectedMashStepDown();
//! \brief Remove currently selected mash step.
void removeSelectedMashStep();
//! \brief Edit currently selected mash step.
void editSelectedMashStep();
//! \brief Set the current recipe's mash to the one selected in the mash combo box.
void setMashToCurrentlySelected();
//! \brief Save the current recipe's mash to be used in other recipes.
void saveMash();
//! \brief Remove the current mash from the recipe, and replace with a blank one.
void removeMash();
//! \brief Create a new recipe in the database.
void newRecipe();
//! \brief Export current recipe to BeerXML.
void exportRecipe();
//! \brief Display file selection dialog and import BeerXML files.
void importFiles();
//! \brief Create a duplicate of the current recipe.
void copyRecipe();
//! \brief Create a new folder
void newFolder();
void renameFolder();
void deleteSelected();
void copySelected();
void exportSelected();
void exportSelectedHtml();
//! \brief Backup the database.
void backup();
//! \brief Restore the database.
void restoreFromBackup();
//! \brief makes sure we can do water chemistry before we show the window
void popChemistry();
/*!
* \brief Prints a document.
*
* Asks the user to select a printer and then calls the @p functor with the
* selected printer.
*/
void print(std::function<void(QPrinter* printer)> functor);
/*!
* \brief Exports a HTML document.
*
* Asks the user to select a file and then calls the @p functor with the
* selected file.
*/
void exportHTML(std::function<void(QFile* file)> functor);
//! \brief draws a context menu, the exact nature of which depends on which
//tree is focused
void contextMenu(const QPoint &point);
//! \brief creates a new brewnote
void newBrewNote();
//! \brief copies an existing brewnote to a new brewday
void reBrewNote();
void brewItHelper();
void brewAgainHelper();
void reduceInventory();
void changeBrewDate();
void fixBrewNote();
//! \brief Open the default browser to view Brewtarget manual.
void openManual();
//! \brief Merges two database files.
void updateDatabase();
//! \brief Catches a QNetworkReply signal and gets info about any new version available.
void finishCheckingVersion();
void redisplayLabel();
void showEquipmentEditor();
void showStyleEditor();
//! \brief Set the equipment based on a drop event
void droppedRecipeEquipment(Equipment *kit);
void droppedRecipeStyle(Style *style);
void droppedRecipeFermentable(QList<Fermentable*>ferms);
void droppedRecipeHop(QList<Hop*>hops);
void droppedRecipeMisc(QList<Misc*>miscs);
void droppedRecipeYeast(QList<Yeast*>yeasts);
protected:
virtual void closeEvent(QCloseEvent* event);
private slots:
/*!
* \brief Make the widgets in the window update changes.
*
* Updates all the widgets with info about the currently
* selected Recipe, except for the tables.
*
* \param prop Not yet used. Will indicate which Recipe property has changed.
*/
void showChanges(QMetaProperty* prop = nullptr);
private:
Recipe* recipeObs;
Style* recStyle;
Equipment* recEquip;
QString highSS, lowSS, goodSS, boldSS; // Palette replacements
AboutDialog* dialog_about;
QFileDialog* fileOpener;
QFileDialog* fileSaver;
QList<QMenu*> contextMenus;
EquipmentEditor* equipEditor;
EquipmentEditor* singleEquipEditor;
FermentableDialog* fermDialog;
FermentableEditor* fermEditor;
HopDialog* hopDialog;
HopEditor* hopEditor;
MashEditor* mashEditor;
MashStepEditor* mashStepEditor;
MashWizard* mashWizard;
MiscDialog* miscDialog;
MiscEditor* miscEditor;
StyleEditor* styleEditor;
StyleEditor* singleStyleEditor;
YeastDialog* yeastDialog;
YeastEditor* yeastEditor;
OptionDialog* optionDialog;
QDialog* brewDayDialog;
ScaleRecipeTool* recipeScaler;
RecipeFormatter* recipeFormatter;
OgAdjuster* ogAdjuster;
ConverterTool* converterTool;
HydrometerTool* hydrometerTool;
TimerMainDialog* timerMainDialog;
PrimingDialog* primingDialog;
StrikeWaterDialog* strikeWaterDialog;
RefractoDialog* refractoDialog;
MashDesigner* mashDesigner;
PitchDialog* pitchDialog;
QPrinter *printer;
WaterDialog* waterDialog;
WaterEditor* waterEditor;
// all things tables should go here.
FermentableTableModel* fermTableModel;
HopTableModel* hopTableModel;
MashStepTableModel* mashStepTableModel;
MiscTableModel* miscTableModel;
YeastTableModel* yeastTableModel;
// all things lists should go here
EquipmentListModel* equipmentListModel;
MashListModel* mashListModel;
StyleListModel* styleListModel;
WaterListModel* waterListModel;
// all things sort/filter proxy go here
FermentableSortFilterProxyModel* fermTableProxy;
HopSortFilterProxyModel* hopTableProxy;
MiscSortFilterProxyModel* miscTableProxy;
StyleSortFilterProxyModel* styleProxyModel;
YeastSortFilterProxyModel* yeastTableProxy;
NamedMashEditor* namedMashEditor;
NamedMashEditor* singleNamedMashEditor;
BtDatePopup* btDatePopup;
int confirmDelete;
//! \brief Fix pixel dimensions according to dots-per-inch (DPI) of screen we're on.
void setSizesInPixelsBasedOnDpi();
//! \brief Currently highlighted fermentable in the fermentable table.
Fermentable* selectedFermentable();
//! \brief Currently highlighted hop in the hop table.
Hop* selectedHop();
//! \brief Currently highlighted misc in the misc table.
Misc* selectedMisc();
//! \brief Currently highlighted yeast in the yeast table
Yeast* selectedYeast();
//! \brief Find an open brewnote tab, if it is open
BrewNoteWidget* findBrewNoteWidget(BrewNote* b);
//! \brief Scroll to the given \c item in the currently visible item tree.
void setTreeSelection(QModelIndex item);
//! \brief Set the keyboard shortcuts.
void setupShortCuts();
//! \brief Set the BtTreeView context menus.
void setupContextMenu();
//! \brief Create the CSS strings
void setupCSS();
//! \brief Create the dialogs, including the file dialogs
void setupDialogs();
//! \brief Configure the range sliders
void setupRanges();
//! \brief Configure combo boxes and their list models
void setupComboBoxes();
//! \brief Configure the tables and their proxies
void setupTables();
//! \brief Restore any saved states
void restoreSavedState();
//! \brief Connect the signal/slots for actions
void setupTriggers();
//! \brief Connect signal/slots for buttons
void setupClicks();
//! \brief Connect signal/slots for combo boxes
void setupActivate();
//! \brief Connect signal/slots for combo boxes
void setupLabels();
//! \brief Connect signal/slots for text edits
void setupTextEdit();
//! \brief Connect signal/slots drag/drop
void setupDrops();
void updateDensitySlider(QString attribute, RangedSlider* slider, double max);
void updateColorSlider(QString attribute, RangedSlider* slider);
void convertedMsg();
void importMsg();
};
#endif /* _MAINWINDOW_H */