delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kioslave / bookmarks / kio_bookmarks_pixmap.cpp
blob6d36701c2643a901234d6afbea64de230b2caa16
1 /*
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"
21 #include <stdio.h>
22 #include <stdlib.h>
24 #include <kstandarddirs.h>
25 #include <kcomponentdata.h>
26 #include <klocale.h>
27 #include <kconfig.h>
28 #include <kconfiggroup.h>
30 #include <qbuffer.h>
31 #include <qpainter.h>
32 #include <qpixmap.h>
33 #include <kicon.h>
35 using namespace KIO;
37 void BookmarksProtocol::echoImage( const QString &type, const QString &string, const QString &sizestring )
39 int size = sizestring.toInt();
40 if (size == 0) {
41 if (type == "icon")
42 size = 16;
43 else
44 size = 128;
47 QPixmap pix;
48 if (!cache->find(type + string + QString::number(size), pix)) {
49 KIcon icon = KIcon(string);
50 if (type == "icon") {
51 pix = icon.pixmap(size, size);
52 } else {
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);
63 echoPixmap(pix);
66 void BookmarksProtocol::echoPixmap(const QPixmap &pixmap)
68 SlaveBase::mimeType("image/png");
70 QByteArray bytes;
71 QBuffer buffer(&bytes);
72 buffer.open(QIODevice::WriteOnly);
73 pixmap.save(&buffer, "PNG");
74 data(bytes);