Browse Source

- got rid of libMagick++ dependency

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
2aea2a0032
  1. 5
      AUTHORS
  2. 1
      Changelog
  3. 107
      configure
  4. 1
      qbittorrent.qc
  5. 19
      src/engineSelectDlg.cpp
  6. 470
      src/ico.cpp
  7. 52
      src/ico.h
  8. 2
      src/main.cpp
  9. 19
      src/rss.h
  10. 253
      src/src.pro

5
AUTHORS

@ -6,6 +6,11 @@ Contributors:
* Ishan Arora <ishan@qbittorrent.org> * Ishan Arora <ishan@qbittorrent.org>
* Grigis Gaëtan <cipher16@gmail.com> * Grigis Gaëtan <cipher16@gmail.com>
Code from other projects:
* files src/ico.cpp src/ico.h
copyright: Malte Starostik <malte@kde.org>
license: LGPL
Images Authors: Images Authors:
* files: src/Icons/*.png * files: src/Icons/*.png
copyright: Gnome Icon Theme copyright: Gnome Icon Theme

1
Changelog

@ -9,6 +9,7 @@
- FEATURE: Allow to force rechecking torrents - FEATURE: Allow to force rechecking torrents
- FEATURE: Added support for 2 new extensions (uTorrent metadata and smart ban plugin) - FEATURE: Added support for 2 new extensions (uTorrent metadata and smart ban plugin)
- FEATURE: Allow to change the save path of torrents after addition - FEATURE: Allow to change the save path of torrents after addition
- FEATURE: Got rid of libmagick++ dependency
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.1 * Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.1
- BUGFIX: Fixed possible crash when deleting a torrent permanently - BUGFIX: Fixed possible crash when deleting a torrent permanently

107
configure vendored

@ -26,9 +26,6 @@ Dependency options:
--with-libboost-inc=[path] Path to libboost include files --with-libboost-inc=[path] Path to libboost include files
--with-libcurl-inc=[path] Path to libcurl include files --with-libcurl-inc=[path] Path to libcurl include files
--with-libcurl-lib=[path] Path to libcurl library files --with-libcurl-lib=[path] Path to libcurl library files
--disable-libmagick Disable use of libmagick
--with-libmagick-inc=[path] Path to libmagick++ include files
--with-libmagick-lib=[path] Path to libmagick++ library files
--disable-libzzip Disable use of libzzip --disable-libzzip Disable use of libzzip
--with-libzzip-inc=[path] Path to libzzip++ include files --with-libzzip-inc=[path] Path to libzzip++ include files
--with-libzzip-lib=[path] Path to libzzip++ library files --with-libzzip-lib=[path] Path to libzzip++ library files
@ -178,21 +175,6 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
--disable-libmagick)
QC_DISABLE_libmagick="Y"
shift
;;
--with-libmagick-inc=*)
QC_WITH_LIBMAGICK_INC=$optarg
shift
;;
--with-libmagick-lib=*)
QC_WITH_LIBMAGICK_LIB=$optarg
shift
;;
--disable-libzzip) --disable-libzzip)
QC_DISABLE_libzzip="Y" QC_DISABLE_libzzip="Y"
shift shift
@ -235,9 +217,6 @@ echo QC_WITH_LIBTORRENT_STATIC_LIB=$QC_WITH_LIBTORRENT_STATIC_LIB
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC echo QC_WITH_LIBCURL_INC=$QC_WITH_LIBCURL_INC
echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB echo QC_WITH_LIBCURL_LIB=$QC_WITH_LIBCURL_LIB
echo QC_DISABLE_libmagick=$QC_DISABLE_libmagick
echo QC_WITH_LIBMAGICK_INC=$QC_WITH_LIBMAGICK_INC
echo QC_WITH_LIBMAGICK_LIB=$QC_WITH_LIBMAGICK_LIB
echo QC_DISABLE_libzzip=$QC_DISABLE_libzzip echo QC_DISABLE_libzzip=$QC_DISABLE_libzzip
echo QC_WITH_LIBZZIP_INC=$QC_WITH_LIBZZIP_INC echo QC_WITH_LIBZZIP_INC=$QC_WITH_LIBZZIP_INC
echo QC_WITH_LIBZZIP_LIB=$QC_WITH_LIBZZIP_LIB echo QC_WITH_LIBZZIP_LIB=$QC_WITH_LIBZZIP_LIB
@ -553,86 +532,6 @@ public:
return true; return true;
} }
}; };
#line 1 "libmagick.qcm"
/*
-----BEGIN QCMOD-----
name: libmagick
arg: with-libmagick-inc=[path], Path to libmagick++ include files
arg: with-libmagick-lib=[path], Path to libmagick++ library files
-----END QCMOD-----
*/
#include <QProcess>
class qc_libmagick : public ConfObj
{
public:
qc_libmagick(Conf *c) : ConfObj(c) {}
QString name() const { return "ImageMagick library (libmagick++)"; }
QString shortname() const { return "libmagick++"; }
QString checkString() const {
if(!conf->getenv("QC_DISABLE_libmagick").isEmpty())
return "";
return ConfObj::checkString();
}
bool exec(){
if(!conf->getenv("QC_DISABLE_libmagick").isEmpty())
return false;
QString s;
s = conf->getenv("QC_WITH_LIBMAGICK_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "Magick++.h")) {
return false;
}
}else{
QStringList sl;
sl << "/usr/include";
sl << "/usr/local/include";
bool found = false;
foreach(s, sl){
if(conf->checkHeader(s, "Magick++.h")){
found = true;
break;
}
}
if(!found)
return false;
}
conf->addIncludePath(s);
s = conf->getenv("QC_WITH_LIBMAGICK_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "Magick++")) {
return false;
}
}else{
QStringList sl;
sl << "/usr/lib/";
sl << "/usr/lib64/";
sl << "/usr/local/lib/";
sl << "/usr/local/lib64/";
bool found = false;
foreach(s, sl){
if(conf->checkLibrary(s, "Magick++")) {
found = true;
break;
}
}
if(!found)
return false;
}
conf->addLib(QString("-L") + s);
QProcess magickConfig;
QStringList params;
params << "--libs";
magickConfig.start("Magick++-config", params, QIODevice::ReadOnly);
magickConfig.waitForStarted();
magickConfig.waitForFinished();
QByteArray result = magickConfig.readAll();
result = result.replace("\n", "");
conf->addLib(result.data());
conf->addDefine("HAVE_MAGICK");
return true;
}
};
#line 1 "libzzip.qcm" #line 1 "libzzip.qcm"
/* /*
-----BEGIN QCMOD----- -----BEGIN QCMOD-----
@ -720,9 +619,6 @@ cat >$1/modules_new.cpp <<EOT
o = new qc_libcurl(conf); o = new qc_libcurl(conf);
o->required = true; o->required = true;
o->disabled = false; o->disabled = false;
o = new qc_libmagick(conf);
o->required = false;
o->disabled = false;
o = new qc_libzzip(conf); o = new qc_libzzip(conf);
o->required = false; o->required = false;
o->disabled = false; o->disabled = false;
@ -1677,9 +1573,6 @@ export QC_WITH_LIBTORRENT_STATIC_LIB
export QC_WITH_LIBBOOST_INC export QC_WITH_LIBBOOST_INC
export QC_WITH_LIBCURL_INC export QC_WITH_LIBCURL_INC
export QC_WITH_LIBCURL_LIB export QC_WITH_LIBCURL_LIB
export QC_DISABLE_libmagick
export QC_WITH_LIBMAGICK_INC
export QC_WITH_LIBMAGICK_LIB
export QC_DISABLE_libzzip export QC_DISABLE_libzzip
export QC_WITH_LIBZZIP_INC export QC_WITH_LIBZZIP_INC
export QC_WITH_LIBZZIP_LIB export QC_WITH_LIBZZIP_LIB

1
qbittorrent.qc

@ -15,6 +15,5 @@
<dep type='libcurl'> <dep type='libcurl'>
<required/> <required/>
</dep> </dep>
<dep type='libmagick'/>
<dep type='libzzip'/> <dep type='libzzip'/>
</qconf> </qconf>

19
src/engineSelectDlg.cpp

@ -32,11 +32,6 @@
#include <QDropEvent> #include <QDropEvent>
#include <QInputDialog> #include <QInputDialog>
#ifdef HAVE_MAGICK
#include <Magick++.h>
using namespace Magick;
#endif
#ifdef HAVE_ZZIP #ifdef HAVE_ZZIP
#include <zzip/zzip.h> #include <zzip/zzip.h>
#endif #endif
@ -611,20 +606,6 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){ if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
// Icon downloaded // Icon downloaded
QImage fileIcon; QImage fileIcon;
#ifdef HAVE_MAGICK
try{
QFile::copy(filePath, filePath+".ico");
Image image(QDir::cleanPath(filePath+".ico").toUtf8().data());
// Convert to PNG since we can't read ICO format
image.magick("PNG");
// Resize to 16x16px
image.sample(Geometry(16, 16));
image.write(filePath.toUtf8().data());
QFile::remove(filePath+".ico");
}catch(Magick::Exception &error_){
qDebug("favicon conversion to PNG failure: %s", error_.what());
}
#endif
if(fileIcon.load(filePath)) { if(fileIcon.load(filePath)) {
QList<QTreeWidgetItem*> items = findItemsWithUrl(url); QList<QTreeWidgetItem*> items = findItemsWithUrl(url);
QTreeWidgetItem *item; QTreeWidgetItem *item;

470
src/ico.cpp

@ -0,0 +1,470 @@
/*
* kimgio import filter for MS Windows .ico files
*
* Distributed under the terms of the LGPL
* Copyright (c) 2000 Malte Starostik <malte@kde.org>
*
*/
// remove when QImage::jumpTable is ported
#define QT3_SUPPORT
#define QT3_SUPPORT_WARNINGS
#ifdef __GNUC__
#warning TODO: remove QT3_SUPPORT
#endif
#include "ico.h"
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <QtGui/QImage>
#include <QtGui/QBitmap>
#include <QtGui/QApplication>
#include <QtCore/QVector>
#include <QtGui/QDesktopWidget>
namespace
{
// Global header (see http://www.daubnet.com/formats/ICO.html)
struct IcoHeader
{
enum Type { Icon = 1, Cursor };
quint16 reserved;
quint16 type;
quint16 count;
};
inline QDataStream& operator >>( QDataStream& s, IcoHeader& h )
{
return s >> h.reserved >> h.type >> h.count;
}
// Based on qt_read_dib et al. from qimage.cpp
// (c) 1992-2002 Trolltech AS.
struct BMP_INFOHDR
{
static const quint32 Size = 40;
quint32 biSize; // size of this struct
quint32 biWidth; // pixmap width
quint32 biHeight; // pixmap height
quint16 biPlanes; // should be 1
quint16 biBitCount; // number of bits per pixel
enum Compression { RGB = 0 };
quint32 biCompression; // compression method
quint32 biSizeImage; // size of image
quint32 biXPelsPerMeter; // horizontal resolution
quint32 biYPelsPerMeter; // vertical resolution
quint32 biClrUsed; // number of colors used
quint32 biClrImportant; // number of important colors
};
const quint32 BMP_INFOHDR::Size;
QDataStream& operator >>( QDataStream &s, BMP_INFOHDR &bi )
{
s >> bi.biSize;
if ( bi.biSize == BMP_INFOHDR::Size )
{
s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount;
s >> bi.biCompression >> bi.biSizeImage;
s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter;
s >> bi.biClrUsed >> bi.biClrImportant;
}
return s;
}
#if 0
QDataStream &operator<<( QDataStream &s, const BMP_INFOHDR &bi )
{
s << bi.biSize;
s << bi.biWidth << bi.biHeight;
s << bi.biPlanes;
s << bi.biBitCount;
s << bi.biCompression;
s << bi.biSizeImage;
s << bi.biXPelsPerMeter << bi.biYPelsPerMeter;
s << bi.biClrUsed << bi.biClrImportant;
return s;
}
#endif
// Header for every icon in the file
struct IconRec
{
unsigned char width;
unsigned char height;
quint16 colors;
quint16 hotspotX;
quint16 hotspotY;
quint32 size;
quint32 offset;
};
inline QDataStream& operator >>( QDataStream& s, IconRec& r )
{
return s >> r.width >> r.height >> r.colors
>> r.hotspotX >> r.hotspotY >> r.size >> r.offset;
}
struct LessDifference
{
LessDifference( unsigned s, unsigned c )
: size( s ), colors( c ) {}
bool operator ()( const IconRec& lhs, const IconRec& rhs ) const
{
// closest size match precedes everything else
if ( std::abs( int( lhs.width - size ) ) <
std::abs( int( rhs.width - size ) ) ) return true;
else if ( std::abs( int( lhs.width - size ) ) >
std::abs( int( rhs.width - size ) ) ) return false;
else if ( colors == 0 )
{
// high/true color requested
if ( lhs.colors == 0 ) return true;
else if ( rhs.colors == 0 ) return false;
else return lhs.colors > rhs.colors;
}
else
{
// indexed icon requested
if ( lhs.colors == 0 && rhs.colors == 0 ) return false;
else if ( lhs.colors == 0 ) return false;
else return std::abs( int( lhs.colors - colors ) ) <
std::abs( int( rhs.colors - colors ) );
}
}
unsigned size;
unsigned colors;
};
bool loadFromDIB( QDataStream& stream, const IconRec& rec, QImage& icon )
{
BMP_INFOHDR header;
stream >> header;
if ( stream.atEnd() || header.biSize != BMP_INFOHDR::Size ||
header.biSize > rec.size ||
header.biCompression != BMP_INFOHDR::RGB ||
( header.biBitCount != 1 && header.biBitCount != 4 &&
header.biBitCount != 8 && header.biBitCount != 24 &&
header.biBitCount != 32 ) ) return false;
unsigned paletteSize, paletteEntries;
if (header.biBitCount > 8)
{
paletteEntries = 0;
paletteSize = 0;
}
else
{
paletteSize = (1 << header.biBitCount);
paletteEntries = paletteSize;
if (header.biClrUsed && header.biClrUsed < paletteSize)
paletteEntries = header.biClrUsed;
}
// Always create a 32-bit image to get the mask right
// Note: this is safe as rec.width, rec.height are bytes
icon = QImage( rec.width, rec.height, QImage::Format_ARGB32 );
if ( icon.isNull() ) return false;
QVector< QRgb > colorTable( paletteSize );
colorTable.fill( QRgb( 0 ) );
for ( unsigned i = 0; i < paletteEntries; ++i )
{
unsigned char rgb[ 4 ];
stream.readRawData( reinterpret_cast< char* >( &rgb ),
sizeof( rgb ) );
colorTable[ i ] = qRgb( rgb[ 2 ], rgb[ 1 ], rgb[ 0 ] );
}
unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4;
unsigned char* buf = new unsigned char[ bpl ];
unsigned char** lines = icon.jumpTable();
for ( unsigned y = rec.height; !stream.atEnd() && y--; )
{
stream.readRawData( reinterpret_cast< char* >( buf ), bpl );
unsigned char* pixel = buf;
QRgb* p = reinterpret_cast< QRgb* >( lines[ y ] );
switch ( header.biBitCount )
{
case 1:
for ( unsigned x = 0; x < rec.width; ++x )
*p++ = colorTable[
( pixel[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ];
break;
case 4:
for ( unsigned x = 0; x < rec.width; ++x )
if ( x & 1 ) *p++ = colorTable[ pixel[ x / 2 ] & 0x0f ];
else *p++ = colorTable[ pixel[ x / 2 ] >> 4 ];
break;
case 8:
for ( unsigned x = 0; x < rec.width; ++x )
*p++ = colorTable[ pixel[ x ] ];
break;
case 24:
for ( unsigned x = 0; x < rec.width; ++x )
*p++ = qRgb( pixel[ 3 * x + 2 ],
pixel[ 3 * x + 1 ],
pixel[ 3 * x ] );
break;
case 32:
for ( unsigned x = 0; x < rec.width; ++x )
*p++ = qRgba( pixel[ 4 * x + 2 ],
pixel[ 4 * x + 1 ],
pixel[ 4 * x ],
pixel[ 4 * x + 3] );
break;
}
}
delete[] buf;
if ( header.biBitCount < 32 )
{
// Traditional 1-bit mask
bpl = ( rec.width + 31 ) / 32 * 4;
buf = new unsigned char[ bpl ];
for ( unsigned y = rec.height; y--; )
{
stream.readRawData( reinterpret_cast< char* >( buf ), bpl );
QRgb* p = reinterpret_cast< QRgb* >( lines[ y ] );
for ( unsigned x = 0; x < rec.width; ++x, ++p )
if ( ( ( buf[ x / 8 ] >> ( 7 - ( x & 0x07 ) ) ) & 1 ) )
*p &= RGB_MASK;
}
delete[] buf;
}
return true;
}
}
ICOHandler::ICOHandler()
{
}
bool ICOHandler::canRead() const
{
if (canRead(device())) {
setFormat("ico");
return true;
}
return false;
}
bool ICOHandler::read(QImage *outImage)
{
qint64 offset = device()->pos();
QDataStream stream( device() );
stream.setByteOrder( QDataStream::LittleEndian );
IcoHeader header;
stream >> header;
if ( stream.atEnd() || !header.count ||
( header.type != IcoHeader::Icon && header.type != IcoHeader::Cursor) )
return false;
unsigned requestedSize = 32;
unsigned requestedColors = QApplication::desktop()->depth() > 8 ? 0 : QApplication::desktop()->depth();
int requestedIndex = -1;
#if 0
if ( io->parameters() )
{
QStringList params = QString(io->parameters()).split( ';', QString::SkipEmptyParts );
QMap< QString, QString > options;
for ( QStringList::ConstIterator it = params.begin();
it != params.end(); ++it )
{
QStringList tmp = (*it).split( '=', QString::SkipEmptyParts );
if ( tmp.count() == 2 ) options[ tmp[ 0 ] ] = tmp[ 1 ];
}
if ( options[ "index" ].toUInt() )
requestedIndex = options[ "index" ].toUInt();
if ( options[ "size" ].toUInt() )
requestedSize = options[ "size" ].toUInt();
if ( options[ "colors" ].toUInt() )
requestedColors = options[ "colors" ].toUInt();
}
#endif
typedef std::vector< IconRec > IconList;
IconList icons;
for ( unsigned i = 0; i < header.count; ++i )
{
if ( stream.atEnd() )
return false;
IconRec rec;
stream >> rec;
icons.push_back( rec );
}
IconList::const_iterator selected;
if (requestedIndex >= 0) {
selected = std::min( icons.begin() + requestedIndex, icons.end() );
} else {
selected = std::min_element( icons.begin(), icons.end(),
LessDifference( requestedSize, requestedColors ) );
}
if ( stream.atEnd() || selected == icons.end() ||
offset + selected->offset > device()->size() )
return false;
device()->seek( offset + selected->offset );
QImage icon;
if ( loadFromDIB( stream, *selected, icon ) )
{
icon.setText( "X-Index", 0, QString::number( selected - icons.begin() ) );
if ( header.type == IcoHeader::Cursor )
{
icon.setText( "X-HotspotX", 0, QString::number( selected->hotspotX ) );
icon.setText( "X-HotspotY", 0, QString::number( selected->hotspotY ) );
}
*outImage = icon;
return true;
}
return false;
}
bool ICOHandler::write(const QImage &/*image*/)
{
#if 0
if (image.isNull())
return;
QByteArray dibData;
QDataStream dib(dibData, QIODevice::ReadWrite);
dib.setByteOrder(QDataStream::LittleEndian);
QImage pixels = image;
QImage mask;
if (io->image().hasAlphaBuffer())
mask = image.createAlphaMask();
else
mask = image.createHeuristicMask();
mask.invertPixels();
for ( int y = 0; y < pixels.height(); ++y )
for ( int x = 0; x < pixels.width(); ++x )
if ( mask.pixel( x, y ) == 0 ) pixels.setPixel( x, y, 0 );
if (!qt_write_dib(dib, pixels))
return;
uint hdrPos = dib.device()->at();
if (!qt_write_dib(dib, mask))
return;
memmove(dibData.data() + hdrPos, dibData.data() + hdrPos + BMP_WIN + 8, dibData.size() - hdrPos - BMP_WIN - 8);
dibData.resize(dibData.size() - BMP_WIN - 8);
QDataStream ico(device());
ico.setByteOrder(QDataStream::LittleEndian);
IcoHeader hdr;
hdr.reserved = 0;
hdr.type = Icon;
hdr.count = 1;
ico << hdr.reserved << hdr.type << hdr.count;
IconRec rec;
rec.width = image.width();
rec.height = image.height();
if (image.numColors() <= 16)
rec.colors = 16;
else if (image.depth() <= 8)
rec.colors = 256;
else
rec.colors = 0;
rec.hotspotX = 0;
rec.hotspotY = 0;
rec.dibSize = dibData.size();
ico << rec.width << rec.height << rec.colors
<< rec.hotspotX << rec.hotspotY << rec.dibSize;
rec.dibOffset = ico.device()->at() + sizeof(rec.dibOffset);
ico << rec.dibOffset;
BMP_INFOHDR dibHeader;
dib.device()->at(0);
dib >> dibHeader;
dibHeader.biHeight = image.height() << 1;
dib.device()->at(0);
dib << dibHeader;
ico.writeRawBytes(dibData.data(), dibData.size());
return true;
#endif
return false;
}
QByteArray ICOHandler::name() const
{
return "ico";
}
bool ICOHandler::canRead(QIODevice *device)
{
if (!device) {
qWarning("ICOHandler::canRead() called with no device");
return false;
}
const qint64 oldPos = device->pos();
char head[8];
qint64 readBytes = device->read(head, sizeof(head));
const bool readOk = readBytes == sizeof(head);
if (device->isSequential()) {
while (readBytes > 0)
device->ungetChar(head[readBytes-- - 1]);
} else {
device->seek(oldPos);
}
if ( !readOk )
return false;
return head[2] == '\001' && head[3] == '\000' && // type should be 1
( head[6] == 16 || head[6] == 32 || head[6] == 64 ) && // width can only be one of those
( head[7] == 16 || head[7] == 32 || head[7] == 64 ); // same for height
}
class ICOPlugin : public QImageIOPlugin
{
public:
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
};
QStringList ICOPlugin::keys() const
{
return QStringList() << "ico" << "ICO";
}
QImageIOPlugin::Capabilities ICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
if (format == "ico" || format == "ICO")
return Capabilities(CanRead);
if (!format.isEmpty())
return 0;
if (!device->isOpen())
return 0;
Capabilities cap;
if (device->isReadable() && ICOHandler::canRead(device))
cap |= CanRead;
return cap;
}
QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format) const
{
QImageIOHandler *handler = new ICOHandler;
handler->setDevice(device);
handler->setFormat(format);
return handler;
}
Q_EXPORT_STATIC_PLUGIN(ICOPlugin)
Q_EXPORT_PLUGIN2(ico, ICOPlugin)

