From 270106d151af76140737a080f2ff50db9b3fbfbe Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Tue, 31 Mar 2009 19:50:43 +0000 Subject: Rename ThemeInstall class files to actually match the class name. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20594 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/installthemes.cpp | 335 -------------------------------- rbutil/rbutilqt/installthemes.h | 73 ------- rbutil/rbutilqt/installthemesfrm.ui | 147 -------------- rbutil/rbutilqt/rbutilqt.cpp | 2 +- rbutil/rbutilqt/rbutilqt.pro | 6 +- rbutil/rbutilqt/themesinstallfrm.ui | 147 ++++++++++++++ rbutil/rbutilqt/themesinstallwindow.cpp | 335 ++++++++++++++++++++++++++++++++ rbutil/rbutilqt/themesinstallwindow.h | 73 +++++++ 8 files changed, 559 insertions(+), 559 deletions(-) delete mode 100644 rbutil/rbutilqt/installthemes.cpp delete mode 100644 rbutil/rbutilqt/installthemes.h delete mode 100644 rbutil/rbutilqt/installthemesfrm.ui create mode 100644 rbutil/rbutilqt/themesinstallfrm.ui create mode 100644 rbutil/rbutilqt/themesinstallwindow.cpp create mode 100644 rbutil/rbutilqt/themesinstallwindow.h diff --git a/rbutil/rbutilqt/installthemes.cpp b/rbutil/rbutilqt/installthemes.cpp deleted file mode 100644 index 77bf2682ad..0000000000 --- a/rbutil/rbutilqt/installthemes.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Riebeling - * $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 - -#include "ui_installthemesfrm.h" -#include "installthemes.h" -#include "installzip.h" -#include "progressloggergui.h" -#include "utils.h" - -ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent) -{ - ui.setupUi(this); - ui.listThemes->setAlternatingRowColors(true); - ui.listThemes->setSelectionMode(QAbstractItemView::ExtendedSelection); - ui.listThemes->setSortingEnabled(true); - ui.themePreview->clear(); - ui.themePreview->setText(tr("no theme selected")); - ui.labelSize->setText(tr("no selection")); - - connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close())); - connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(ui.listThemes, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), - this, SLOT(updateDetails(QListWidgetItem*, QListWidgetItem*))); - connect(ui.listThemes, SIGNAL(itemSelectionChanged()), this, SLOT(updateSize())); - connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool))); -} - -ThemesInstallWindow::~ThemesInstallWindow() -{ - if(infocachedir!="") - recRmdir(infocachedir); -} - - -void ThemesInstallWindow::downloadInfo() -{ - // try to get the current build information - getter = new HttpGet(this); - - qDebug() << "downloading themes info"; - themesInfo.open(); - qDebug() << "file:" << themesInfo.fileName(); - themesInfo.close(); - - QUrl url; - url = QUrl(settings->themeUrl() + "/rbutilqt.php?target=" - + settings->curConfigure_Modelname()); - qDebug() << "downloadInfo()" << url; - qDebug() << url.queryItems(); - if(settings->cacheOffline()) - getter->setCache(true); - getter->setFile(&themesInfo); - - connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); - connect(logger, SIGNAL(aborted()), getter, SLOT(abort())); - getter->getFile(url); -} - - -void ThemesInstallWindow::downloadDone(int id, bool error) -{ - downloadDone(error); - qDebug() << "downloadDone(bool) =" << id << error; -} - - -void ThemesInstallWindow::downloadDone(bool error) -{ - qDebug() << "downloadDone(bool) =" << error; - - disconnect(logger, SIGNAL(aborted()), getter, SLOT(abort())); - disconnect(logger, SIGNAL(aborted()), this, SLOT(close())); - themesInfo.open(); - - QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); - QStringList tl = iniDetails.childGroups(); - qDebug() << iniDetails.value("error/code").toString() - << iniDetails.value("error/description").toString() - << iniDetails.value("error/query").toString(); - - if(error) { - logger->addItem(tr("Network error: %1.\n" - "Please check your network and proxy settings.") - .arg(getter->errorString()), LOGERROR); - getter->abort(); - logger->abort(); - disconnect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); - connect(logger, SIGNAL(closed()), this, SLOT(close())); - return; - } - // handle possible error codes - if(iniDetails.value("error/code").toInt() != 0 || !iniDetails.contains("error/code")) { - qDebug() << "error!"; - logger->addItem(tr("the following error occured:\n%1") - .arg(iniDetails.value("error/description", "unknown error").toString()), LOGERROR); - logger->abort(); - connect(logger, SIGNAL(closed()), this, SLOT(close())); - return; - } - logger->addItem(tr("done."), LOGOK); - logger->abort(); - logger->close(); - - // setup list - for(int i = 0; i < tl.size(); i++) { - iniDetails.beginGroup(tl.at(i)); - // skip all themes without name field set (i.e. error section) - if(iniDetails.value("name").toString().isEmpty()) { - iniDetails.endGroup(); - continue; - } - qDebug() << "adding theme:" << tl.at(i); - QListWidgetItem *w = new QListWidgetItem; - w->setData(Qt::DisplayRole, iniDetails.value("name").toString()); - w->setData(Qt::UserRole, tl.at(i)); - ui.listThemes->addItem(w); - - iniDetails.endGroup(); - } - // check if there's a themes "MOTD" available - if(iniDetails.contains("status/msg")) { - // check if there's a localized msg available - QString lang = settings->curLang().split("_").at(0); - QString msg; - if(iniDetails.contains("status/msg." + lang)) - msg = iniDetails.value("status/msg." + lang).toString(); - else - msg = iniDetails.value("status/msg").toString(); - qDebug() << "[Themes] MOTD" << msg; - if(!msg.isEmpty()) - QMessageBox::information(this, tr("Information"), msg); - } -} - - -void ThemesInstallWindow::updateSize(void) -{ - long size = 0; - // sum up size for all selected themes - QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); - int items = ui.listThemes->selectedItems().size(); - for(int i = 0; i < items; i++) { - iniDetails.beginGroup(ui.listThemes->selectedItems() - .at(i)->data(Qt::UserRole).toString()); - size += iniDetails.value("size").toInt(); - iniDetails.endGroup(); - } - ui.labelSize->setText(tr("Download size %L1 kiB (%n item(s))", "", items) - .arg((size + 512) / 1024)); -} - - -void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* prev) -{ - if(cur == prev) - return; - - QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); - - QCoreApplication::processEvents(); - ui.themeDescription->setText(tr("fetching details for %1") - .arg(cur->data(Qt::DisplayRole).toString())); - ui.themePreview->clear(); - ui.themePreview->setText(tr("fetching preview ...")); - - iniDetails.beginGroup(cur->data(Qt::UserRole).toString()); - - QUrl img, txt; - txt = QUrl(QString(settings->themeUrl() + "/" - + iniDetails.value("descriptionfile").toString())); - img = QUrl(QString(settings->themeUrl() + "/" - + iniDetails.value("image").toString())); - - QString text; - text = tr("Author: %1
").arg(iniDetails.value("author", - tr("unknown")).toString()); - text += tr("Version: %1
").arg(iniDetails.value("version", - tr("unknown")).toString()); - text += tr("Description: %1
").arg(iniDetails.value("about", - tr("no description")).toString()); - - ui.themeDescription->setHtml(text); - iniDetails.endGroup(); - - igetter.abort(); - if(!settings->cacheDisabled()) - igetter.setCache(true); - else - { - if(infocachedir=="") - { - infocachedir = QDir::tempPath() + "rbutil-themeinfo"; - QDir d = QDir::temp(); - d.mkdir("rbutil-themeinfo"); - } - igetter.setCache(infocachedir); - } - - igetter.getFile(img); -} - - -void ThemesInstallWindow::updateImage(bool error) -{ - qDebug() << "updateImage(bool) =" << error; - - if(error) { - ui.themePreview->clear(); - ui.themePreview->setText(tr("Retrieving theme preview failed.\n" - "HTTP response code: %1").arg(igetter.httpResponse())); - return; - } - - QPixmap p; - if(!error) { - imgData = igetter.readAll(); - if(imgData.isNull()) return; - p.loadFromData(imgData); - if(p.isNull()) { - ui.themePreview->clear(); - ui.themePreview->setText(tr("no theme preview")); - } - else - ui.themePreview->setPixmap(p); - } -} - - -void ThemesInstallWindow::resizeEvent(QResizeEvent* e) -{ - qDebug() << "resizeEvent(QResizeEvent*) =" << e; - - QPixmap p, q; - QSize img; - img.setHeight(ui.themePreview->height()); - img.setWidth(ui.themePreview->width()); - - p.loadFromData(imgData); - if(p.isNull()) return; - q = p.scaled(img, Qt::KeepAspectRatio, Qt::SmoothTransformation); - ui.themePreview->setScaledContents(false); - ui.themePreview->setPixmap(p); -} - - - -void ThemesInstallWindow::show() -{ - QDialog::show(); - logger = new ProgressLoggerGui(this); - logger->show(); - logger->addItem(tr("getting themes information ..."), LOGINFO); - - connect(logger, SIGNAL(aborted()), this, SLOT(close())); - - downloadInfo(); - -} - - -void ThemesInstallWindow::abort() -{ - igetter.abort(); - logger->abort(); - this->close(); -} - - -void ThemesInstallWindow::accept() -{ - if(ui.listThemes->selectedItems().size() == 0) { - this->close(); - return; - } - QStringList themes; - QStringList names; - QStringList version; - QString zip; - QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); - for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) { - iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString()); - zip = settings->themeUrl() - + "/" + iniDetails.value("archive").toString(); - themes.append(zip); - names.append("Theme: " + - ui.listThemes->selectedItems().at(i)->data(Qt::DisplayRole).toString()); - // if no version info is available use installation (current) date - version.append(iniDetails.value("version", - QDate().currentDate().toString("yyyyMMdd")).toString()); - iniDetails.endGroup(); - } - qDebug() << "installing themes:" << themes; - - logger = new ProgressLoggerGui(this); - logger->show(); - QString mountPoint = settings->mountpoint(); - qDebug() << "mountpoint:" << mountPoint; - // show dialog with error if mount point is wrong - if(!QFileInfo(mountPoint).isDir()) { - logger->addItem(tr("Mount point is wrong!"),LOGERROR); - logger->abort(); - return; - } - - installer = new ZipInstaller(this); - installer->setUrl(themes); - installer->setLogSection(names); - installer->setLogVersion(version); - installer->setMountPoint(mountPoint); - if(!settings->cacheDisabled()) - installer->setCache(true); - - connect(logger, SIGNAL(closed()), this, SLOT(close())); - installer->install(logger); - -} - diff --git a/rbutil/rbutilqt/installthemes.h b/rbutil/rbutilqt/installthemes.h deleted file mode 100644 index 6b7aa22074..0000000000 --- a/rbutil/rbutilqt/installthemes.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Riebeling - * $Id$ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#ifndef INSTALLTHEMES_H -#define INSTALLTHEMES_H - -#include -#include - -#include "ui_installthemesfrm.h" -#include "httpget.h" -#include "installzip.h" -#include "progressloggergui.h" -#include "rbsettings.h" - -class ThemesInstallWindow : public QDialog -{ - Q_OBJECT - - public: - ThemesInstallWindow(QWidget* parent = 0); - ~ThemesInstallWindow(); - void setSettings(RbSettings* sett){settings=sett;} - void downloadInfo(void); - void show(void); - - public slots: - void accept(void); - - private: - Ui::ThemeInstallFrm ui; - RbSettings* settings; - HttpGet *getter; - HttpGet igetter; - QTemporaryFile themesInfo; - void resizeEvent(QResizeEvent*); - QByteArray imgData; - ProgressLoggerGui *logger; - ZipInstaller *installer; - QString file; - QString fileName; - - QString infocachedir; - - private slots: - void downloadDone(bool); - void downloadDone(int, bool); - void updateImage(bool); - void abort(void); - void updateDetails(QListWidgetItem* cur, QListWidgetItem* prev); - void updateSize(void); -}; - - -#endif diff --git a/rbutil/rbutilqt/installthemesfrm.ui b/rbutil/rbutilqt/installthemesfrm.ui deleted file mode 100644 index 4033f1eda7..0000000000 --- a/rbutil/rbutilqt/installthemesfrm.ui +++ /dev/null @@ -1,147 +0,0 @@ - - ThemeInstallFrm - - - - 0 - 0 - 750 - 450 - - - - Theme Installation - - - - - - - - - :/icons/wizard.xpm - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Selected Theme - - - - - - - 0 - 0 - - - - - - - true - - - Qt::AlignCenter - - - - - - - Description - - - - - - - - - - Download size: - - - - - - - - - - Hold Ctrl to select multiple item, Shift for a range - - - - - - - Qt::Horizontal - - - - 241 - 20 - - - - - - - - - - &Install - - - :/icons/go-next.png - - - - - - - &Cancel - - - :/icons/process-stop.png - - - - - - - - - - PreviewLabel - QLabel -
preview.h
-
-
- - - - -
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 1000302186..abb42c85ed 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -28,7 +28,7 @@ #include "installtalkwindow.h" #include "createvoicewindow.h" #include "httpget.h" -#include "installthemes.h" +#include "themesinstallwindow.h" #include "uninstallwindow.h" #include "utils.h" #include "rbzip.h" diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index 72fead2c04..4a1131ca44 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -58,7 +58,7 @@ SOURCES += rbutilqt.cpp \ ../ipodpatcher/ipodpatcher.c \ ../sansapatcher/sansapatcher.c \ browsedirtree.cpp \ - installthemes.cpp \ + themesinstallwindow.cpp \ base/uninstall.cpp \ uninstallwindow.cpp \ base/utils.cpp \ @@ -110,7 +110,7 @@ HEADERS += rbutilqt.h \ irivertools/h120sums.h \ irivertools/h300sums.h \ browsedirtree.h \ - installthemes.h \ + themesinstallwindow.h \ base/uninstall.h \ uninstallwindow.h \ base/utils.h \ @@ -164,7 +164,7 @@ FORMS += rbutilqtfrm.ui \ configurefrm.ui \ browsedirtreefrm.ui \ installtalkfrm.ui \ - installthemesfrm.ui \ + themesinstallfrm.ui \ uninstallfrm.ui \ previewfrm.ui \ rbspeexcfgfrm.ui \ diff --git a/rbutil/rbutilqt/themesinstallfrm.ui b/rbutil/rbutilqt/themesinstallfrm.ui new file mode 100644 index 0000000000..4033f1eda7 --- /dev/null +++ b/rbutil/rbutilqt/themesinstallfrm.ui @@ -0,0 +1,147 @@ + + ThemeInstallFrm + + + + 0 + 0 + 750 + 450 + + + + Theme Installation + + + + + + + + + :/icons/wizard.xpm + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Selected Theme + + + + + + + 0 + 0 + + + + + + + true + + + Qt::AlignCenter + + + + + + + Description + + + + + + + + + + Download size: + + + + + + + + + + Hold Ctrl to select multiple item, Shift for a range + + + + + + + Qt::Horizontal + + + + 241 + 20 + + + + + + + + + + &Install + + + :/icons/go-next.png + + + + + + + &Cancel + + + :/icons/process-stop.png + + + + + + + + + + PreviewLabel + QLabel +
preview.h
+
+
+ + + + +
diff --git a/rbutil/rbutilqt/themesinstallwindow.cpp b/rbutil/rbutilqt/themesinstallwindow.cpp new file mode 100644 index 0000000000..fb3fbe4cb7 --- /dev/null +++ b/rbutil/rbutilqt/themesinstallwindow.cpp @@ -0,0 +1,335 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $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 + +#include "ui_themesinstallfrm.h" +#include "themesinstallwindow.h" +#include "installzip.h" +#include "progressloggergui.h" +#include "utils.h" + +ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent) +{ + ui.setupUi(this); + ui.listThemes->setAlternatingRowColors(true); + ui.listThemes->setSelectionMode(QAbstractItemView::ExtendedSelection); + ui.listThemes->setSortingEnabled(true); + ui.themePreview->clear(); + ui.themePreview->setText(tr("no theme selected")); + ui.labelSize->setText(tr("no selection")); + + connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close())); + connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(ui.listThemes, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + this, SLOT(updateDetails(QListWidgetItem*, QListWidgetItem*))); + connect(ui.listThemes, SIGNAL(itemSelectionChanged()), this, SLOT(updateSize())); + connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool))); +} + +ThemesInstallWindow::~ThemesInstallWindow() +{ + if(infocachedir!="") + recRmdir(infocachedir); +} + + +void ThemesInstallWindow::downloadInfo() +{ + // try to get the current build information + getter = new HttpGet(this); + + qDebug() << "downloading themes info"; + themesInfo.open(); + qDebug() << "file:" << themesInfo.fileName(); + themesInfo.close(); + + QUrl url; + url = QUrl(settings->themeUrl() + "/rbutilqt.php?target=" + + settings->curConfigure_Modelname()); + qDebug() << "downloadInfo()" << url; + qDebug() << url.queryItems(); + if(settings->cacheOffline()) + getter->setCache(true); + getter->setFile(&themesInfo); + + connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); + connect(logger, SIGNAL(aborted()), getter, SLOT(abort())); + getter->getFile(url); +} + + +void ThemesInstallWindow::downloadDone(int id, bool error) +{ + downloadDone(error); + qDebug() << "downloadDone(bool) =" << id << error; +} + + +void ThemesInstallWindow::downloadDone(bool error) +{ + qDebug() << "downloadDone(bool) =" << error; + + disconnect(logger, SIGNAL(aborted()), getter, SLOT(abort())); + disconnect(logger, SIGNAL(aborted()), this, SLOT(close())); + themesInfo.open(); + + QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); + QStringList tl = iniDetails.childGroups(); + qDebug() << iniDetails.value("error/code").toString() + << iniDetails.value("error/description").toString() + << iniDetails.value("error/query").toString(); + + if(error) { + logger->addItem(tr("Network error: %1.\n" + "Please check your network and proxy settings.") + .arg(getter->errorString()), LOGERROR); + getter->abort(); + logger->abort(); + disconnect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); + connect(logger, SIGNAL(closed()), this, SLOT(close())); + return; + } + // handle possible error codes + if(iniDetails.value("error/code").toInt() != 0 || !iniDetails.contains("error/code")) { + qDebug() << "error!"; + logger->addItem(tr("the following error occured:\n%1") + .arg(iniDetails.value("error/description", "unknown error").toString()), LOGERROR); + logger->abort(); + connect(logger, SIGNAL(closed()), this, SLOT(close())); + return; + } + logger->addItem(tr("done."), LOGOK); + logger->abort(); + logger->close(); + + // setup list + for(int i = 0; i < tl.size(); i++) { + iniDetails.beginGroup(tl.at(i)); + // skip all themes without name field set (i.e. error section) + if(iniDetails.value("name").toString().isEmpty()) { + iniDetails.endGroup(); + continue; + } + qDebug() << "adding theme:" << tl.at(i); + QListWidgetItem *w = new QListWidgetItem; + w->setData(Qt::DisplayRole, iniDetails.value("name").toString()); + w->setData(Qt::UserRole, tl.at(i)); + ui.listThemes->addItem(w); + + iniDetails.endGroup(); + } + // check if there's a themes "MOTD" available + if(iniDetails.contains("status/msg")) { + // check if there's a localized msg available + QString lang = settings->curLang().split("_").at(0); + QString msg; + if(iniDetails.contains("status/msg." + lang)) + msg = iniDetails.value("status/msg." + lang).toString(); + else + msg = iniDetails.value("status/msg").toString(); + qDebug() << "[Themes] MOTD" << msg; + if(!msg.isEmpty()) + QMessageBox::information(this, tr("Information"), msg); + } +} + + +void ThemesInstallWindow::updateSize(void) +{ + long size = 0; + // sum up size for all selected themes + QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); + int items = ui.listThemes->selectedItems().size(); + for(int i = 0; i < items; i++) { + iniDetails.beginGroup(ui.listThemes->selectedItems() + .at(i)->data(Qt::UserRole).toString()); + size += iniDetails.value("size").toInt(); + iniDetails.endGroup(); + } + ui.labelSize->setText(tr("Download size %L1 kiB (%n item(s))", "", items) + .arg((size + 512) / 1024)); +} + + +void ThemesInstallWindow::updateDetails(QListWidgetItem* cur, QListWidgetItem* prev) +{ + if(cur == prev) + return; + + QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); + + QCoreApplication::processEvents(); + ui.themeDescription->setText(tr("fetching details for %1") + .arg(cur->data(Qt::DisplayRole).toString())); + ui.themePreview->clear(); + ui.themePreview->setText(tr("fetching preview ...")); + + iniDetails.beginGroup(cur->data(Qt::UserRole).toString()); + + QUrl img, txt; + txt = QUrl(QString(settings->themeUrl() + "/" + + iniDetails.value("descriptionfile").toString())); + img = QUrl(QString(settings->themeUrl() + "/" + + iniDetails.value("image").toString())); + + QString text; + text = tr("Author: %1
").arg(iniDetails.value("author", + tr("unknown")).toString()); + text += tr("Version: %1
").arg(iniDetails.value("version", + tr("unknown")).toString()); + text += tr("Description: %1
").arg(iniDetails.value("about", + tr("no description")).toString()); + + ui.themeDescription->setHtml(text); + iniDetails.endGroup(); + + igetter.abort(); + if(!settings->cacheDisabled()) + igetter.setCache(true); + else + { + if(infocachedir=="") + { + infocachedir = QDir::tempPath() + "rbutil-themeinfo"; + QDir d = QDir::temp(); + d.mkdir("rbutil-themeinfo"); + } + igetter.setCache(infocachedir); + } + + igetter.getFile(img); +} + + +void ThemesInstallWindow::updateImage(bool error) +{ + qDebug() << "updateImage(bool) =" << error; + + if(error) { + ui.themePreview->clear(); + ui.themePreview->setText(tr("Retrieving theme preview failed.\n" + "HTTP response code: %1").arg(igetter.httpResponse())); + return; + } + + QPixmap p; + if(!error) { + imgData = igetter.readAll(); + if(imgData.isNull()) return; + p.loadFromData(imgData); + if(p.isNull()) { + ui.themePreview->clear(); + ui.themePreview->setText(tr("no theme preview")); + } + else + ui.themePreview->setPixmap(p); + } +} + + +void ThemesInstallWindow::resizeEvent(QResizeEvent* e) +{ + qDebug() << "resizeEvent(QResizeEvent*) =" << e; + + QPixmap p, q; + QSize img; + img.setHeight(ui.themePreview->height()); + img.setWidth(ui.themePreview->width()); + + p.loadFromData(imgData); + if(p.isNull()) return; + q = p.scaled(img, Qt::KeepAspectRatio, Qt::SmoothTransformation); + ui.themePreview->setScaledContents(false); + ui.themePreview->setPixmap(p); +} + + + +void ThemesInstallWindow::show() +{ + QDialog::show(); + logger = new ProgressLoggerGui(this); + logger->show(); + logger->addItem(tr("getting themes information ..."), LOGINFO); + + connect(logger, SIGNAL(aborted()), this, SLOT(close())); + + downloadInfo(); + +} + + +void ThemesInstallWindow::abort() +{ + igetter.abort(); + logger->abort(); + this->close(); +} + + +void ThemesInstallWindow::accept() +{ + if(ui.listThemes->selectedItems().size() == 0) { + this->close(); + return; + } + QStringList themes; + QStringList names; + QStringList version; + QString zip; + QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this); + for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) { + iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString()); + zip = settings->themeUrl() + + "/" + iniDetails.value("archive").toString(); + themes.append(zip); + names.append("Theme: " + + ui.listThemes->selectedItems().at(i)->data(Qt::DisplayRole).toString()); + // if no version info is available use installation (current) date + version.append(iniDetails.value("version", + QDate().currentDate().toString("yyyyMMdd")).toString()); + iniDetails.endGroup(); + } + qDebug() << "installing themes:" << themes; + + logger = new ProgressLoggerGui(this); + logger->show(); + QString mountPoint = settings->mountpoint(); + qDebug() << "mountpoint:" << mountPoint; + // show dialog with error if mount point is wrong + if(!QFileInfo(mountPoint).isDir()) { + logger->addItem(tr("Mount point is wrong!"),LOGERROR); + logger->abort(); + return; + } + + installer = new ZipInstaller(this); + installer->setUrl(themes); + installer->setLogSection(names); + installer->setLogVersion(version); + installer->setMountPoint(mountPoint); + if(!settings->cacheDisabled()) + installer->setCache(true); + + connect(logger, SIGNAL(closed()), this, SLOT(close())); + installer->install(logger); + +} + diff --git a/rbutil/rbutilqt/themesinstallwindow.h b/rbutil/rbutilqt/themesinstallwindow.h new file mode 100644 index 0000000000..57fe5975d8 --- /dev/null +++ b/rbutil/rbutilqt/themesinstallwindow.h @@ -0,0 +1,73 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef INSTALLTHEMES_H +#define INSTALLTHEMES_H + +#include +#include + +#include "ui_themesinstallfrm.h" +#include "httpget.h" +#include "installzip.h" +#include "progressloggergui.h" +#include "rbsettings.h" + +class ThemesInstallWindow : public QDialog +{ + Q_OBJECT + + public: + ThemesInstallWindow(QWidget* parent = 0); + ~ThemesInstallWindow(); + void setSettings(RbSettings* sett){settings=sett;} + void downloadInfo(void); + void show(void); + + public slots: + void accept(void); + + private: + Ui::ThemeInstallFrm ui; + RbSettings* settings; + HttpGet *getter; + HttpGet igetter; + QTemporaryFile themesInfo; + void resizeEvent(QResizeEvent*); + QByteArray imgData; + ProgressLoggerGui *logger; + ZipInstaller *installer; + QString file; + QString fileName; + + QString infocachedir; + + private slots: + void downloadDone(bool); + void downloadDone(int, bool); + void updateImage(bool); + void abort(void); + void updateDetails(QListWidgetItem* cur, QListWidgetItem* prev); + void updateSize(void); +}; + + +#endif -- cgit v1.2.3