-
Notifications
You must be signed in to change notification settings - Fork 0
/
color.h
40 lines (31 loc) · 1.11 KB
/
color.h
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
#include <QString>
#ifndef COLORS_H
#define COLORS_H
//pleco style colors
namespace Color{
QString addColorSpan(const QString& hanzi, const QString& pinyin);
const QString spanRed = "<span style=\"color:#DD0000\">";
const QString spanGreen = "<span style=\"color:#00A600\">";
const QString spanPurple = "<span style=\"color:#CA2CFF\">";
const QString spanBlue = "<span style=\"color:#0000FF\">";
const QString red = "#DD0000";
const QString green = "#00A600";
const QString purple = "#CA2CFF";
const QString blue = "#0000FF";
QString addColorSpan(const QString& hanzi, const QString& pinyin)
{
if(pinyin.contains(" ")) // if pinyin contains spaces, there are multiple pronounciations with possibly different tones
return hanzi;
else if(pinyin.contains("1"))
return spanRed + hanzi + "</span>";
else if(pinyin.contains("2"))
return spanGreen + hanzi + "</span>";
else if(pinyin.contains("3"))
return spanBlue + hanzi + "</span>";
else if(pinyin.contains("4"))
return spanPurple + hanzi + "</span>";
else // neutral tone
return hanzi;
}
}
#endif COLORS_H