Generate proper thumbnails for portrait images.
[harmattan/cameraplus] / src / platformsettings.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 "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 QSize PlatformSettings::previewSize() {
45   return value("quill/previewSize", PREVIEW_SIZE).toSize();
46 }
47
48 QString PlatformSettings::thumbnailFlavorName() {
49   return value("quill/thumbnailFlavorName", THUMBNAIL_FLAVOR_NAME).toString();
50 }
51
52 QString PlatformSettings::thumbnailExtension() {
53   return value("quill/thumbnailExtension", THUMBNAIL_EXTENSION).toString();
54 }
55
56 QColor PlatformSettings::backgroundRenderingColor() {
57   return value("quill/backgroundRenderingColor", BACKGROUND_RENDERING_COLOR).value<QColor>();
58 }
59
60 bool PlatformSettings::isDBusThumbnailingEnabled() {
61   return value("quill/dbusThumbnailingEnabled", DBUS_THUMBNAILING_ENABLED).toBool();
62 }
63
64 bool PlatformSettings::isThumbnailCreationEnabled() {
65   return value("quill/thumbnailCreationEnabled", THUMBNAIL_CREATION_ENABLED).toBool();
66 }
67
68 QString PlatformSettings::temporaryFilePath() {
69   QString defaultPath = QString(TEMPORARY_FILE_PATH).arg(QDir::homePath()).arg(QDir::separator());
70   return value("quill/temporaryFilePath", defaultPath).toString();
71 }