Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial suppor for saving (full-size image, slow!)

  • Loading branch information...
commit c5bcc5f336e806772755e8e1165e0b7ec2b95eca 1 parent 2b2d08a
@thp thp authored
View
1  ClassicPrintDeclarative.cpp
@@ -2,4 +2,5 @@
#include "ClassicPrintDeclarative.h"
ClassicPrint *ClassicPrintDeclarative::classicPrint;
+QString ClassicPrintDeclarative::destinationFolder;
View
43 ClassicPrintDeclarative.h
@@ -10,6 +10,8 @@
#include "ClassicPrintFilm.h"
#include "ClassicPrintProcessing.h"
+#include "ClassicPrintThread.h"
+
class ClassicPrintDeclarative : public QObject {
Q_OBJECT
@@ -19,7 +21,9 @@ class ClassicPrintDeclarative : public QObject {
m_sequence(0),
m_timer(),
m_progress(0),
- m_working(false)
+ m_working(false),
+ m_thread(NULL),
+ m_saving(false)
{
m_timer.setInterval(500);
m_timer.setSingleShot(true);
@@ -79,6 +83,28 @@ class ClassicPrintDeclarative : public QObject {
}
+ Q_INVOKABLE
+ void save(QString filename) {
+ m_saving = true;
+ emit savingChanged();
+
+ if (m_thread != NULL) {
+ m_thread->wait();
+ delete m_thread;
+ }
+
+ QFileInfo fi(filename);
+ QString now = QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss");
+ QString destination = fi.baseName() + "_" + now + "." + fi.suffix();
+
+ m_thread = new ClassicPrintThread(getClassicPrint(),
+ filename, QDir(destinationFolder).filePath(destination));
+
+ QObject::connect(m_thread, SIGNAL(finished()),
+ this, SLOT(savingFinished()));
+
+ m_thread->start();
+ }
/* Lens */
@@ -266,6 +292,11 @@ class ClassicPrintDeclarative : public QObject {
bool working() { return m_working; }
Q_PROPERTY(bool working READ working NOTIFY workingChanged)
+ bool saving() { return m_saving; }
+ Q_PROPERTY(bool saving READ saving NOTIFY savingChanged)
+
+ static QString destinationFolder;
+
signals:
/* Lens */
void radiusChanged();
@@ -286,6 +317,7 @@ class ClassicPrintDeclarative : public QObject {
void sequenceChanged();
void progressChanged();
void workingChanged();
+ void savingChanged();
public slots:
void contentUpdated() {
@@ -308,6 +340,13 @@ class ClassicPrintDeclarative : public QObject {
}
}
+ void savingFinished() {
+ if (m_saving) {
+ m_saving = false;
+ emit savingChanged();
+ }
+ }
+
private:
static ClassicPrint *classicPrint;
@@ -315,6 +354,8 @@ class ClassicPrintDeclarative : public QObject {
QTimer m_timer;
int m_progress;
bool m_working;
+ ClassicPrintThread *m_thread;
+ bool m_saving;
};
#endif
View
34 ClassicPrintThread.h
@@ -0,0 +1,34 @@
+#ifndef CLASSICPRINTQML_CLASSICPRINTTHREAD_H
+#define CLASSICPRINTQML_CLASSICPRINTTHREAD_H
+
+#include <QtCore>
+
+#include "ClassicPrint.h"
+
+class ClassicPrintThread : public QThread {
+ public:
+ ClassicPrintThread(ClassicPrint *classicPrint,
+ QString sourceFilename,
+ QString destinationFilename,
+ QObject *parent=NULL)
+ : QThread(parent),
+ m_classicPrint(classicPrint),
+ m_sourceFilename(sourceFilename),
+ m_destinationFilename(destinationFilename)
+ {
+ }
+
+ void run() {
+ QImage source(m_sourceFilename);
+ QImage destination(source.size(), source.format());
+ m_classicPrint->process(source, 0, 0, destination);
+ destination.save(m_destinationFilename);
+ }
+
+ private:
+ ClassicPrint *m_classicPrint;
+ QString m_sourceFilename;
+ QString m_destinationFilename;
+};
+
+#endif
View
3  classicprintqml.cpp
@@ -21,9 +21,12 @@ int main(int argc, char *argv[])
#if defined(CLASSICPRINTQML_DESKTOP)
QDir dcim("/home/thp/Pictures/Webcam/");
+ ClassicPrintDeclarative::destinationFolder = "/home/thp/Desktop/Classic Print/";
#else
QDir dcim("/home/user/MyDocs/DCIM/");
+ ClassicPrintDeclarative::destinationFolder = "/home/user/MyDocs/Pictures/Classic Print/";
#endif
+ QDir(ClassicPrintDeclarative::destinationFolder).mkpath(".");
QStringList photos;
photos << "*.jpg";
View
20 classicprintqml.qml
@@ -8,6 +8,8 @@ import org.maemo.classicprint 1.0
PageStackWindow {
initialPage: listPage
+ showToolBar: !classicPrint.saving
+
ClassicPrint {
id: classicPrint
}
@@ -74,6 +76,7 @@ PageStackWindow {
Image {
id: displayImage
+ visible: !classicPrint.saving
asynchronous: true
property string filePath: ''
@@ -107,7 +110,18 @@ PageStackWindow {
}
}
+ Label {
+ anchors {
+ horizontalCenter: progressBar.horizontalCenter
+ bottom: progressBar.top
+ bottomMargin: 30
+ }
+ text: 'Saving photo...'
+ visible: classicPrint.saving
+ }
+
ProgressBar {
+ id: progressBar
anchors.centerIn: parent
width: parent.width * .9
visible: classicPrint.working
@@ -116,6 +130,7 @@ PageStackWindow {
Rectangle {
id: lensPane
+ visible: !classicPrint.saving
state: 'down'
@@ -209,6 +224,7 @@ PageStackWindow {
Rectangle {
id: filmPane
+ visible: !classicPrint.saving
state: 'down'
@@ -273,6 +289,7 @@ PageStackWindow {
Rectangle {
id: processingPane
+ visible: !classicPrint.saving
state: 'down'
@@ -374,7 +391,8 @@ PageStackWindow {
MenuLayout {
MenuItem {
- text: '...'
+ text: 'Save'
+ onClicked: classicPrint.save(displayImage.filePath);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.