forked from len0rd/rockbox
Theme Editor: Added targetdb download to preferences dialog, fixed Cancel button on FontDownloader
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27565 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e1e51f9994
commit
d92f8174a1
9 changed files with 319 additions and 7 deletions
|
@ -34,10 +34,13 @@
|
||||||
|
|
||||||
FontDownloader::FontDownloader(QWidget *parent, QString path) :
|
FontDownloader::FontDownloader(QWidget *parent, QString path) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::FontDownloader), dir(path), reply(0)
|
ui(new Ui::FontDownloader), dir(path), reply(0), cancelled(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
QObject::connect(ui->cancelButton, SIGNAL(clicked()),
|
||||||
|
this, SLOT(cancel()));
|
||||||
|
|
||||||
manager = new QNetworkAccessManager();
|
manager = new QNetworkAccessManager();
|
||||||
|
|
||||||
if(!dir.exists())
|
if(!dir.exists())
|
||||||
|
@ -91,12 +94,18 @@ FontDownloader::~FontDownloader()
|
||||||
|
|
||||||
void FontDownloader::cancel()
|
void FontDownloader::cancel()
|
||||||
{
|
{
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
if(reply)
|
if(reply)
|
||||||
{
|
{
|
||||||
reply->abort();
|
reply->abort();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
reply = 0;
|
reply = 0;
|
||||||
}
|
}
|
||||||
|
fout.close();
|
||||||
|
fout.remove();
|
||||||
|
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontDownloader::dataReceived()
|
void FontDownloader::dataReceived()
|
||||||
|
@ -115,7 +124,11 @@ void FontDownloader::progress(qint64 bytes, qint64 available)
|
||||||
|
|
||||||
void FontDownloader::finished()
|
void FontDownloader::finished()
|
||||||
{
|
{
|
||||||
|
if(cancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
fout.close();
|
fout.close();
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
reply = 0;
|
reply = 0;
|
||||||
ui->label->setText(tr("Download complete"));
|
ui->label->setText(tr("Download complete"));
|
||||||
|
|
|
@ -54,6 +54,8 @@ private:
|
||||||
QDir dir;
|
QDir dir;
|
||||||
QFile fout;
|
QFile fout;
|
||||||
QNetworkReply* reply;
|
QNetworkReply* reply;
|
||||||
|
|
||||||
|
bool cancelled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FONTDOWNLOADER_H
|
#endif // FONTDOWNLOADER_H
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "preferencesdialog.h"
|
#include "preferencesdialog.h"
|
||||||
#include "ui_preferencesdialog.h"
|
#include "ui_preferencesdialog.h"
|
||||||
#include "fontdownloader.h"
|
#include "fontdownloader.h"
|
||||||
|
#include "targetdownloader.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
@ -223,6 +224,8 @@ void PreferencesDialog::setupUI()
|
||||||
this, SLOT(browseDB()));
|
this, SLOT(browseDB()));
|
||||||
QObject::connect(ui->dlFontsButton, SIGNAL(clicked()),
|
QObject::connect(ui->dlFontsButton, SIGNAL(clicked()),
|
||||||
this, SLOT(dlFonts()));
|
this, SLOT(dlFonts()));
|
||||||
|
QObject::connect(ui->dlTargetButton, SIGNAL(clicked()),
|
||||||
|
this, SLOT(dlTargetDB()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::colorClicked()
|
void PreferencesDialog::colorClicked()
|
||||||
|
@ -278,6 +281,12 @@ void PreferencesDialog::dlFonts()
|
||||||
dl->show();
|
dl->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::dlTargetDB()
|
||||||
|
{
|
||||||
|
TargetDownloader* dl = new TargetDownloader(this, ui->dbBox->text());
|
||||||
|
dl->show();
|
||||||
|
}
|
||||||
|
|
||||||
void PreferencesDialog::accept()
|
void PreferencesDialog::accept()
|
||||||
{
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
|
@ -50,6 +50,7 @@ private slots:
|
||||||
void browseFont();
|
void browseFont();
|
||||||
void browseDB();
|
void browseDB();
|
||||||
void dlFonts();
|
void dlFonts();
|
||||||
|
void dlTargetDB();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PreferencesDialog *ui;
|
Ui::PreferencesDialog *ui;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -358,7 +358,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="dlTargetButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Update Target DB</string>
|
<string>Update Target DB</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
138
utils/themeeditor/gui/targetdownloader.cpp
Normal file
138
utils/themeeditor/gui/targetdownloader.cpp
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Robert Bieber
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "targetdownloader.h"
|
||||||
|
#include "ui_targetdownloader.h"
|
||||||
|
|
||||||
|
#include "quazip.h"
|
||||||
|
#include "quazipfile.h"
|
||||||
|
#include "quazipfileinfo.h"
|
||||||
|
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
TargetDownloader::TargetDownloader(QWidget *parent, QString path) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::TargetDownloader), reply(0), cancelled(false)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
QObject::connect(ui->cancelButton, SIGNAL(clicked()),
|
||||||
|
this, SLOT(cancel()));
|
||||||
|
|
||||||
|
manager = new QNetworkAccessManager();
|
||||||
|
|
||||||
|
fout.setFileName(path);
|
||||||
|
if(fout.open(QFile::WriteOnly))
|
||||||
|
{
|
||||||
|
ui->label->setText(tr("Downloading targetdb"));
|
||||||
|
|
||||||
|
QNetworkRequest request;
|
||||||
|
request.setUrl(QUrl("http://svn.rockbox.org/viewvc.cgi/trunk/utils/"
|
||||||
|
"themeeditor/resources/targetdb"));
|
||||||
|
request.setRawHeader("User-Agent", "Rockbox Theme Editor");
|
||||||
|
|
||||||
|
reply = manager->get(request);
|
||||||
|
|
||||||
|
QObject::connect(reply, SIGNAL(readyRead()),
|
||||||
|
this, SLOT(dataReceived()));
|
||||||
|
QObject::connect(reply, SIGNAL(finished()),
|
||||||
|
this, SLOT(finished()));
|
||||||
|
QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
|
||||||
|
this, SLOT(progress(qint64,qint64)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->label->setText(tr("Error: Couldn't open output file"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetDownloader::~TargetDownloader()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
fout.close();
|
||||||
|
manager->deleteLater();
|
||||||
|
|
||||||
|
if(reply)
|
||||||
|
{
|
||||||
|
reply->abort();
|
||||||
|
reply->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TargetDownloader::cancel()
|
||||||
|
{
|
||||||
|
cancelled = true;
|
||||||
|
|
||||||
|
if(reply)
|
||||||
|
{
|
||||||
|
reply->abort();
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fout.close();
|
||||||
|
fout.remove();
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TargetDownloader::dataReceived()
|
||||||
|
{
|
||||||
|
fout.write(reply->readAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TargetDownloader::progress(qint64 bytes, qint64 available)
|
||||||
|
{
|
||||||
|
if(available > 0)
|
||||||
|
{
|
||||||
|
ui->progressBar->setMaximum(available);
|
||||||
|
ui->progressBar->setValue(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TargetDownloader::finished()
|
||||||
|
{
|
||||||
|
if(cancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fout.close();
|
||||||
|
reply->deleteLater();
|
||||||
|
reply = 0;
|
||||||
|
ui->label->setText(tr("Download complete"));
|
||||||
|
hide();
|
||||||
|
this->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TargetDownloader::netError(QNetworkReply::NetworkError code)
|
||||||
|
{
|
||||||
|
ui->label->setText(tr("Network error: ") + reply->errorString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TargetDownloader::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
cancel();
|
||||||
|
event->accept();
|
||||||
|
}
|
60
utils/themeeditor/gui/targetdownloader.h
Normal file
60
utils/themeeditor/gui/targetdownloader.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Robert Bieber
|
||||||
|
*
|
||||||
|
* 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 TARGETDOWNLOADER_H
|
||||||
|
#define TARGETDOWNLOADER_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TargetDownloader;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TargetDownloader : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TargetDownloader(QWidget *parent, QString dir);
|
||||||
|
virtual ~TargetDownloader();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
void dataReceived();
|
||||||
|
void progress(qint64 bytes, qint64 available);
|
||||||
|
void finished();
|
||||||
|
void netError(QNetworkReply::NetworkError code);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
Ui::TargetDownloader *ui;
|
||||||
|
|
||||||
|
QNetworkAccessManager* manager;
|
||||||
|
QFile fout;
|
||||||
|
QNetworkReply* reply;
|
||||||
|
|
||||||
|
bool cancelled;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TARGETDOWNLOADER_H
|
87
utils/themeeditor/gui/targetdownloader.ui
Normal file
87
utils/themeeditor/gui/targetdownloader.ui
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TargetDownloader</class>
|
||||||
|
<widget class="QDialog" name="TargetDownloader">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>107</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Downloading Font Pack</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../resources.qrc">
|
||||||
|
<normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="progressBar">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Checking Directory</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cancelButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../resources.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -23,7 +23,6 @@ INCLUDEPATH += models
|
||||||
INCLUDEPATH += graphics
|
INCLUDEPATH += graphics
|
||||||
INCLUDEPATH += quazip
|
INCLUDEPATH += quazip
|
||||||
INCLUDEPATH += qtfindreplacedialog
|
INCLUDEPATH += qtfindreplacedialog
|
||||||
|
|
||||||
DEFINES += FINDREPLACE_NOLIB
|
DEFINES += FINDREPLACE_NOLIB
|
||||||
cross {
|
cross {
|
||||||
message("Crossbuilding for W32 binary")
|
message("Crossbuilding for W32 binary")
|
||||||
|
@ -95,7 +94,8 @@ HEADERS += models/parsetreemodel.h \
|
||||||
qtfindreplacedialog/findreplacedialog.h \
|
qtfindreplacedialog/findreplacedialog.h \
|
||||||
qtfindreplacedialog/findform.h \
|
qtfindreplacedialog/findform.h \
|
||||||
qtfindreplacedialog/finddialog.h \
|
qtfindreplacedialog/finddialog.h \
|
||||||
gui/projectexporter.h
|
gui/projectexporter.h \
|
||||||
|
gui/targetdownloader.h
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
models/parsetreemodel.cpp \
|
models/parsetreemodel.cpp \
|
||||||
models/parsetreenode.cpp \
|
models/parsetreenode.cpp \
|
||||||
|
@ -134,7 +134,8 @@ SOURCES += main.cpp \
|
||||||
qtfindreplacedialog/findreplacedialog.cpp \
|
qtfindreplacedialog/findreplacedialog.cpp \
|
||||||
qtfindreplacedialog/findform.cpp \
|
qtfindreplacedialog/findform.cpp \
|
||||||
qtfindreplacedialog/finddialog.cpp \
|
qtfindreplacedialog/finddialog.cpp \
|
||||||
gui/projectexporter.cpp
|
gui/projectexporter.cpp \
|
||||||
|
gui/targetdownloader.cpp
|
||||||
OTHER_FILES += README \
|
OTHER_FILES += README \
|
||||||
resources/windowicon.png \
|
resources/windowicon.png \
|
||||||
resources/appicon.xcf \
|
resources/appicon.xcf \
|
||||||
|
@ -169,7 +170,8 @@ FORMS += gui/editorwindow.ui \
|
||||||
gui/fontdownloader.ui \
|
gui/fontdownloader.ui \
|
||||||
qtfindreplacedialog/findreplaceform.ui \
|
qtfindreplacedialog/findreplaceform.ui \
|
||||||
qtfindreplacedialog/findreplacedialog.ui \
|
qtfindreplacedialog/findreplacedialog.ui \
|
||||||
gui/projectexporter.ui
|
gui/projectexporter.ui \
|
||||||
|
gui/targetdownloader.ui
|
||||||
RESOURCES += resources.qrc
|
RESOURCES += resources.qrc
|
||||||
win32:RC_FILE = themeeditor.rc
|
win32:RC_FILE = themeeditor.rc
|
||||||
macx {
|
macx {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue