FotoBox
preferences.h
Go to the documentation of this file.
1 /* preferences.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 PREFERENCES_H
9 #define PREFERENCES_H
10 
11 #include "countdown.h"
12 
13 #include <QDialog>
14 #include <QSettings>
15 
16 namespace Ui {
17 class PreferencesDialog;
18 } //namespace Ui
19 
20 namespace FotoBox {
21 
25 class Preferences : public QDialog
26 {
27  Q_OBJECT
28 
29 public:
34  explicit Preferences(QWidget *parent = nullptr);
35 
39  ~Preferences() override;
40 
44  Preferences(const Preferences &other) = delete;
45 
49  Preferences &operator=(const Preferences &other) = delete;
50 
54  Preferences(Preferences &&other) = delete;
55 
59  Preferences &operator=(Preferences &&other) = delete;
60 
61 private Q_SLOTS:
65  void startFotoBox();
66 
70  void colorDialog();
71 
77 
81  void chooseDirectory();
82 
86  void clearDirectoryContent();
87 
92 
97  void showColor(const QString &i_colorName);
98 
104  void verifyApplication(const QString &i_name);
105 
111  bool verifyPath(const QString &i_path);
112 
113 private:
118  void windowPosition();
119 
123  void pigpioDeamon();
124 
128  void stopCountdownMode();
129 
133  void connectUi();
134 
138  void loadPreferences();
139 
143  void setButtonIcons();
144 
148  void savePreferences();
149 
154  void mouseMoveEvent(QMouseEvent *event) override;
155 
162  auto applicationAvailable(const QString &i_name, const QString &i_message) -> bool;
163 
169  auto gphotoInfo(const QString &i_name) -> QString;
170 
172  static constexpr int COUNTDOWN_START_VALUE = 10;
173 
175  static constexpr int DEFAULT_COUNTDOWN_START_VALUE = 3;
176 
178  static constexpr unsigned int DEFAULT_INPUT_PIN = 24;
179 
181  static constexpr unsigned int DEFAULT_OUTPUT_PIN = 17;
182 
184  static constexpr unsigned int DEFAULT_QUERY_INTERVAL = 10;
185 
187  static constexpr int DEFAULT_TIMEOUT = 30;
188 
190  Ui::PreferencesDialog *m_ui;
191 
193  QSettings m_settings;
194 
197 };
198 
199 } // end namespace FotoBox
200 
201 #endif // PREFERENCES_H
The Countdown class.
Definition: countdown.h:21
Preference class to change and store the application settings.
Definition: preferences.h:26
Preferences(QWidget *parent=nullptr)
Preferences constructor.
Definition: preferences.cpp:27
void pigpioDeamon()
Check if pigpio deamon is reachable.
Definition: preferences.cpp:87
static constexpr unsigned int DEFAULT_QUERY_INTERVAL
Definition: preferences.h:184
void clearDirectoryContent()
Clear directory content of the photo directory.
void mouseMoveEvent(QMouseEvent *event) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
static constexpr int COUNTDOWN_START_VALUE
Definition: preferences.h:172
static constexpr unsigned int DEFAULT_OUTPUT_PIN
Definition: preferences.h:181
void commandLineOptionsDialog()
Show help dialog for gphoto2/raspistill command line options.
static constexpr unsigned int DEFAULT_INPUT_PIN
Definition: preferences.h:178
void savePreferences()
Save the preferences to QSettings.
Ui::PreferencesDialog * m_ui
Definition: preferences.h:190
static constexpr int DEFAULT_COUNTDOWN_START_VALUE
Definition: preferences.h:175
Preferences(const Preferences &other)=delete
Preferences default copy constructor.
void chooseDirectory()
Open a QFileDialog to choose the photo directory.
void restoreDefaultPreferences()
Restore default preferences.
auto gphotoInfo(const QString &i_name) -> QString
Read gphoto2 / libgphoto2 version and camera model.
Preferences & operator=(Preferences &&other)=delete
Preferences default move assignment.
void loadPreferences()
Load application settings from INI file.
static constexpr int DEFAULT_TIMEOUT
Definition: preferences.h:187
void stopCountdownMode()
Stop countdown, stop mouse tracking and set normal window title name.
void showColor(const QString &i_colorName)
Show the given color in QLineEdit.
void connectUi()
Signal & Slot connect.
Definition: preferences.cpp:97
void windowPosition()
Set the window position.
Definition: preferences.cpp:75
Preferences(Preferences &&other)=delete
Preferences default move constructor.
auto applicationAvailable(const QString &i_name, const QString &i_message) -> bool
Check if application is installed and available.
void verifyApplication(const QString &i_name)
Check camera application availability and provide help if needed.
void setButtonIcons()
Set icons for all QToolButtons.
Preferences & operator=(const Preferences &other)=delete
Preferences default copy assignment.
void colorDialog()
Open a color picker to choose background color for FotoBox.
~Preferences() override
Preferences destructor.
Definition: preferences.cpp:70
bool verifyPath(const QString &i_path)
Check if the path is useable.
void startFotoBox()
Start the FotoBox.
Definition: fotobox.h:20