Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SvgIcon.cpp « mumble « src - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4252507a9a898922de58bebd98b8bf726fc5cf18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2018-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include "SvgIcon.h"

#include <QPainter>
#include <QSvgRenderer>

void SvgIcon::addSvgPixmapsToIcon(QIcon &icon, QString fn) {
	QSvgRenderer svg(fn);

	QList< QSize > commonSizes;
	commonSizes << QSize(8, 8);
	commonSizes << QSize(16, 16);
	commonSizes << QSize(22, 22); // Plasma notification area size
	commonSizes << QSize(24, 24);
	commonSizes << QSize(32, 32);
	commonSizes << QSize(44, 44); // Plasma notification area size @x2
	commonSizes << QSize(48, 48);
	commonSizes << QSize(64, 64);
	commonSizes << QSize(96, 96);
	commonSizes << QSize(128, 128);
	commonSizes << QSize(256, 256);

	foreach (QSize size, commonSizes) {
		QPixmap pm(size);
		pm.fill(Qt::transparent);

		QPainter p(&pm);
		p.setRenderHint(QPainter::Antialiasing);
		p.setRenderHint(QPainter::TextAntialiasing);
		p.setRenderHint(QPainter::SmoothPixmapTransform);
		svg.render(&p);

		icon.addPixmap(pm);
	}
}