mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-11 06:02:37 -05:00
If caching is disabled, still cache theme info and images in a temporary directory (which will be deleted once rbutil is closed) to prevent downling them every time the theme selection changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14704 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e6b8347a4d
commit
554f0c3771
7 changed files with 106 additions and 37 deletions
|
|
@ -23,7 +23,7 @@
|
||||||
#include "installthemes.h"
|
#include "installthemes.h"
|
||||||
#include "installzip.h"
|
#include "installzip.h"
|
||||||
#include "progressloggergui.h"
|
#include "progressloggergui.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
|
ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -37,6 +37,11 @@ ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
|
||||||
connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
|
connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThemesInstallWindow::~ThemesInstallWindow()
|
||||||
|
{
|
||||||
|
if(infocachedir!="")
|
||||||
|
recRmdir(infocachedir);
|
||||||
|
}
|
||||||
|
|
||||||
QString ThemesInstallWindow::resolution()
|
QString ThemesInstallWindow::resolution()
|
||||||
{
|
{
|
||||||
|
|
@ -186,6 +191,16 @@ void ThemesInstallWindow::updateDetails(int row)
|
||||||
igetter.setProxy(proxy);
|
igetter.setProxy(proxy);
|
||||||
if(!userSettings->value("cachedisable").toBool())
|
if(!userSettings->value("cachedisable").toBool())
|
||||||
igetter.setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
|
igetter.setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(infocachedir=="")
|
||||||
|
{
|
||||||
|
infocachedir = QDir::tempPath()+"rbutil-themeinfo";
|
||||||
|
QDir d = QDir::temp();
|
||||||
|
d.mkdir("rbutil-themeinfo");
|
||||||
|
}
|
||||||
|
igetter.setCache(infocachedir);
|
||||||
|
}
|
||||||
igetter.getFile(img);
|
igetter.getFile(img);
|
||||||
connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool)));
|
connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class ThemesInstallWindow : public QDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThemesInstallWindow(QWidget* parent = 0);
|
ThemesInstallWindow(QWidget* parent = 0);
|
||||||
|
~ThemesInstallWindow();
|
||||||
void setDeviceSettings(QSettings*);
|
void setDeviceSettings(QSettings*);
|
||||||
void setUserSettings(QSettings *);
|
void setUserSettings(QSettings *);
|
||||||
void setProxy(QUrl);
|
void setProxy(QUrl);
|
||||||
|
|
@ -60,6 +61,8 @@ class ThemesInstallWindow : public QDialog
|
||||||
QString file;
|
QString file;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
|
||||||
|
QString infocachedir;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void downloadDone(bool);
|
void downloadDone(bool);
|
||||||
void downloadDone(int, bool);
|
void downloadDone(int, bool);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ SOURCES += rbutilqt.cpp \
|
||||||
installthemes.cpp \
|
installthemes.cpp \
|
||||||
uninstall.cpp \
|
uninstall.cpp \
|
||||||
uninstallwindow.cpp \
|
uninstallwindow.cpp \
|
||||||
|
utils.cpp \
|
||||||
browseof.cpp \
|
browseof.cpp \
|
||||||
preview.cpp
|
preview.cpp
|
||||||
|
|
||||||
|
|
@ -68,6 +69,7 @@ HEADERS += rbutilqt.h \
|
||||||
installthemes.h \
|
installthemes.h \
|
||||||
uninstall.h \
|
uninstall.h \
|
||||||
uninstallwindow.h \
|
uninstallwindow.h \
|
||||||
|
utils.h \
|
||||||
browseof.h \
|
browseof.h \
|
||||||
preview.h
|
preview.h
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "uninstall.h"
|
#include "uninstall.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
|
Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -37,29 +37,6 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
|
||||||
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
|
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
|
||||||
m_dp->abort();
|
m_dp->abort();
|
||||||
}
|
}
|
||||||
// recursiv function to delete a dir with files
|
|
||||||
bool Uninstaller::recRmdir( QString &dirName )
|
|
||||||
{
|
|
||||||
QString dirN = dirName;
|
|
||||||
QDir dir(dirN);
|
|
||||||
QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
|
|
||||||
QFileInfo fileInfo;
|
|
||||||
QString curItem, lstAt;
|
|
||||||
for(int i = 0; i < list.size(); i++){ // loop through all items of list
|
|
||||||
QString name = list.at(i);
|
|
||||||
if(!(name == ".") && !(name == "..")){
|
|
||||||
curItem = dirN + "/" + name;
|
|
||||||
fileInfo.setFile(curItem);
|
|
||||||
if(fileInfo.isDir()) // is directory
|
|
||||||
recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
|
|
||||||
else // is file
|
|
||||||
QFile::remove(curItem); // ok, delete file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dir.cdUp();
|
|
||||||
return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Uninstaller::uninstall(ProgressloggerInterface* dp)
|
void Uninstaller::uninstall(ProgressloggerInterface* dp)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ private slots:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool recRmdir( QString &dirName );
|
|
||||||
|
|
||||||
QString m_mountpoint;
|
QString m_mountpoint;
|
||||||
|
|
||||||
QStringList uninstallSections;
|
QStringList uninstallSections;
|
||||||
|
|
|
||||||
45
rbutil/rbutilqt/utils.cpp
Normal file
45
rbutil/rbutilqt/utils.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Wenger
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
// recursive function to delete a dir with files
|
||||||
|
bool recRmdir( const QString &dirName )
|
||||||
|
{
|
||||||
|
QString dirN = dirName;
|
||||||
|
QDir dir(dirN);
|
||||||
|
QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
|
||||||
|
QFileInfo fileInfo;
|
||||||
|
QString curItem, lstAt;
|
||||||
|
for(int i = 0; i < list.size(); i++){ // loop through all items of list
|
||||||
|
QString name = list.at(i);
|
||||||
|
if(!(name == ".") && !(name == "..")){
|
||||||
|
curItem = dirN + "/" + name;
|
||||||
|
fileInfo.setFile(curItem);
|
||||||
|
if(fileInfo.isDir()) // is directory
|
||||||
|
recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
|
||||||
|
else // is file
|
||||||
|
QFile::remove(curItem); // ok, delete file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dir.cdUp();
|
||||||
|
return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
|
||||||
|
}
|
||||||
29
rbutil/rbutilqt/utils.h
Normal file
29
rbutil/rbutilqt/utils.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Dominik Wenger
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef UTILS_H
|
||||||
|
#define UTILS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
bool recRmdir( const QString &dirName );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue