9122bedf0f283410aed52952d62aca4c2bbdd6fb
[harmattan/cameraplus] / src / platformsettings.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012 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 "platformsettings.h"
22 #include <QDir>
23 #include <QSize>
24
25 #define PATH "/usr/share/cameraplus/config/cameraplus.ini"
26
27 #define PREVIEW_SIZE                             QSize(854, 480)
28 #define THUMBNAIL_FLAVOR_NAME                    QString("screen")
29 #define TEMPORARY_FILE_PATH                      "%1%2.config%2quill%2tmp"
30 #define THUMBNAIL_EXTENSION                      QString("jpeg")
31 #define THUMBNAIL_CREATION_ENABLED               true
32 #define DBUS_THUMBNAILING_ENABLED                true
33 #define BACKGROUND_RENDERING_COLOR               QColor(Qt::black)
34
35 PlatformSettings::PlatformSettings() :
36   QSettings(PATH, QSettings::IniFormat) {
37
38 }
39
40 PlatformSettings::~PlatformSettings() {
41
42 }
43
44 QList<QPair<QString, QSize> > PlatformSettings::previewLevels() {
45   return QList<QPair<QString, QSize> >() <<
46     qMakePair<QString, QSize>(value("quill/thumbnailFlavorName", THUMBNAIL_FLAVOR_NAME).toString(),
47                               value("quill/previewSize", PREVIEW_SIZE).toSize());
48 }
49
50 QString PlatformSettings::thumbnailExtension() {
51   return value("quill/thumbnailExtension", THUMBNAIL_EXTENSION).toString();
52 }
53
54 QColor PlatformSettings::backgroundRenderingColor() {
55   return value("quill/backgroundRenderingColor", BACKGROUND_RENDERING_COLOR).value<QColor>();
56 }
57
58 bool PlatformSettings::isDBusThumbnailingEnabled() {
59   return value("quill/dbusThumbnailingEnabled", DBUS_THUMBNAILING_ENABLED).toBool();
60 }
61
62 bool PlatformSettings::isThumbnailCreationEnabled() {
63   return value("quill/thumbnailCreationEnabled", THUMBNAIL_CREATION_ENABLED).toBool();
64 }
65
66 QString PlatformSettings::temporaryFilePath() {
67   QString defaultPath = QString(TEMPORARY_FILE_PATH).arg(QDir::homePath()).arg(QDir::separator());
68   return value("quill/temporaryFilePath", defaultPath).toString();
69 }