FotoBox
preferenceprovider.h
Go to the documentation of this file.
1 /* preferenceprovider.h
2  *
3  * Copyright (c) 2018 Thomas Kais
4  *
5  * This file is subject to the terms and conditions defined in
6  * file 'COPYING', which is part of this source code package.
7  */
8 #ifndef PREFERENCEPROVIDER_H
9 #define PREFERENCEPROVIDER_H
10 
11 #include <QObject>
12 
13 namespace FotoBox {
14 
18 class PreferenceProvider : public QObject
19 {
20  Q_OBJECT
21 
22 private:
27  explicit PreferenceProvider(QObject *parent = nullptr);
28 
32  ~PreferenceProvider() override = default;
33 
35  QString m_photoFolder;
36 
38  QString m_photoName;
39 
42 
45 
47  QString m_cameraMode;
48 
50  QString m_argumentLine;
51 
53  int m_countdown = 0;
54 
56  unsigned int m_inputPin = 0;
57 
59  unsigned int m_outputPin = 0;
60 
62  unsigned int m_queryInterval = 0;
63 
65  int m_timeoutValue = 0;
66 
68  bool m_grayscale = false;
69 
71  bool m_showButtons = false;
72 
74  bool m_print = false;
75 
77  QString m_printerName;
78 
79 public:
80  //Qt Property System
81  Q_PROPERTY(QString photoFolder READ photoFolder WRITE setPhotoFolder NOTIFY photoFolderChanged)
82  Q_PROPERTY(QString photoName READ photoName WRITE setPhotoName NOTIFY photoNameChanged)
83  Q_PROPERTY(QString countdownColor READ countdownColor WRITE setCountdownColor NOTIFY countdownColorChanged)
84  Q_PROPERTY(QString backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
85  Q_PROPERTY(QString cameraMode READ cameraMode WRITE setCameraMode NOTIFY cameraModeChanged)
86  Q_PROPERTY(QString argumentLine READ argumentLine WRITE setArgumentLine NOTIFY argumentLineChanged)
87  Q_PROPERTY(int countdown READ countdown WRITE setCountdown NOTIFY countdownChanged)
88  Q_PROPERTY(unsigned int inputPin READ inputPin WRITE setInputPin NOTIFY inputPinChanged)
89  Q_PROPERTY(unsigned int outputPin READ outputPin WRITE setOutputPin NOTIFY outputPinChanged)
90  Q_PROPERTY(unsigned int queryInterval READ queryInterval WRITE setQueryInterval NOTIFY queryIntervalChanged)
91  Q_PROPERTY(int timeoutValue READ timeoutValue WRITE setTimeoutValue NOTIFY timeoutValueChanged)
92  Q_PROPERTY(bool grayscale READ grayscale WRITE setGrayscale NOTIFY grayscaleChanged)
93  Q_PROPERTY(bool showButtons READ showButtons WRITE setShowButtons NOTIFY showButtonsChanged)
94  Q_PROPERTY(bool print READ print WRITE setPrint NOTIFY printChanged)
95  Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName NOTIFY printerNameChanged)
96 
97 
101 
105  PreferenceProvider &operator=(const PreferenceProvider &) = delete;
106 
111 
115  PreferenceProvider &operator=(PreferenceProvider &&other) = delete;
116 
121  static PreferenceProvider &instance();
122 
127  auto photoFolder() const -> QString;
128 
133  auto photoName() const -> QString;
134 
139  auto countdownColor() const -> QString;
140 
145  auto backgroundColor() const -> QString;
146 
151  QString cameraMode() const;
152 
157  auto argumentLine() const -> QString;
158 
163  auto countdown() const -> int;
164 
169  auto inputPin() const -> unsigned int;
170 
175  auto outputPin() const -> unsigned int;
176 
181  auto queryInterval() const -> unsigned int;
182 
187  auto timeoutValue() const -> int;
188 
193  auto grayscale() const -> bool;
194 
199  auto showButtons() const -> bool;
200 
205  auto print() const -> bool;
206 
211  auto printerName() const -> QString;
212 
213 public Q_SLOTS:
218  void setPhotoFolder(const QString &i_value);
219 
224  void setPhotoName(const QString &i_value);
225 
230  void setCountdownColor(const QString &i_value);
231 
236  void setBackgroundColor(const QString &i_value);
237 
242  void setCameraMode(const QString &i_value);
243 
248  void setArgumentLine(const QString &i_value);
249 
254  void setCountdown(int i_value);
255 
260  void setInputPin(unsigned int i_value);
261 
266  void setOutputPin(unsigned int i_value);
267 
272  void setQueryInterval(unsigned int i_value);
273 
278  void setTimeoutValue(int i_value);
279 
284  void setGrayscale(bool i_value);
285 
290  void setShowButtons(bool i_value);
291 
296  void setPrint(bool i_value);
297 
302  void setPrinterName(const QString &i_value);
303 
304 Q_SIGNALS:
308  void photoFolderChanged(QString);
309 
313  void photoNameChanged(QString);
314 
318  void countdownColorChanged(QString);
319 
323  void backgroundColorChanged(QString);
324 
328  void cameraModeChanged(QString);
329 
333  void argumentLineChanged(QString);
334 
338  void countdownChanged(int);
339 
343  void inputPinChanged(unsigned int);
344 
348  void outputPinChanged(unsigned int);
349 
353  void queryIntervalChanged(unsigned int);
354 
359 
363  void grayscaleChanged(bool);
364 
368  void showButtonsChanged(bool);
369 
373  void printChanged(bool);
374 
378  void printerNameChanged(QString);
379 };
380 
381 } // end namespace FotoBox
382 
383 #endif // PREFERENCEPROVIDER_H
Preference who stores the preferences.
void inputPinChanged(unsigned int)
signal: pigpio GPIO input pin has changed
void argumentLineChanged(QString)
signal: camera framework arguments has changed
void setOutputPin(unsigned int i_value)
set pigpio GPIO output pin
void setInputPin(unsigned int i_value)
set pigpio GPIO input pin
void backgroundColorChanged(QString)
signal: background color of the FotoBox UI has changed
void photoNameChanged(QString)
signal: photo name template has changed
void setQueryInterval(unsigned int i_value)
set how often the pin should be queried
void cameraModeChanged(QString)
signal: the camera framework to be used has changed
void setTimeoutValue(int i_value)
set timeout value for the camera framework
void setCountdown(int i_value)
set countdown until photo is taken
void printChanged(bool)
signal: print has changed
void setCameraMode(const QString &i_value)
set the camera framework to be used
void setArgumentLine(const QString &i_value)
set camera framework arguments
void setPhotoFolder(const QString &i_value)
set photo output directory
void setPhotoName(const QString &i_value)
set photo name template
void photoFolderChanged(QString)
signal: photo output directory has changed
void setPrinterName(const QString &i_value)
set printer name
void showButtonsChanged(bool)
signal: whether buttons are displayed on the UI has changed
void setShowButtons(bool i_value)
set whether buttons are displayed on the UI
void setCountdownColor(const QString &i_value)
set font color of the countdown
void countdownChanged(int)
signal: countdown until photo is taken has changed
static PreferenceProvider & instance()
get instance (Meyers Singleton)
void setGrayscale(bool i_value)
set grayscale bool (monochrome photography)
void timeoutValueChanged(int)
signal: timeout value for the camera framework has changed
void grayscaleChanged(bool)
signal: grayscale (monochrome photography) has changed
void outputPinChanged(unsigned int)
signal: pigpio GPIO output pin has changed
void countdownColorChanged(QString)
signal: font color of the countdown has changed
void setPrint(bool i_value)
set print on or off
void queryIntervalChanged(unsigned int)
signal: how often the pin should be queried has changed
void setBackgroundColor(const QString &i_value)
set background color of the FotoBox UI
PreferenceProvider(QObject *parent=nullptr)
hide Preferences default constructor (Singleton)
~PreferenceProvider() override=default
hide Preferences destructor (Singleton)
void printerNameChanged(QString)
signal: printer name has changed