52
src/ico.h

@ -0,0 +1,52 @@
/*
* ico.h - kimgio import filter for MS Windows .ico files
*
* Distributed under the terms of the LGPL
* Copyright (c) 2000 Malte Starostik <malte@kde.org>
*
*/
// You can use QImageIO::setParameters() to request a specific
// Icon out of an .ico file:
//
// Options consist of a name=value pair and are separated by a semicolon.
// Available options are:
// size=<size> select the icon that most closely matches <size> (pixels)
// default: 32
// colors=<num> select the icon that has <num> colors (or comes closest)
// default: 1 << display depth or 0 (RGB) if display depth > 8
// index=<index> select the indexth icon from the file. If this option
// is present, the size and colors options will be ignored.
// default: none
// If both size and colors are given, size takes precedence.
//
// The old format is still supported:
// the parameters consist of a single string in the form
// "<size>[:<colors>]" which correspond to the options above
//
// If an icon was returned (i.e. the file is valid and the index option
// if present was not out of range), the icon's index within the .ico
// file is returned in the text tag "X-Index" of the image.
// If the icon is in fact a cursor, its hotspot coordinates are returned
// in the text tags "X-HotspotX" and "X-HotspotY".
#ifndef _ICO_H_
#define _ICO_H_
#include <QtGui/QImageIOPlugin>
class ICOHandler : public QImageIOHandler
{
public:
ICOHandler();
bool canRead() const;
bool read(QImage *image);
bool write(const QImage &image);
QByteArray name() const;
static bool canRead(QIODevice *device);
};
#endif

