2 Copyright (C) 2008 Xavier Vello <xavier.vello@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "kio_bookmarks.h"
24 #include <kstandarddirs.h>
25 #include <kcomponentdata.h>
28 #include <kconfiggroup.h>
37 void BookmarksProtocol::echoImage( const QString
&type
, const QString
&string
, const QString
&sizestring
)
39 int size
= sizestring
.toInt();
48 if (!cache
->find(type
+ string
+ QString::number(size
), pix
)) {
49 KIcon icon
= KIcon(string
);
51 pix
= icon
.pixmap(size
, size
);
53 pix
= QPixmap(size
, size
);
54 pix
.fill(Qt::transparent
);
55 QPainter
painter(&pix
);
56 painter
.setOpacity(0.3);
58 QRectF
rect(0, 0, size
, size
);
59 painter
.drawPixmap(rect
, icon
.pixmap(size
, size
), rect
);
61 cache
->insert(type
+ string
+ QString::number(size
), pix
);
66 void BookmarksProtocol::echoPixmap(const QPixmap
&pixmap
)
68 SlaveBase::mimeType("image/png");
71 QBuffer
buffer(&bytes
);
72 buffer
.open(QIODevice::WriteOnly
);
73 pixmap
.save(&buffer
, "PNG");