blob: 8d6f804c9804d7b7ebd22c2f9da77485e1e1af05 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#include "icons.h"
#define PIXMAP_MUTE PIXMAPS"/mute"
#define PIXMAP_UNMUTE PIXMAPS"/unmute"
#define PIXMAP_RECORD PIXMAPS"/record"
#define PIXMAP_STOP PIXMAPS"/stop"
#define PIXMAP_FREEZE PIXMAPS"/freeze"
#define PIXMAP_UNFREEZE PIXMAPS"/unfreeze"
#define PIXMAP_CPR PIXMAPS"/cpr"
#define PIXMAP_CLEAR PIXMAPS"/clear"
#define PIXMAP_SNAPSHOT PIXMAPS"/snapshot"
#define PIXMAP_DUMMY PIXMAPS"/dummy"
#define PIXMAP_LOGO_SMALL PIXMAPS"/miav-logo"
#define CAIRO_SVG
#ifdef QT_SVG
#include <QSvgRenderer>
#include <QPainter>
#endif
#ifdef CAIRO_SVG
#include "svgloader.h"
#endif
#include <QApplication>
#include <QDesktopWidget>
#include <QX11Info>
QPixmap *loadIcon(char* fname)
{
QPixmap *pixmap;
int dpix = qApp->desktop()->x11Info().appDpiX();
int dpiy = qApp->desktop()->x11Info().appDpiY();
printf("DpiX: %d DpiY: %d\n", dpix, dpiy);
#ifdef CAIRO_SVG
SVGLoader svg;
QString filename = fname;
filename.append(".svg");
double dpi = (double)(dpix + dpiy) / 2.0;
pixmap = new QPixmap(QPixmap::fromImage(svg.load(filename, 0, 0, 14.0 / dpi, 14.0 / dpi)));
#endif
#ifdef QT_SVG
QSvgRenderer svgrenderer;
QPainter painter;
pixmap = new QPixmap(w, h);
painter.begin(pixmap);
QString filename = fname;
svgrenderer.load(filename . ".svg");
svgrenderer.render(&painter);
painter.end();
#endif
#ifndef QT_SVG
#ifndef CAIRO_SVG
QString filename = fname;
filename.append(".png");
pixmap = new QPixmap(filename);
Qt::AspectRatioMode aspect = pixmap.width()<pixmap.height()?
Qt::KeepAspectRatio:Qt::KeepAspectRatioByExpanding;
double dpi = (double)(dpix + dpiy) / 2.0;
*pixmap = pixmap->scaled((int)(dpi / 1.5),(int)(dpi / 1.5), aspect, Qt::SmoothTransformation);
#endif
#endif
return pixmap;
}
bool Icons::loadIcons()
{
cpr = loadIcon(PIXMAP_CPR);
record = loadIcon(PIXMAP_RECORD);
stop = loadIcon(PIXMAP_STOP);
snapshot = loadIcon(PIXMAP_SNAPSHOT);
freeze = loadIcon(PIXMAP_FREEZE);
unfreeze = loadIcon(PIXMAP_UNFREEZE);
mute = loadIcon(PIXMAP_MUTE);
unmute = loadIcon(PIXMAP_UNMUTE);
clear = loadIcon(PIXMAP_CLEAR);
return true;
}
bool Icons::unloadIcons()
{
delete cpr;
delete record;
delete stop;
delete snapshot;
delete freeze;
delete unfreeze;
delete mute;
delete unmute;
delete clear;
return true;
}
QPixmap *Icons::cpr;
QPixmap *Icons::record;
QPixmap *Icons::stop;
QPixmap *Icons::snapshot;
QPixmap *Icons::freeze;
QPixmap *Icons::unfreeze;
QPixmap *Icons::mute;
QPixmap *Icons::unmute;
QPixmap *Icons::clear;
|