FotoBox
FotoBox::Camera Class Reference

The Camera class Use gphoto2 to send commands to camera. More...

#include <camera.h>

+ Inheritance diagram for FotoBox::Camera:
+ Collaboration diagram for FotoBox::Camera:

Public Member Functions

 Camera (QObject *parent=nullptr)
 Camera constructor. More...
 
 ~Camera () override=default
 Camera destructor. More...
 
 Camera (const Camera &other)=delete
 Camera default copy constructor. More...
 
Cameraoperator= (const Camera &other)=delete
 Camera default copy assignment. More...
 
 Camera (Camera &&other)=delete
 Camera default move constructor. More...
 
Cameraoperator= (Camera &&other)=delete
 Camera default move assignment. More...
 
auto shootPhoto () -> bool
 shoot a photo with gphoto2 More...
 
auto currentPhoto () const -> QString
 return member More...
 

Private Attributes

const int m_timeoutValue
 
QString m_currentPhoto
 
const QString m_photoSuffix
 
const QString m_cameraMode
 
const QStringList m_argList
 
QProcess m_process
 

Static Private Attributes

static constexpr int TO_SECONDS = 1000
 

Detailed Description

The Camera class Use gphoto2 to send commands to camera.

Definition at line 20 of file camera.h.

Constructor & Destructor Documentation

◆ Camera() [1/3]

FotoBox::Camera::Camera ( QObject *  parent = nullptr)
explicit

Camera constructor.

Parameters
parentQObjec

Definition at line 16 of file camera.cpp.

17  : QObject(parent)
21  , m_argList(PreferenceProvider::instance().argumentLine().split(QChar(' ')))
22  , m_process(this)
23 {
24  //call this function to save memory, if you are not interested in the output of the process
25  m_process.closeReadChannel(QProcess::StandardOutput);
26  m_process.closeReadChannel(QProcess::StandardError);
27 
28  //use 'photo folder' as working dir
29  m_process.setWorkingDirectory(PreferenceProvider::instance().photoFolder());
30 }
static constexpr int TO_SECONDS
Definition: camera.h:70
const QString m_cameraMode
Definition: camera.h:82
const int m_timeoutValue
Definition: camera.h:73
const QString m_photoSuffix
Definition: camera.h:79
const QStringList m_argList
Definition: camera.h:85
QProcess m_process
Definition: camera.h:88
static PreferenceProvider & instance()
get instance (Meyers Singleton)

References FotoBox::PreferenceProvider::instance(), and m_process.

+ Here is the call graph for this function:

◆ ~Camera()

FotoBox::Camera::~Camera ( )
overridedefault

Camera destructor.

◆ Camera() [2/3]

FotoBox::Camera::Camera ( const Camera other)
delete

Camera default copy constructor.

◆ Camera() [3/3]

FotoBox::Camera::Camera ( Camera &&  other)
delete

Camera default move constructor.

Member Function Documentation

◆ currentPhoto()

auto FotoBox::Camera::currentPhoto ( ) const -> QString

return member

See also
m_currentPhoto
Returns
filepath current photo

Definition at line 48 of file camera.cpp.

49 {
50  return m_currentPhoto;
51 }
QString m_currentPhoto
Definition: camera.h:76

References m_currentPhoto.

◆ operator=() [1/2]

Camera& FotoBox::Camera::operator= ( Camera &&  other)
delete

Camera default move assignment.

◆ operator=() [2/2]

Camera& FotoBox::Camera::operator= ( const Camera other)
delete

Camera default copy assignment.

◆ shootPhoto()

auto FotoBox::Camera::shootPhoto ( ) -> bool

shoot a photo with gphoto2

Returns
true: processed finished / false: error

Definition at line 32 of file camera.cpp.

33 {
34  //file name of photo
35  m_currentPhoto = QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_HH-mm-ss_")) + m_photoSuffix;
36  //add filename to argument
37  auto arguments = m_argList;
38  arguments = arguments.replaceInStrings(QStringLiteral("%1"), m_currentPhoto);
39 
40  //start programm with given arguments
41  m_process.start(m_cameraMode, arguments, {});
42  m_process.waitForFinished(m_timeoutValue);
43 
44  //check time out and process exit code
45  return (m_process.exitCode() == EXIT_SUCCESS);
46 }

Member Data Documentation

◆ m_argList

const QStringList FotoBox::Camera::m_argList
private

list of command line arguments

Definition at line 85 of file camera.h.

◆ m_cameraMode

const QString FotoBox::Camera::m_cameraMode
private

camera mode

Definition at line 82 of file camera.h.

◆ m_currentPhoto

QString FotoBox::Camera::m_currentPhoto
private

name of the current photo

Definition at line 76 of file camera.h.

Referenced by currentPhoto().

◆ m_photoSuffix

const QString FotoBox::Camera::m_photoSuffix
private

name of the photo

Definition at line 79 of file camera.h.

◆ m_process

QProcess FotoBox::Camera::m_process
private

executing commands

Definition at line 88 of file camera.h.

Referenced by Camera().

◆ m_timeoutValue

const int FotoBox::Camera::m_timeoutValue
private

time out value

Definition at line 73 of file camera.h.

◆ TO_SECONDS

constexpr int FotoBox::Camera::TO_SECONDS = 1000
staticconstexprprivate

used to convert msec to sec

Definition at line 70 of file camera.h.


The documentation for this class was generated from the following files: