Prevent changing any camera properties while device change is in progress
[harmattan/cameraplus] / lib / qtcamimagemode.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 #include "qtcamimagemode.h"
22 #include "qtcammode_p.h"
23 #include "qtcamdevice_p.h"
24 #include "qtcamimagesettings.h"
25 #include "qtcamdevice.h"
26
27 class QtCamImageModePrivate : public QtCamModePrivate {
28 public:
29   QtCamImageModePrivate(QtCamDevicePrivate *dev) :
30   QtCamModePrivate(dev),
31   settings(dev->conf->imageSettings(dev->id)),
32   resolution(settings->defaultResolution()) {
33
34   }
35
36   ~QtCamImageModePrivate() {
37     delete settings;
38   }
39
40   QtCamImageSettings *settings;
41   QtCamImageResolution resolution;
42 };
43
44 QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *dev, QObject *parent) :
45   QtCamMode(new QtCamImageModePrivate(dev), "mode-image", parent) {
46
47   d_ptr->init(new DoneHandler(d_ptr, "image-done", this));
48
49   d = (QtCamImageModePrivate *)d_ptr;
50
51   QString name = d_ptr->dev->conf->imageEncodingProfileName();
52   QString path = d_ptr->dev->conf->imageEncodingProfilePath();
53
54   if (!name.isEmpty() && !path.isEmpty()) {