- implemented the swipe and touch logic in QML

- Added a SHA1 hash verification of the downloaded resource file
- Fixed the activation/deactivation of the QML UI to avoid burning the battery
This commit is contained in:
Xawotihs
2012-01-07 20:41:43 +00:00
parent 436f95dfec
commit 26738af904
5 changed files with 105 additions and 40 deletions

View File

@@ -49,6 +49,12 @@ public:
}
};
Q_INVOKABLE void pixelInput(int x, int y);
Q_INVOKABLE qint64 getTick() {
return g_startTimer.elapsed();
};
Q_INVOKABLE void doScroll(int x, int y) {
m_engine->Scroll(x, y);
};
int getNominalHeight(){ return SCREEN_HEIGHT;};
int getNominalWidth(){ return SCREEN_WIDTH;};
float getNominalRatio() { return ((float)SCREEN_WIDTH / (float)SCREEN_HEIGHT);};

View File

@@ -13,38 +13,38 @@
class FileDownloader : public QObject
{
Q_OBJECT
Q_PROPERTY(bool done READ isDone NOTIFY downloaded)
Q_PROPERTY(qint64 received READ received NOTIFY receivedChanged)
Q_PROPERTY(QUrl url READ getDownloadUrl WRITE setDownloadUrl NOTIFY downloadUrlChanged)
Q_PROPERTY(QString hash READ getHash NOTIFY hashChanged)
public:
explicit FileDownloader(QString localPath, QUrl url=QUrl(""), QObject *parent = 0);
explicit FileDownloader(QString localPath, QObject *parent = 0);
virtual ~FileDownloader();
qint64 received() const {return m_received;};
bool isDone() {return m_done;};
QUrl getDownloadUrl() {return m_downloadUrl;};
QString getHash() {return m_hash;};
signals:
void downloaded();
void receivedChanged();
void downloadUrlChanged();
void hashChanged();
private slots:
void fileDownloaded(QNetworkReply* pReply){
if(m_tmp.write(pReply->readAll()) == -1) return;
if(QFile(m_localPath).exists())
QFile::remove(m_localPath);
if(!m_tmp.rename(m_localPath)) return;
computeHash(m_tmp);
m_tmp.setAutoRemove(false);
m_done = true;
//emit a signal
emit downloaded();
};
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal){
m_received = bytesReceived*100/bytesTotal;
emit receivedChanged();
};
void setDownloadUrl(QUrl url);
void computeHash(QFile& file);
private:
@@ -53,8 +53,8 @@ private:
QTemporaryFile m_tmp;
QString m_localPath;
QUrl m_downloadUrl;
QString m_hash;
bool m_OK;
bool m_done;
};
QML_DECLARE_TYPEINFO(FileDownloader, QML_HAS_ATTACHED_PROPERTIES)