1
/****************************************************************************
4
* Copyright (c) 2011 by Sidorov Aleksey <gorthauer87@ya.ru>
6
***************************************************************************
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 3 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General
19
* Public License along with this library; if not, write to the
20
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301 USA
23
*****************************************************************************/
25
#include "temporaryicon.h"
28
#include <QApplication>
31
#include <QDesktopServices>
33
TemporaryIcon::TemporaryIcon(const QIcon &icon)
35
int size = qApp->style()->pixelMetric(QStyle::PM_ListViewIconSize);
36
m_iconSize = QSize(size, size);
37
QImage image = icon.pixmap(m_iconSize).toImage();
38
if (!image.isNull()) {
39
QString name = QUuid::createUuid().toString();
40
QString path = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
41
m_filePath = path + QLatin1String("/") + name + QLatin1String(".ico");
42
image.save(m_filePath, "ico");
46
TemporaryIcon::~TemporaryIcon()
48
if (!m_filePath.isNull())
49
QFile::remove(m_filePath);
52
QString TemporaryIcon::filePath() const