From: Mohammed Sameer Date: Sat, 23 Feb 2013 20:54:16 +0000 (+0200) Subject: Added cameraplus.ini to store application specific settings X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=commitdiff_plain;h=b2f99e69cb4012bb167d6be909c113a1b0f5dc9f Added cameraplus.ini to store application specific settings --- diff --git a/data/n9/cameraplus.ini b/data/n9/cameraplus.ini new file mode 100644 index 0000000..c5d0389 --- /dev/null +++ b/data/n9/cameraplus.ini @@ -0,0 +1,13 @@ +[quill] +previewSize = @Size(854 480) +thumbnailFlavorName = screen +thumbnailExtension = jpeg + +# QColor(Qt::black) +backgroundRenderingColor = @Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\0\0\0\0) + +# Empty to use the default + +temporaryFilePath = +dbusThumbnailingEnabled = true +thumbnailCreationEnabled = true diff --git a/src/main.cpp b/src/main.cpp index 3e33b8c..d7e6306 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,25 +46,30 @@ #include "gridlines.h" #include "deviceinfo.h" #include "devicekeys.h" +#include "platformsettings.h" #ifdef QMLJSDEBUGGER #include "qt_private/qdeclarativedebughelper_p.h" #endif /* QMLJSDEBUGGER */ -static void initQuill() { - // TODO: All these are hardcoded. - Quill::setPreviewLevelCount(1); - Quill::setPreviewSize(0, QSize(854, 480)); - Quill::setMinimumPreviewSize(0, QSize(854, 480)); - Quill::setThumbnailExtension("jpeg"); - Quill::setThumbnailFlavorName(0, "screen"); - Quill::setBackgroundRenderingColor(Qt::black); - QString tempPath(QDir::homePath() + QDir::separator() + ".config" + - QDir::separator() + "quill" + QDir::separator() + "tmp"); +static void initQuill(PlatformSettings *settings) { + QList > previewLevels = settings->previewLevels(); + Quill::setPreviewLevelCount(previewLevels.size()); + + for (int x = 0; x < previewLevels.size(); x++) { + Quill::setThumbnailFlavorName(x, previewLevels[x].first); + Quill::setPreviewSize(x, previewLevels[x].second); + Quill::setMinimumPreviewSize(x, previewLevels[x].second); + } + + Quill::setThumbnailExtension(settings->thumbnailExtension()); + Quill::setBackgroundRenderingColor(settings->backgroundRenderingColor()); + Quill::setDBusThumbnailingEnabled(settings->isDBusThumbnailingEnabled()); + Quill::setThumbnailCreationEnabled(settings->isThumbnailCreationEnabled()); + + QString tempPath = settings->temporaryFilePath(); QDir().mkpath(tempPath); Quill::setTemporaryFilePath(tempPath); - Quill::setDBusThumbnailingEnabled(true); - Quill::setThumbnailCreationEnabled(true); } Q_DECL_EXPORT int main(int argc, char *argv[]) { @@ -75,9 +80,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) { QDeclarativeDebugHelper::enableDebugging(); #endif /* QMLJSDEBUGGER */ - // Let's initialize Quill: - initQuill(); - QDeclarativeView view; view.setAttribute(Qt::WA_NoSystemBackground); view.setViewport(new QGLWidget); @@ -85,6 +87,11 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) { view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); view.viewport()->setAttribute(Qt::WA_NoSystemBackground); + PlatformSettings platformSettings; + + // Let's initialize Quill: + initQuill(&platformSettings); + qmlRegisterType("CameraPlus", 1, 0, "Settings"); qmlRegisterType("CameraPlus", 1, 0, "FileNaming"); qmlRegisterType("CameraPlus", 1, 0, "QuillItem"); diff --git a/src/platformsettings.cpp b/src/platformsettings.cpp new file mode 100644 index 0000000..9122bed --- /dev/null +++ b/src/platformsettings.cpp @@ -0,0 +1,69 @@ +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012 Mohammed Sameer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "platformsettings.h" +#include +#include + +#define PATH "/usr/share/cameraplus/config/cameraplus.ini" + +#define PREVIEW_SIZE QSize(854, 480) +#define THUMBNAIL_FLAVOR_NAME QString("screen") +#define TEMPORARY_FILE_PATH "%1%2.config%2quill%2tmp" +#define THUMBNAIL_EXTENSION QString("jpeg") +#define THUMBNAIL_CREATION_ENABLED true +#define DBUS_THUMBNAILING_ENABLED true +#define BACKGROUND_RENDERING_COLOR QColor(Qt::black) + +PlatformSettings::PlatformSettings() : + QSettings(PATH, QSettings::IniFormat) { + +} + +PlatformSettings::~PlatformSettings() { + +} + +QList > PlatformSettings::previewLevels() { + return QList >() << + qMakePair(value("quill/thumbnailFlavorName", THUMBNAIL_FLAVOR_NAME).toString(), + value("quill/previewSize", PREVIEW_SIZE).toSize()); +} + +QString PlatformSettings::thumbnailExtension() { + return value("quill/thumbnailExtension", THUMBNAIL_EXTENSION).toString(); +} + +QColor PlatformSettings::backgroundRenderingColor() { + return value("quill/backgroundRenderingColor", BACKGROUND_RENDERING_COLOR).value(); +} + +bool PlatformSettings::isDBusThumbnailingEnabled() { + return value("quill/dbusThumbnailingEnabled", DBUS_THUMBNAILING_ENABLED).toBool(); +} + +bool PlatformSettings::isThumbnailCreationEnabled() { + return value("quill/thumbnailCreationEnabled", THUMBNAIL_CREATION_ENABLED).toBool(); +} + +QString PlatformSettings::temporaryFilePath() { + QString defaultPath = QString(TEMPORARY_FILE_PATH).arg(QDir::homePath()).arg(QDir::separator()); + return value("quill/temporaryFilePath", defaultPath).toString(); +} diff --git a/src/platformsettings.h b/src/platformsettings.h new file mode 100644 index 0000000..2c3ad9f --- /dev/null +++ b/src/platformsettings.h @@ -0,0 +1,43 @@ +// -*- c++ -*- + +/*! + * This file is part of CameraPlus. + * + * Copyright (C) 2012 Mohammed Sameer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PLATFORM_SETTINGS_H +#define PLATFORM_SETTINGS_H + +#include +#include + +class PlatformSettings : private QSettings { +public: + PlatformSettings(); + ~PlatformSettings(); + + QList > previewLevels(); + + QString thumbnailExtension(); + QColor backgroundRenderingColor(); + bool isDBusThumbnailingEnabled(); + bool isThumbnailCreationEnabled(); + QString temporaryFilePath(); +}; + +#endif /* PLATFORM_SETTINGS_H */ diff --git a/src/src.pro b/src/src.pro index f73043f..fbddb4d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -15,12 +15,14 @@ PKGCONFIG = quill qmsystem2 libresourceqt1 SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp fsmonitor.cpp \ cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \ trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \ - postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp devicekeys.cpp + postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp devicekeys.cpp \ + platformsettings.cpp HEADERS += settings.h filenaming.h quillitem.h displaystate.h fsmonitor.h \ cameraresources.h compass.h orientation.h geocode.h mountprotector.h \ trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h \ - postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h devicekeys.h + postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h devicekeys.h \ + platformsettings.h RESOURCES += ../qml/qml.qrc