// }
}
- // TODO: filenaming.
+ Button {
+ id: cameraRoll
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.topMargin: 20
+ anchors.rightMargin: 20
+ width: 56
+ height: 56
+
+ opacity: 0.5
+ iconSource: "image://theme/icon-m-camera-roll"
+ onClicked: openFile("PostCapturePage.qml");
+ visible: controlsVisible
+ }
+
// TODO: metadata
}
--- /dev/null
+// -*- qml -*-
+import QtQuick 1.1
+import com.nokia.meego 1.1
+import QtCamera 1.0
+import QtSparql 1.0
+import CameraPlus 1.0
+
+// QML QtGallery stuff is crap.
+// Most of the ideas (and some code) for loading and displaying images are stolen from
+// N9QmlPhotoPicker https://github.com/petrumotrescu/N9QmlPhotoPicker
+
+// TODO: this is really basic.
+
+Page {
+ id: page
+ property Camera cam: null
+
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ }
+
+ ListView {
+ // TODO: ListView does not loop and seems one has to use PathView.
+ id: view
+ anchors.fill: parent
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem
+ cacheBuffer: view.width * 2
+
+ model: SparqlListModel {
+ query: "SELECT nie:url(?urn) AS ?url tracker:id(?urn) AS ?trackerid nie:mimeType(?urn) AS mimeType WHERE { ?urn rdf:type nfo:Media . ?urn nfo:equipment \"urn:equipment:Nokia:N950:\" ; tracker:available \"true\"^^xsd:boolean } ORDER BY DESC (?created)"
+
+ connection: SparqlConnection {
+ id: connection
+ driver: "QTRACKER_DIRECT"
+ onStatusChanged: checkStatus(status)
+
+ function checkStatus(status) {
+ if (status == SparqlConnection.Error)
+ console.log("Error = "+connection.errorString());
+ }
+ }
+ }
+
+ delegate: QuillItem {
+ source: url
+ width: view.width
+ height: view.height
+ // TODO: does not work because of preloading
+// onError: showError(qsTr("Failed to load image"));
+ }
+ }
+
+ ToolBar {
+ id: toolBar
+ opacity: 0.8
+ anchors.bottom: parent.bottom
+ tools: ToolBarLayout {
+ id: layout
+ ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
+ }
+ }
+}
anchors.topMargin: 10
anchors.leftMargin: 20
}
+
+ Button {
+ id: cameraRoll
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.topMargin: 20
+ anchors.rightMargin: 20
+ width: 56
+ height: 56
+
+ opacity: 0.5
+ iconSource: "image://theme/icon-m-camera-roll"
+ onClicked: openFile("PostCapturePage.qml");
+ visible: controlsVisible && !videoMode.recording
+ }
}
#include "settings.h"
#include "filenaming.h"
+#import "quillitem.h"
Q_DECL_EXPORT int main(int argc, char *argv[]) {
XInitThreads();
Plugin::registerTypes(view.engine());
qmlRegisterType<Settings>("CameraPlus", 1, 0, "Settings");
qmlRegisterType<FileNaming>("CameraPlus", 1, 0, "FileNaming");
+ qmlRegisterType<QuillItem>("CameraPlus", 1, 0, "QuillItem");
QUrl sourceUrl = QUrl::fromLocalFile(QDir::currentPath() + "/main.qml");
view.setSource(sourceUrl);
--- /dev/null
+#include "quillitem.h"
+#include <QuillFile>
+#include <QUrl>
+#include <QPainter>
+#include <QStyleOptionGraphicsItem>
+#include <QDir>
+
+QuillItem::QuillItem(QDeclarativeItem *parent) :
+ QDeclarativeItem(parent), m_file(0) {
+
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+
+ static bool init = false;
+ if (!init) {
+ Quill::setPreviewLevelCount(1);
+ Quill::setPreviewSize(0, QSize(864, 480)); // TODO:
+ Quill::setMinimumPreviewSize(0, QSize(864, 480)); // TODO:
+ Quill::setThumbnailExtension("jpeg"); // TODO:
+ Quill::setThumbnailFlavorName(0, "screen");
+ Quill::setBackgroundRenderingColor(Qt::black);
+ QString tempPath(QDir::homePath() + QDir::separator() + ".config" +
+ QDir::separator() + "quill" + QDir::separator() + "tmp");
+ QDir().mkpath(tempPath);
+ Quill::setTemporaryFilePath(tempPath);
+ init = true;
+ }
+}
+
+QuillItem::~QuillItem() {
+ delete m_file; m_file = 0;
+}
+
+QUrl QuillItem::source() const {
+ if (m_file) {
+ return QUrl::fromLocalFile(m_file->fileName());
+ }
+
+ return QUrl();
+}
+
+void QuillItem::setSource(const QUrl& src) {
+ if (src == source()) {
+ return;
+ }
+
+ if (m_file) {
+ m_file->deleteLater();
+ }
+
+ m_file = new QuillFile(src.toLocalFile());
+
+ QObject::connect(m_file, SIGNAL(error(QuillError)),
+ this, SLOT(fileError()), Qt::QueuedConnection);
+ QObject::connect(m_file, SIGNAL(imageAvailable(QuillImageList)),
+ this, SLOT(fileLoaded()), Qt::QueuedConnection);
+ QObject::connect(m_file, SIGNAL(removed()),
+ m_file, SLOT(deleteLater()), Qt::QueuedConnection);
+
+ if (fileError()) {
+ return;
+ }
+
+ m_file->setDisplayLevel(0);
+
+ if (fileError()) {
+ return;
+ }
+
+ emit sourceChanged();
+}
+
+void QuillItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
+ Q_UNUSED(widget);
+
+ if (!m_file) {
+ return;
+ }
+
+ QImage image = m_file->image(0);
+
+ if (!image.isNull()) {
+ painter->drawImage(option->rect, image);
+ }
+}
+
+void QuillItem::fileLoaded() {
+ update();
+}
+
+bool QuillItem::fileError() {
+ if (!m_file) {
+ return true;
+ }
+
+ QuillError err = m_file->error();
+ if (err.errorCode() != QuillError::NoError) {
+ qWarning() << "Error loading file" << m_file->fileName() << err.errorData();
+
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(QString, err.errorData()));
+ m_file->deleteLater(); m_file = 0;
+ return true;
+ }
+
+ return false;
+}
--- /dev/null
+// -*- c++ -*-
+
+#ifndef QUILL_ITEM_H
+#define QUILL_ITEM_H
+
+#include <QDeclarativeItem>
+
+class QuillFile;
+
+class QuillItem : public QDeclarativeItem {
+ Q_OBJECT
+
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged);
+
+public:
+ QuillItem(QDeclarativeItem *parent = 0);
+ ~QuillItem();
+
+ QUrl source() const;
+ void setSource(const QUrl& src);
+
+ void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+
+signals:
+ void sourceChanged();
+ void error(const QString& err);
+
+private slots:
+ void fileLoaded();
+ bool fileError();
+
+private:
+ QuillFile *m_file;
+};
+
+#endif /* QUILL_ITEM_H */
CONFIG += link_pkgconfig debug static
PKGCONFIG = gstreamer-0.10 gstreamer-interfaces-0.10 gstreamer-video-0.10 gstreamer-tag-0.10 \
- gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10
+ gstreamer-pbutils-0.10 meego-gstreamer-interfaces-0.10 quill
LIBS += -L../imports/ -limports -L../lib/ -lqtcamera
-SOURCES += main.cpp settings.cpp filenaming.cpp
-HEADERS += settings.h filenaming.h
+SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp
+HEADERS += settings.h filenaming.h quillitem.h