- Moved the resource URL inside the QML app
- Updated local path for all the platforms - Fixed local path creation problem on Linux
This commit is contained in:
@@ -15,15 +15,18 @@ class FileDownloader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool done READ isDone NOTIFY downloaded)
|
Q_PROPERTY(bool done READ isDone NOTIFY downloaded)
|
||||||
Q_PROPERTY(qint64 received READ received NOTIFY receivedChanged)
|
Q_PROPERTY(qint64 received READ received NOTIFY receivedChanged)
|
||||||
|
Q_PROPERTY(QUrl url READ getDownloadUrl WRITE setDownloadUrl NOTIFY downloadUrlChanged)
|
||||||
public:
|
public:
|
||||||
explicit FileDownloader(QUrl url, QString localPath, QObject *parent = 0);
|
explicit FileDownloader(QString localPath, QUrl url=QUrl(""), QObject *parent = 0);
|
||||||
virtual ~FileDownloader();
|
virtual ~FileDownloader();
|
||||||
qint64 received() const {return m_received;};
|
qint64 received() const {return m_received;};
|
||||||
bool isDone() {return m_done;};
|
bool isDone() {return m_done;};
|
||||||
|
QUrl getDownloadUrl() {return m_downloadUrl;};
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void downloaded();
|
void downloaded();
|
||||||
void receivedChanged();
|
void receivedChanged();
|
||||||
|
void downloadUrlChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fileDownloaded(QNetworkReply* pReply){
|
void fileDownloaded(QNetworkReply* pReply){
|
||||||
@@ -41,6 +44,7 @@ private slots:
|
|||||||
m_received = bytesReceived*100/bytesTotal;
|
m_received = bytesReceived*100/bytesTotal;
|
||||||
emit receivedChanged();
|
emit receivedChanged();
|
||||||
};
|
};
|
||||||
|
void setDownloadUrl(QUrl url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -48,6 +52,7 @@ private:
|
|||||||
qint64 m_received;
|
qint64 m_received;
|
||||||
QTemporaryFile m_tmp;
|
QTemporaryFile m_tmp;
|
||||||
QString m_localPath;
|
QString m_localPath;
|
||||||
|
QUrl m_downloadUrl;
|
||||||
bool m_OK;
|
bool m_OK;
|
||||||
bool m_done;
|
bool m_done;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,9 +116,10 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
|||||||
userPath = "/sdcard/Wagic/Res/";
|
userPath = "/sdcard/Wagic/Res/";
|
||||||
systemPath = "";
|
systemPath = "";
|
||||||
#elif defined (QT_CONFIG)
|
#elif defined (QT_CONFIG)
|
||||||
// userPath = USERDIR;
|
QDir dir(QDir::homePath());
|
||||||
// systemPath = RESDIR;
|
dir.cd(USERDIR);
|
||||||
userPath = QDir::toNativeSeparators(QDir::homePath()).toStdString() + "/.wagic/";
|
|
||||||
|
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
|
||||||
systemPath = "";
|
systemPath = "";
|
||||||
#else
|
#else
|
||||||
//Find the Res.txt file and matching Res folders for backwards compatibility
|
//Find the Res.txt file and matching Res folders for backwards compatibility
|
||||||
|
|||||||
+2
-3
@@ -629,14 +629,13 @@ int main(int argc, char* argv[])
|
|||||||
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
||||||
app->setApplicationName(g_launcher->GetName());
|
app->setApplicationName(g_launcher->GetName());
|
||||||
|
|
||||||
FileDownloader fileDownloader(QUrl("http://wagic.googlecode.com/files/core_017.zip"),
|
FileDownloader fileDownloader(USERDIR);
|
||||||
QDir::toNativeSeparators(QDir::homePath()) + "/.wagic/core_017.zip", 0);
|
|
||||||
|
|
||||||
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
|
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
|
||||||
g_glwidget = viewer.data();
|
g_glwidget = viewer.data();
|
||||||
viewer->setMainQmlFile(QLatin1String("qml/QmlWagic/main.qml"));
|
|
||||||
|
|
||||||
viewer->rootContext()->setContextProperty("fileDownloader", &fileDownloader);
|
viewer->rootContext()->setContextProperty("fileDownloader", &fileDownloader);
|
||||||
|
viewer->setMainQmlFile(QLatin1String("qml/QmlWagic/main.qml"));
|
||||||
|
|
||||||
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
|
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
|
||||||
QGLWidget *glWidget = new QGLWidget;
|
QGLWidget *glWidget = new QGLWidget;
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ WagicCore::~WagicCore()
|
|||||||
m_launcher = NULL;
|
m_launcher = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_engine)
|
||||||
m_engine->SetApp(NULL);
|
m_engine->SetApp(NULL);
|
||||||
|
|
||||||
if (m_app)
|
if (m_app)
|
||||||
{
|
{
|
||||||
m_app->Destroy();
|
m_app->Destroy();
|
||||||
|
|||||||
@@ -1,14 +1,30 @@
|
|||||||
#include "filedownloader.h"
|
#include "filedownloader.h"
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
FileDownloader::FileDownloader(QUrl url, QString localPath, QObject *parent) :
|
FileDownloader::FileDownloader(QString localPath, QUrl url, QObject *parent) :
|
||||||
QObject(parent), m_received(0), m_localPath(localPath), m_OK(false), m_done(false)
|
QObject(parent), m_received(0), m_OK(false), m_done(false)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
QDir dir(QDir::homePath());
|
||||||
|
if(!dir.mkpath(localPath))
|
||||||
|
{
|
||||||
|
m_OK = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dir.cd(localPath);
|
||||||
|
m_localPath = dir.filePath("core.zip");
|
||||||
|
|
||||||
QFile local(m_localPath);
|
QFile local(m_localPath);
|
||||||
if(local.exists()) {
|
if(local.exists()) {
|
||||||
m_done = true;
|
m_done = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!url.isEmpty())
|
||||||
|
setDownloadUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileDownloader::setDownloadUrl(QUrl url)
|
||||||
|
{
|
||||||
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
|
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(fileDownloaded(QNetworkReply*)));
|
SLOT(fileDownloaded(QNetworkReply*)));
|
||||||
|
|
||||||
@@ -21,6 +37,7 @@ FileDownloader::FileDownloader(QUrl url, QString localPath, QObject *parent) :
|
|||||||
m_OK = m_tmp.open();
|
m_OK = m_tmp.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileDownloader::~FileDownloader()
|
FileDownloader::~FileDownloader()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ Rectangle {
|
|||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: wagic; visible: false
|
target: wagic; visible: false
|
||||||
}
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target:fileDownloader; url: "http://wagic.googlecode.com/files/core_017.zip"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "NORMAL"
|
name: "NORMAL"
|
||||||
|
|||||||
@@ -373,8 +373,11 @@ maemo5: {
|
|||||||
# Variables
|
# Variables
|
||||||
BINDIR = /opt/wagic
|
BINDIR = /opt/wagic
|
||||||
RESDIR = /home/user/wagic/Res
|
RESDIR = /home/user/wagic/Res
|
||||||
|
USERDIR = MyDocs/.Wagic
|
||||||
ICONDIR = /usr/share
|
ICONDIR = /usr/share
|
||||||
|
|
||||||
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
||||||
|
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
||||||
|
|
||||||
INSTALLS += target \
|
INSTALLS += target \
|
||||||
desktop \
|
desktop \
|
||||||
@@ -407,7 +410,7 @@ maemo5: {
|
|||||||
# Variables
|
# Variables
|
||||||
BINDIR = /opt/wagic/bin
|
BINDIR = /opt/wagic/bin
|
||||||
RESDIR = /opt/wagic/Res
|
RESDIR = /opt/wagic/Res
|
||||||
USERDIR = /home/user/MyDocs/.Wagic
|
USERDIR = MyDocs/.Wagic
|
||||||
ICONDIR = /usr/share
|
ICONDIR = /usr/share
|
||||||
|
|
||||||
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
||||||
@@ -443,7 +446,7 @@ maemo5: {
|
|||||||
TARGET.CAPABILITY += NetworkServices
|
TARGET.CAPABILITY += NetworkServices
|
||||||
|
|
||||||
RESDIR = some/res/dir
|
RESDIR = some/res/dir
|
||||||
USERDIR = some/user/dir
|
USERDIR = .Wagic
|
||||||
DEFINES += RESDIR=\"$$RESDIR\"
|
DEFINES += RESDIR=\"$$RESDIR\"
|
||||||
DEFINES += USERDIR=\"$$USERDIR\"
|
DEFINES += USERDIR=\"$$USERDIR\"
|
||||||
|
|
||||||
@@ -455,13 +458,13 @@ maemo5: {
|
|||||||
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
||||||
} else:unix {
|
} else:unix {
|
||||||
RESDIR = Res
|
RESDIR = Res
|
||||||
USERDIR = ~/.Wagic
|
USERDIR = .Wagic
|
||||||
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
||||||
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
||||||
|
|
||||||
} else:windows {
|
} else:windows {
|
||||||
RESDIR = ./Res
|
RESDIR = ./Res
|
||||||
USERDIR = ./user
|
USERDIR = .Wagic
|
||||||
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
||||||
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
DEFINES += USERDIR=\\\"$$USERDIR\\\"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user