- 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:
Xawotihs
2012-01-06 23:54:57 +00:00
parent 1f3aedcd3f
commit d9625ed034
7 changed files with 46 additions and 16 deletions

View File

@@ -15,15 +15,18 @@ 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)
public:
explicit FileDownloader(QUrl url, QString localPath, QObject *parent = 0);
explicit FileDownloader(QString localPath, QUrl url=QUrl(""), QObject *parent = 0);
virtual ~FileDownloader();
qint64 received() const {return m_received;};
bool isDone() {return m_done;};
QUrl getDownloadUrl() {return m_downloadUrl;};
signals:
void downloaded();
void receivedChanged();
void downloadUrlChanged();
private slots:
void fileDownloaded(QNetworkReply* pReply){
@@ -41,6 +44,7 @@ private slots:
m_received = bytesReceived*100/bytesTotal;
emit receivedChanged();
};
void setDownloadUrl(QUrl url);
private:
@@ -48,6 +52,7 @@ private:
qint64 m_received;
QTemporaryFile m_tmp;
QString m_localPath;
QUrl m_downloadUrl;
bool m_OK;
bool m_done;
};

View File

@@ -116,10 +116,11 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
userPath = "/sdcard/Wagic/Res/";
systemPath = "";
#elif defined (QT_CONFIG)
// userPath = USERDIR;
// systemPath = RESDIR;
userPath = QDir::toNativeSeparators(QDir::homePath()).toStdString() + "/.wagic/";
systemPath = "";
QDir dir(QDir::homePath());
dir.cd(USERDIR);
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = "";
#else
//Find the Res.txt file and matching Res folders for backwards compatibility
ifstream mfile("Res.txt");

View File

@@ -629,14 +629,13 @@ int main(int argc, char* argv[])
QScopedPointer<QApplication> app(createApplication(argc, argv));
app->setApplicationName(g_launcher->GetName());
FileDownloader fileDownloader(QUrl("http://wagic.googlecode.com/files/core_017.zip"),
QDir::toNativeSeparators(QDir::homePath()) + "/.wagic/core_017.zip", 0);
FileDownloader fileDownloader(USERDIR);
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
g_glwidget = viewer.data();
viewer->setMainQmlFile(QLatin1String("qml/QmlWagic/main.qml"));
viewer->rootContext()->setContextProperty("fileDownloader", &fileDownloader);
viewer->setMainQmlFile(QLatin1String("qml/QmlWagic/main.qml"));
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
QGLWidget *glWidget = new QGLWidget;

View File

@@ -78,7 +78,9 @@ WagicCore::~WagicCore()
m_launcher = NULL;
}
m_engine->SetApp(NULL);
if(m_engine)
m_engine->SetApp(NULL);
if (m_app)
{
m_app->Destroy();

View File

@@ -1,14 +1,30 @@
#include "filedownloader.h"
#include <QDir>
FileDownloader::FileDownloader(QUrl url, QString localPath, QObject *parent) :
QObject(parent), m_received(0), m_localPath(localPath), m_OK(false), m_done(false)
FileDownloader::FileDownloader(QString localPath, QUrl url, QObject *parent) :
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);
if(local.exists()) {
m_done = true;
return;
}
if(!url.isEmpty())
setDownloadUrl(url);
}
void FileDownloader::setDownloadUrl(QUrl url)
{
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
SLOT(fileDownloaded(QNetworkReply*)));
@@ -21,7 +37,8 @@ FileDownloader::FileDownloader(QUrl url, QString localPath, QObject *parent) :
m_OK = m_tmp.open();
}
FileDownloader::~FileDownloader()
{
}
}

View File

@@ -17,6 +17,9 @@ Rectangle {
PropertyChanges {
target: wagic; visible: false
}
PropertyChanges {
target:fileDownloader; url: "http://wagic.googlecode.com/files/core_017.zip"
}
},
State {
name: "NORMAL"

View File

@@ -373,8 +373,11 @@ maemo5: {
# Variables
BINDIR = /opt/wagic
RESDIR = /home/user/wagic/Res
USERDIR = MyDocs/.Wagic
ICONDIR = /usr/share
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
INSTALLS += target \
desktop \
@@ -407,7 +410,7 @@ maemo5: {
# Variables
BINDIR = /opt/wagic/bin
RESDIR = /opt/wagic/Res
USERDIR = /home/user/MyDocs/.Wagic
USERDIR = MyDocs/.Wagic
ICONDIR = /usr/share
DEFINES += RESDIR=\\\"$$RESDIR\\\"
@@ -443,7 +446,7 @@ maemo5: {
TARGET.CAPABILITY += NetworkServices
RESDIR = some/res/dir
USERDIR = some/user/dir
USERDIR = .Wagic
DEFINES += RESDIR=\"$$RESDIR\"
DEFINES += USERDIR=\"$$USERDIR\"
@@ -455,13 +458,13 @@ maemo5: {
DEFINES += USERDIR=\\\"$$USERDIR\\\"
} else:unix {
RESDIR = Res
USERDIR = ~/.Wagic
USERDIR = .Wagic
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
} else:windows {
RESDIR = ./Res
USERDIR = ./user
USERDIR = .Wagic
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
}