mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 21:52:28 -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 "installzip.h"
|
||||
#include "progressloggergui.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
|
|
@ -32,11 +32,16 @@ ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
|
|||
ui.listThemes->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
ui.themePreview->clear();
|
||||
ui.themePreview->setText(tr("no theme selected"));
|
||||
|
||||
|
||||
connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
}
|
||||
|
||||
ThemesInstallWindow::~ThemesInstallWindow()
|
||||
{
|
||||
if(infocachedir!="")
|
||||
recRmdir(infocachedir);
|
||||
}
|
||||
|
||||
QString ThemesInstallWindow::resolution()
|
||||
{
|
||||
|
|
@ -186,6 +191,16 @@ void ThemesInstallWindow::updateDetails(int row)
|
|||
igetter.setProxy(proxy);
|
||||
if(!userSettings->value("cachedisable").toBool())
|
||||
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);
|
||||
connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,13 +34,14 @@ class ThemesInstallWindow : public QDialog
|
|||
|
||||
public:
|
||||
ThemesInstallWindow(QWidget* parent = 0);
|
||||
~ThemesInstallWindow();
|
||||
void setDeviceSettings(QSettings*);
|
||||
void setUserSettings(QSettings *);
|
||||
void setProxy(QUrl);
|
||||
void downloadInfo(void);
|
||||
void show(void);
|
||||
void accept(void);
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
|
|
@ -59,7 +60,9 @@ class ThemesInstallWindow : public QDialog
|
|||
ZipInstaller *installer;
|
||||
QString file;
|
||||
QString fileName;
|
||||
|
||||
|
||||
QString infocachedir;
|
||||
|
||||
private slots:
|
||||
void downloadDone(bool);
|
||||
void downloadDone(int, bool);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ SOURCES += rbutilqt.cpp \
|
|||
installthemes.cpp \
|
||||
uninstall.cpp \
|
||||
uninstallwindow.cpp \
|
||||
utils.cpp \
|
||||
browseof.cpp \
|
||||
preview.cpp
|
||||
|
||||
|
|
@ -68,6 +69,7 @@ HEADERS += rbutilqt.h \
|
|||
installthemes.h \
|
||||
uninstall.h \
|
||||
uninstallwindow.h \
|
||||
utils.h \
|
||||
browseof.h \
|
||||
preview.h
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "uninstall.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
|
||||
Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
|
||||
{
|
||||
m_mountpoint = mountpoint;
|
||||
}
|
||||
|
|
@ -37,45 +37,22 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
|
|||
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
|
||||
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)
|
||||
{
|
||||
m_dp = dp;
|
||||
m_dp->setProgressMax(0);
|
||||
m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);
|
||||
|
||||
|
||||
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
|
||||
|
||||
|
||||
for(int i=0; i< uninstallSections.size() ; i++)
|
||||
{
|
||||
m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO);
|
||||
installlog.beginGroup(uninstallSections.at(i));
|
||||
QStringList toDeleteList = installlog.allKeys();
|
||||
QStringList dirList;
|
||||
|
||||
|
||||
// iterate over all entrys
|
||||
for(int j =0; j < toDeleteList.size(); j++ )
|
||||
{
|
||||
|
|
@ -101,7 +78,7 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
|
|||
|
||||
installlog.endGroup();
|
||||
//installlog.removeGroup(uninstallSections.at(i))
|
||||
}
|
||||
}
|
||||
uninstallSections.clear();
|
||||
installlog.sync();
|
||||
m_dp->setProgressMax(1);
|
||||
|
|
@ -121,5 +98,5 @@ QStringList Uninstaller::getAllSections()
|
|||
|
||||
bool Uninstaller::uninstallPossible()
|
||||
{
|
||||
return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists();
|
||||
return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ private slots:
|
|||
|
||||
|
||||
private:
|
||||
bool recRmdir( QString &dirName );
|
||||
|
||||
QString m_mountpoint;
|
||||
|
||||
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