Repository navigation
Expand file tree
/
Copy pathOpenRGBFont.cpp
More file actions
132 lines (120 loc) · 3.41 KB
/
Copy pathOpenRGBFont.cpp
File metadata and controls
132 lines (120 loc) · 3.41 KB
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
/*---------------------------------------------------------*\
| OpenRGBFont.cpp |
| |
| Functionality for OpenRGB custom font icons |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <QStringList>
#include <QFontDatabase>
#include "OpenRGBFont.h"
OpenRGBFont* OpenRGBFont::instance;
OpenRGBFont::OpenRGBFont()
{
}
OpenRGBFont *OpenRGBFont::Get()
{
if(!instance)
{
instance = new OpenRGBFont();
instance->fontId = QFontDatabase::addApplicationFont(":/fonts/OpenRGB.ttf");
if(instance->fontId == -1)
{
printf("Cannot load requested font.\n");
}
else
{
QString family = QFontDatabase::applicationFontFamilies(instance->fontId).at(0);
instance->font = QFont(family);
instance->font.setStyleStrategy(QFont::PreferAntialias);
}
}
return instance;
}
int OpenRGBFont::GetIconIDFromDeviceType(device_type type)
{
/*-----------------------------------------------------*\
| Return the icon int value for the given device |
| type value |
\*-----------------------------------------------------*/
int icon;
switch(type)
{
case DEVICE_TYPE_ACCESSORY:
icon = OpenRGBFont::usb;
break;
case DEVICE_TYPE_MOTHERBOARD:
icon = OpenRGBFont::mainboard;
break;
case DEVICE_TYPE_DRAM:
icon = OpenRGBFont::dram;
break;
case DEVICE_TYPE_GPU:
icon = OpenRGBFont::gpu;
break;
case DEVICE_TYPE_COOLER:
icon = OpenRGBFont::cooler;
break;
case DEVICE_TYPE_LEDSTRIP:
icon = OpenRGBFont::ledstrip;
break;
case DEVICE_TYPE_KEYBOARD:
icon = OpenRGBFont::keyboard;
break;
case DEVICE_TYPE_MICROPHONE:
icon = OpenRGBFont::mic;
break;
case DEVICE_TYPE_MOUSE:
icon = OpenRGBFont::mouse;
break;
case DEVICE_TYPE_MOUSEMAT:
icon = OpenRGBFont::mousemat;
break;
case DEVICE_TYPE_HEADSET:
icon = OpenRGBFont::headset;
break;
case DEVICE_TYPE_HEADSET_STAND:
icon = OpenRGBFont::headsetstand;
break;
case DEVICE_TYPE_GAMEPAD:
icon = OpenRGBFont::gamepad;
break;
case DEVICE_TYPE_LIGHT:
icon = OpenRGBFont::bulb;
break;
case DEVICE_TYPE_SPEAKER:
icon = OpenRGBFont::music_speaker;
break;
case DEVICE_TYPE_VIRTUAL:
icon = OpenRGBFont::virtual_controller;
break;
case DEVICE_TYPE_STORAGE:
icon = OpenRGBFont::drive;
break;
case DEVICE_TYPE_CASE:
icon = OpenRGBFont::pc_case;
break;
case DEVICE_TYPE_KEYPAD:
icon = OpenRGBFont::keypad;
break;
case DEVICE_TYPE_LAPTOP:
icon = OpenRGBFont::laptop;
break;
case DEVICE_TYPE_MONITOR:
icon = OpenRGBFont::monitor;
break;
default:
icon = OpenRGBFont::unknown;
break;
}
return icon;
}
QString OpenRGBFont::icon(int glyph)
{
return QChar(glyph);
}
QFont OpenRGBFont::GetFont()
{
return Get()->font;
}