LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
widthiconprovider.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "widthiconprovider.h"
10 #include <QIcon>
11 
12 namespace LC::Util
13 {
15  : QQuickImageProvider (Pixmap)
16  {
17  }
18 
19  QPixmap WidthIconProvider::requestPixmap (const QString& idStr, QSize *size, const QSize& requestedSize)
20  {
21  auto list = idStr.split ('/', Qt::SkipEmptyParts);
22  if (list.isEmpty ())
23  return QPixmap ();
24 
25  auto realSize = requestedSize;
26  if (realSize.width () <= 0)
27  {
28  bool ok = false;
29  const int width = list.last ().toDouble (&ok);
30  realSize = width > 0 ? QSize (width, width) : QSize (32, 32);
31  if (ok)
32  list.removeLast ();
33  }
34 
35  const auto& icon = GetIcon (list);
36 
37  if (size)
38  *size = icon.actualSize (realSize);
39 
40  return icon.pixmap (realSize);
41  }
42 }
LC::Util::WidthIconProvider::WidthIconProvider
WidthIconProvider()
Definition: widthiconprovider.cpp:20
LC::Util
Definition: icoreproxy.h:33
widthiconprovider.h
LC::Util::WidthIconProvider::GetIcon
virtual QIcon GetIcon(const QStringList &path)=0
Implement this method to return a proper QIcon for path.
LC::Util::WidthIconProvider::requestPixmap
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
Reimplemented from QDeclarativeImageProvider::requestPixmap().
Definition: widthiconprovider.cpp:25