2
src/main.cpp

@ -48,6 +48,8 @@
#include "GUI.h" #include "GUI.h"
#include "misc.h" #include "misc.h"
#include "ico.h"
void useStyle(QApplication *app, int style){ void useStyle(QApplication *app, int style){
switch(style) { switch(style) {

19
src/rss.h

@ -38,11 +38,6 @@
#include "misc.h" #include "misc.h"
#include "downloadThread.h" #include "downloadThread.h"
#ifdef HAVE_MAGICK
#include <Magick++.h>
using namespace Magick;
#endif
class RssManager; class RssManager;
class RssStream; class RssStream;
class RssItem; class RssItem;
@ -588,20 +583,6 @@ class RssManager : public QObject{
if(url.endsWith("favicon.ico")){ if(url.endsWith("favicon.ico")){
// Icon downloaded // Icon downloaded
QImage fileIcon; QImage fileIcon;
#ifdef HAVE_MAGICK
try{
QFile::copy(path, path+".ico");
Image image(QDir::cleanPath(path+".ico").toUtf8().data());
// Convert to PNG since we can't read ICO format
image.magick("PNG");
// Resize to 16x16px
image.sample(Geometry(16, 16));
image.write(path.toUtf8().data());
QFile::remove(path+".ico");
}catch(Magick::Exception &error_){
qDebug("favicon conversion to PNG failure: %s", error_.what());
}
#endif
if(fileIcon.load(path)) { if(fileIcon.load(path)) {
QList<RssStream*> res = findFeedsWithIcon(url); QList<RssStream*> res = findFeedsWithIcon(url);
RssStream* stream; RssStream* stream;

253
src/src.pro

@ -2,30 +2,29 @@
LANG_PATH = lang LANG_PATH = lang
ICONS_PATH = Icons ICONS_PATH = Icons
#Set the following variable to 1 to enable debug # Set the following variable to 1 to enable debug
DEBUG_MODE = 1 DEBUG_MODE = 1
# Global # Global
TEMPLATE = app TEMPLATE = app
TARGET = qbittorrent TARGET = qbittorrent
CONFIG += qt thread x11 network CONFIG += qt \
thread \
x11 \
network
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v1.3.0alpha\\\" DEFINES += VERSION=\\\"v1.3.0alpha\\\"
DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=3 DEFINES += VERSION_MINOR=3
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=0
!mac:QMAKE_LFLAGS += -Wl,--as-needed
!mac { contains(DEBUG_MODE, 1) {
QMAKE_LFLAGS += -Wl,--as-needed
}
contains(DEBUG_MODE, 1){
CONFIG += debug CONFIG += debug
CONFIG -= release CONFIG -= release
message(Debug build!) message(Debug build!)
} }
contains(DEBUG_MODE, 0){ contains(DEBUG_MODE, 0) {
CONFIG -= debug CONFIG -= debug
CONFIG += release CONFIG += release
DEFINES += QT_NO_DEBUG_OUTPUT DEFINES += QT_NO_DEBUG_OUTPUT
@ -37,11 +36,11 @@ contains(DEBUG_MODE, 0){
DEFINES += NDEBUG DEFINES += NDEBUG
# Install # Install
!win32 {
!win32 {
# Binary # Binary
exists(../conf.pri){ exists(../conf.pri) {
include(../conf.pri) include(../conf.pri)
# Target # Target
target.path = $$BINDIR target.path = $$BINDIR
INSTALLS += target INSTALLS += target
@ -49,12 +48,12 @@ DEFINES += NDEBUG
# DBUS # DBUS
QT += dbus QT += dbus
# Man page # Man page
man.files = ../doc/qbittorrent.1 man.files = ../doc/qbittorrent.1
man.path = $$PREFIX/share/man/man1/ man.path = $$PREFIX/share/man/man1/
INSTALLS += man INSTALLS += man
# Menu Icon # Menu Icon
menuicon.files = Icons/qBittorrent.desktop menuicon.files = Icons/qBittorrent.desktop
menuicon.path = $$PREFIX/share/applications/ menuicon.path = $$PREFIX/share/applications/
@ -81,112 +80,154 @@ DEFINES += NDEBUG
icon128.path = $$PREFIX/share/icons/hicolor/128x128/apps/ icon128.path = $$PREFIX/share/icons/hicolor/128x128/apps/
icon192.files = menuicons/192x192/apps/qbittorrent.png icon192.files = menuicons/192x192/apps/qbittorrent.png
icon192.path = $$PREFIX/share/icons/hicolor/192x192/apps/ icon192.path = $$PREFIX/share/icons/hicolor/192x192/apps/
INSTALLS += icon16 icon22 icon24 icon32 icon36 icon48 icon64 icon72 icon96 icon128 icon192 INSTALLS += icon16 \
icon22 \
icon24 \
icon32 \
icon36 \
icon48 \
icon64 \
icon72 \
icon96 \
icon128 \
icon192
} }
QMAKE_CXXFLAGS_RELEASE += -fwrapv \
QMAKE_CXXFLAGS_RELEASE += -fwrapv -O2 -O2
QMAKE_CXXFLAGS_DEBUG += -fwrapv -O1 QMAKE_CXXFLAGS_DEBUG += -fwrapv \
-O1
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += "libtorrent-rasterbar libcurl" PKGCONFIG += "libtorrent-rasterbar libcurl"
!contains(DEFINES, HAVE_MAGICK){ QT += network \
message(ImageMagick disabled) xml
}
QT += network xml
DEFINES += QT_NO_CAST_TO_ASCII DEFINES += QT_NO_CAST_TO_ASCII
#QT_NO_CAST_FROM_ASCII
# QT_NO_CAST_FROM_ASCII
# Windows # Windows
win32 { win32:LIBS += -ltorrent \
LIBS += -ltorrent -lccext2 -lccgnu2 -lccext2 \
#-lMagick++ -lWand -lMagick -lccgnu2
}
# -lMagick++ -lWand -lMagick
RESOURCES = icons.qrc \ RESOURCES = icons.qrc \
lang.qrc \ lang.qrc \
search.qrc \ search.qrc \
webui.qrc webui.qrc
# Translations # Translations
TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \ TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
$$LANG_PATH/qbittorrent_zh.ts \ $$LANG_PATH/qbittorrent_zh.ts \
$$LANG_PATH/qbittorrent_zh_TW.ts \ $$LANG_PATH/qbittorrent_zh_TW.ts \
$$LANG_PATH/qbittorrent_en.ts \ $$LANG_PATH/qbittorrent_en.ts \
$$LANG_PATH/qbittorrent_ca.ts \ $$LANG_PATH/qbittorrent_ca.ts \
$$LANG_PATH/qbittorrent_es.ts \ $$LANG_PATH/qbittorrent_es.ts \
$$LANG_PATH/qbittorrent_pl.ts \ $$LANG_PATH/qbittorrent_pl.ts \
$$LANG_PATH/qbittorrent_ko.ts \ $$LANG_PATH/qbittorrent_ko.ts \
$$LANG_PATH/qbittorrent_de.ts \ $$LANG_PATH/qbittorrent_de.ts \
$$LANG_PATH/qbittorrent_nl.ts \ $$LANG_PATH/qbittorrent_nl.ts \
$$LANG_PATH/qbittorrent_tr.ts \ $$LANG_PATH/qbittorrent_tr.ts \
$$LANG_PATH/qbittorrent_sv.ts \ $$LANG_PATH/qbittorrent_sv.ts \
$$LANG_PATH/qbittorrent_el.ts \ $$LANG_PATH/qbittorrent_el.ts \
$$LANG_PATH/qbittorrent_ru.ts \ $$LANG_PATH/qbittorrent_ru.ts \
$$LANG_PATH/qbittorrent_uk.ts \ $$LANG_PATH/qbittorrent_uk.ts \
$$LANG_PATH/qbittorrent_bg.ts \ $$LANG_PATH/qbittorrent_bg.ts \
$$LANG_PATH/qbittorrent_it.ts \ $$LANG_PATH/qbittorrent_it.ts \
$$LANG_PATH/qbittorrent_sk.ts \ $$LANG_PATH/qbittorrent_sk.ts \
$$LANG_PATH/qbittorrent_ro.ts \ $$LANG_PATH/qbittorrent_ro.ts \
$$LANG_PATH/qbittorrent_pt.ts \ $$LANG_PATH/qbittorrent_pt.ts \
$$LANG_PATH/qbittorrent_nb.ts \ $$LANG_PATH/qbittorrent_nb.ts \
$$LANG_PATH/qbittorrent_fi.ts \ $$LANG_PATH/qbittorrent_fi.ts \
$$LANG_PATH/qbittorrent_da.ts \ $$LANG_PATH/qbittorrent_da.ts \
$$LANG_PATH/qbittorrent_ja.ts \ $$LANG_PATH/qbittorrent_ja.ts \
$$LANG_PATH/qbittorrent_hu.ts \ $$LANG_PATH/qbittorrent_hu.ts \
$$LANG_PATH/qbittorrent_pt_BR.ts \ $$LANG_PATH/qbittorrent_pt_BR.ts \
$$LANG_PATH/qbittorrent_cs.ts $$LANG_PATH/qbittorrent_cs.ts
# Source code # Source code
HEADERS += GUI.h misc.h options_imp.h about_imp.h \ HEADERS += GUI.h \
properties_imp.h createtorrent_imp.h \ misc.h \
DLListDelegate.h SearchListDelegate.h \ options_imp.h \
PropListDelegate.h previewSelect.h \ about_imp.h \
PreviewListDelegate.h trackerLogin.h \ properties_imp.h \
downloadThread.h downloadFromURLImp.h \ createtorrent_imp.h \
torrentAddition.h \ DLListDelegate.h \
bittorrent.h searchEngine.h \ SearchListDelegate.h \
rss.h rss_imp.h FinishedTorrents.h \ PropListDelegate.h \
allocationDlg.h FinishedListDelegate.h \ previewSelect.h \
qtorrenthandle.h downloadingTorrents.h \ PreviewListDelegate.h \
engineSelectDlg.h pluginSource.h \ trackerLogin.h \
arborescence.h qgnomelook.h realprogressbar.h \ downloadThread.h \
realprogressbarthread.h qrealarray.h \ downloadFromURLImp.h \
httpserver.h httpconnection.h \ torrentAddition.h \
httprequestparser.h httpresponsegenerator.h \ bittorrent.h \
json.h eventmanager.h filterParserThread.h \ searchEngine.h \
TrackersAdditionDlg.h searchTab.h console_imp.h rss.h \
FORMS += MainWindow.ui options.ui about.ui \ rss_imp.h \
properties.ui createtorrent.ui preview.ui \ FinishedTorrents.h \
login.ui downloadFromURL.ui addTorrentDialog.ui \ allocationDlg.h \
search.ui rss.ui seeding.ui bandwidth_limit.ui \ FinishedListDelegate.h \
download.ui engineSelect.ui pluginSource.ui \ qtorrenthandle.h \
trackersAdd.ui console.ui downloadingTorrents.h \
engineSelectDlg.h \
pluginSource.h \
arborescence.h \
qgnomelook.h \
realprogressbar.h \
realprogressbarthread.h \
qrealarray.h \
httpserver.h \
httpconnection.h \
httprequestparser.h \
httpresponsegenerator.h \
json.h \
eventmanager.h \
filterParserThread.h \
TrackersAdditionDlg.h \
searchTab.h \
console_imp.h \
ico.h
FORMS += MainWindow.ui \
options.ui \
about.ui \
properties.ui \
createtorrent.ui \
preview.ui \
login.ui \
downloadFromURL.ui \
addTorrentDialog.ui \
search.ui \
rss.ui \
seeding.ui \
bandwidth_limit.ui \
download.ui \
engineSelect.ui \
pluginSource.ui \
trackersAdd.ui \
console.ui
SOURCES += GUI.cpp \ SOURCES += GUI.cpp \
main.cpp \ main.cpp \
options_imp.cpp \ options_imp.cpp \
properties_imp.cpp \ properties_imp.cpp \
createtorrent_imp.cpp \ createtorrent_imp.cpp \
bittorrent.cpp \ bittorrent.cpp \
searchEngine.cpp \ searchEngine.cpp \
rss_imp.cpp \ rss_imp.cpp \
FinishedTorrents.cpp \ FinishedTorrents.cpp \
qtorrenthandle.cpp \ qtorrenthandle.cpp \
downloadingTorrents.cpp \ downloadingTorrents.cpp \
engineSelectDlg.cpp \ engineSelectDlg.cpp \
downloadThread.cpp \ downloadThread.cpp \
realprogressbar.cpp \ realprogressbar.cpp \
realprogressbarthread.cpp \ realprogressbarthread.cpp \
qrealarray.cpp \ qrealarray.cpp \
httpserver.cpp \ httpserver.cpp \
httpconnection.cpp \ httpconnection.cpp \
httprequestparser.cpp \ httprequestparser.cpp \
httpresponsegenerator.cpp \ httpresponsegenerator.cpp \
json.cpp \ json.cpp \
eventmanager.cpp \ eventmanager.cpp \
SearchTab.cpp SearchTab.cpp \
ico.cpp
DESTDIR = . DESTDIR = .

Loading…
Cancel
Save