Skip to content
Browse files

Progress bar and faster fileModel loading

  • Loading branch information...
1 parent 1bf2e50 commit 2b2d08aabb47523104a9d2cef010c8cc68e6e95e @thp thp committed May 19, 2012
Showing with 52 additions and 17 deletions.
  1. +33 −1 ClassicPrintDeclarative.h
  2. +7 −0 classicprint-0.1/ClassicPrint.cpp
  3. +2 −0 classicprint-0.1/ClassicPrint.h
  4. +4 −11 classicprintqml.cpp
  5. +6 −5 classicprintqml.qml
View
34 ClassicPrintDeclarative.h
@@ -17,7 +17,9 @@ class ClassicPrintDeclarative : public QObject {
ClassicPrintDeclarative(QObject *parent=NULL)
: QObject(parent),
m_sequence(0),
- m_timer()
+ m_timer(),
+ m_progress(0),
+ m_working(false)
{
m_timer.setInterval(500);
m_timer.setSingleShot(true);
@@ -57,6 +59,12 @@ class ClassicPrintDeclarative : public QObject {
QObject::connect(this, SIGNAL(lightLeakChanged()),
this, SLOT(contentUpdated()));
+
+
+ QObject::connect(getClassicPrint(), SIGNAL(progress(int)),
+ this, SLOT(onProgress(int)));
+ QObject::connect(getClassicPrint(), SIGNAL(working(bool)),
+ this, SLOT(onWorking(bool)));
}
static void init() {
@@ -252,6 +260,12 @@ class ClassicPrintDeclarative : public QObject {
int sequence() { return m_sequence; }
Q_PROPERTY(int sequence READ sequence NOTIFY sequenceChanged)
+ int progress() { return m_progress; }
+ Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
+
+ bool working() { return m_working; }
+ Q_PROPERTY(bool working READ working NOTIFY workingChanged)
+
signals:
/* Lens */
void radiusChanged();
@@ -270,6 +284,8 @@ class ClassicPrintDeclarative : public QObject {
void lightLeakChanged();
void sequenceChanged();
+ void progressChanged();
+ void workingChanged();
public slots:
void contentUpdated() {
@@ -278,11 +294,27 @@ class ClassicPrintDeclarative : public QObject {
m_timer.start();
}
+ void onProgress(int progress) {
+ if (progress != m_progress) {
+ m_progress = progress;
+ emit progressChanged();
+ }
+ }
+
+ void onWorking(bool working) {
+ if (working != m_working) {
+ m_working = working;
+ emit workingChanged();
+ }
+ }
+
private:
static ClassicPrint *classicPrint;
int m_sequence;
QTimer m_timer;
+ int m_progress;
+ bool m_working;
};
#endif
View
7 classicprint-0.1/ClassicPrint.cpp
@@ -83,6 +83,13 @@ ClassicPrint::~ClassicPrint() {
** @return True/False
*/
bool ClassicPrint::process(const QImage& photo, int width, int height, QImage& processed) {
+ emit working(true);
+ bool result = process_real(photo, width, height, processed);
+ emit working(false);
+ return result;
+}
+
+bool ClassicPrint::process_real(const QImage& photo, int width, int height, QImage& processed) {
if (!m_current_lens || !m_current_film || !m_current_processing) {
return false;
}
View
2 classicprint-0.1/ClassicPrint.h
@@ -64,6 +64,7 @@ class ClassicPrint : public QObject {
**
** @return True/False
*/
+ bool process_real(const QImage& photo, int width, int height, QImage& processed);
bool process(const QImage& photo, int width, int height, QImage& processed);
//---------------------------------------------------------------------------
@@ -327,6 +328,7 @@ class ClassicPrint : public QObject {
signals:
void progress(int percent);
+ void working(bool working);
private slots:
void progress_lens(int percent);
View
15 classicprintqml.cpp
@@ -6,7 +6,7 @@
#include "ClassicPrintProvider.h"
#include "ClassicPrintDeclarative.h"
-#define CLASSICPRINTQML_DESKTOP
+//#define CLASSICPRINTQML_DESKTOP
int main(int argc, char *argv[])
{
@@ -19,24 +19,17 @@ int main(int argc, char *argv[])
ClassicPrintProvider::addToView(&view);
- QStringList fileModel;
-
-
#if defined(CLASSICPRINTQML_DESKTOP)
QDir dcim("/home/thp/Pictures/Webcam/");
#else
QDir dcim("/home/user/MyDocs/DCIM/");
#endif
QStringList photos;
- photos << "*.jpg" << "*.png";
-
- QStringList fileNames = dcim.entryList(photos, QDir::Files, QDir::Time);
- QString fileName;
- foreach (fileName, fileNames) {
- fileModel << (dcim.absolutePath() + "/" + fileName);
- }
+ photos << "*.jpg";
+ QStringList fileModel = dcim.entryList(photos, QDir::Files, QDir::Time);
+ view.rootContext()->setContextProperty("dcimFolder", dcim.absolutePath());
view.rootContext()->setContextProperty("fileModel", fileModel);
view.setSource(QUrl("qrc:/classicprintqml.qml"));
#if defined(CLASSICPRINTQML_DESKTOP)
View
11 classicprintqml.qml
@@ -27,7 +27,7 @@ PageStackWindow {
spacing: 10
delegate: Image {
- source: 'file://' + modelData
+ source: 'file://' + dcimFolder + '/' + modelData
asynchronous: true
fillMode: Image.PreserveAspectFit
@@ -42,7 +42,7 @@ PageStackWindow {
anchors.fill: parent
onClicked: {
- displayImage.filePath = modelData;
+ displayImage.filePath = dcimFolder + '/' + modelData;
pageStack.push(imagePage);
}
}
@@ -107,10 +107,11 @@ PageStackWindow {
}
}
- BusyIndicator {
+ ProgressBar {
anchors.centerIn: parent
- running: visible
- visible: displayImage.status == Image.Loading
+ width: parent.width * .9
+ visible: classicPrint.working
+ value: classicPrint.progress / 100.
}
Rectangle {

0 comments on commit 2b2d08a

Please sign in to comment.
Something went wrong with that request. Please try again.