LeechCraft
0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
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
{
14
WidthIconProvider::WidthIconProvider
()
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::requestPixmap
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
Reimplemented from QDeclarativeImageProvider::requestPixmap().
Definition
widthiconprovider.cpp:19
LC::Util::WidthIconProvider::WidthIconProvider
WidthIconProvider()
Definition
widthiconprovider.cpp:14
LC::Util::WidthIconProvider::GetIcon
virtual QIcon GetIcon(const QStringList &path)=0
Implement this method to return a proper QIcon for path.
LC::Util
Definition
icoreproxy.h:34
LC::Util::Filter
Container< T > Filter(const Container< T > &c, F f)
Definition
prelude.h:118
widthiconprovider.h
src
util
qml
widthiconprovider.cpp
Generated by
1.10.0