--- /dev/null
+[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
#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<QPair<QString, QSize> > 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[]) {
QDeclarativeDebugHelper::enableDebugging();
#endif /* QMLJSDEBUGGER */
- // Let's initialize Quill:
- initQuill();
-
QDeclarativeView view;
view.setAttribute(Qt::WA_NoSystemBackground);
view.setViewport(new QGLWidget);
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
view.viewport()->setAttribute(Qt::WA_NoSystemBackground);
+ PlatformSettings platformSettings;
+
+ // Let's initialize Quill:
+ initQuill(&platformSettings);
+
qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * 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 <QDir>
+#include <QSize>
+
+#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<QPair<QString, QSize> > PlatformSettings::previewLevels() {
+ return QList<QPair<QString, QSize> >() <<
+ qMakePair<QString, QSize>(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<QColor>();
+}
+
+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();
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * 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 <QSettings>
+#include <QColor>
+
+class PlatformSettings : private QSettings {
+public:
+ PlatformSettings();
+ ~PlatformSettings();
+
+ QList<QPair<QString, QSize> > previewLevels();
+
+ QString thumbnailExtension();
+ QColor backgroundRenderingColor();
+ bool isDBusThumbnailingEnabled();
+ bool isThumbnailCreationEnabled();
+ QString temporaryFilePath();
+};
+
+#endif /* PLATFORM_SETTINGS_H */
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