1 | *** libs/libmythui/xmlparsebase.cpp.orig 2010-12-31 01:43:55.000000000 -0600 |
---|
2 | --- libs/libmythui/xmlparsebase.cpp 2011-04-01 16:55:13.000000000 -0500 |
---|
3 | *************** |
---|
4 | *** 799,801 **** |
---|
5 | --- 799,922 ---- |
---|
6 | win->CopyFrom(st); |
---|
7 | return true; |
---|
8 | } |
---|
9 | + |
---|
10 | + void XMLParseBase::GetOSDTimeouts(int *timeoutshort, |
---|
11 | + int *timeoutmedium, |
---|
12 | + int *timeoutlong) |
---|
13 | + { |
---|
14 | + // OSD timeout values, children of "mythuitheme". If defined, |
---|
15 | + // they must be decimal numbers (not hexadecimal, etc.). |
---|
16 | + // If the specified value is not an integer, it will be |
---|
17 | + // ignored and the passed int reference will not be changed. |
---|
18 | + // |
---|
19 | + // Format (times in milliseconds): |
---|
20 | + // <osdtimeouts> |
---|
21 | + // <timeoutshort>1234</timeoutshort> |
---|
22 | + // <timeoutmedium>2345</timeoutmedium> |
---|
23 | + // <timeoutlong>12345</timeoutlong> |
---|
24 | + // </osdtimeouts> |
---|
25 | + |
---|
26 | + const QStringList searchpath = GetMythUI()->GetThemeSearchPath(); |
---|
27 | + |
---|
28 | + QStringList::const_iterator it = searchpath.begin(); |
---|
29 | + for (; it != searchpath.end(); ++it) |
---|
30 | + { |
---|
31 | + QString filename = *it + "osd.xml"; |
---|
32 | + QDomDocument doc; |
---|
33 | + QFile f(filename); |
---|
34 | + |
---|
35 | + if (!f.open(QIODevice::ReadOnly)) |
---|
36 | + VERBOSE(VB_GUI|VB_FILE, LOC_WARN + |
---|
37 | + QString("GetOSDTimeouts: can't open \"%1\"").arg(filename)); |
---|
38 | + |
---|
39 | + else |
---|
40 | + { |
---|
41 | + QString errorMsg; |
---|
42 | + int errorLine = 0; |
---|
43 | + int errorColumn = 0; |
---|
44 | + |
---|
45 | + if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn)) |
---|
46 | + { |
---|
47 | + VERBOSE(VB_IMPORTANT, LOC_ERR + |
---|
48 | + QString("Location: '%1' @ %2 column: %3" |
---|
49 | + "\n\t\t\tError: %4") |
---|
50 | + .arg(qPrintable(filename)).arg(errorLine).arg(errorColumn) |
---|
51 | + .arg(qPrintable(errorMsg))); |
---|
52 | + f.close(); |
---|
53 | + return; |
---|
54 | + } |
---|
55 | + |
---|
56 | + f.close(); |
---|
57 | + |
---|
58 | + QDomElement docElem = doc.documentElement(); |
---|
59 | + QDomNode n = docElem.firstChild(); |
---|
60 | + bool timeoutsfound = false; |
---|
61 | + while (!n.isNull() && !timeoutsfound) |
---|
62 | + { |
---|
63 | + QDomElement e = n.toElement(); |
---|
64 | + if (!e.isNull()) |
---|
65 | + { |
---|
66 | + if (e.tagName() == "osdtimeouts") |
---|
67 | + { |
---|
68 | + timeoutsfound = true; |
---|
69 | + for (QDomNode child = e.firstChild(); !child.isNull(); |
---|
70 | + child = child.nextSibling()) |
---|
71 | + { |
---|
72 | + QDomElement info = child.toElement(); |
---|
73 | + if (!info.isNull()) |
---|
74 | + { |
---|
75 | + QString type = info.tagName(); |
---|
76 | + |
---|
77 | + if (type == "timeoutshort") |
---|
78 | + { |
---|
79 | + QString value = getFirstText(info); |
---|
80 | + if (value != "") |
---|
81 | + { |
---|
82 | + bool valid; |
---|
83 | + int timeout = value.toInt(&valid, 10); |
---|
84 | + if (!valid) |
---|
85 | + VERBOSE_XML(VB_IMPORTANT, filename, e, |
---|
86 | + LOC_ERR + "timeoutshort value ignored; not an integer"); |
---|
87 | + else |
---|
88 | + *timeoutshort = timeout; |
---|
89 | + } |
---|
90 | + } |
---|
91 | + |
---|
92 | + else if (type == "timeoutmedium") |
---|
93 | + { |
---|
94 | + QString value = getFirstText(info); |
---|
95 | + if (value != "") |
---|
96 | + { |
---|
97 | + bool valid; |
---|
98 | + int timeout = value.toInt(&valid, 10); |
---|
99 | + if (!valid) |
---|
100 | + VERBOSE_XML(VB_IMPORTANT, filename, e, |
---|
101 | + LOC_ERR + "timeoutmedium value ignored; not an integer"); |
---|
102 | + else |
---|
103 | + *timeoutmedium = timeout; |
---|
104 | + } |
---|
105 | + } |
---|
106 | + |
---|
107 | + else if (type == "timeoutlong") |
---|
108 | + { |
---|
109 | + QString value = getFirstText(info); |
---|
110 | + if (value != "") |
---|
111 | + { |
---|
112 | + bool valid; |
---|
113 | + int timeout = value.toInt(&valid, 10); |
---|
114 | + if (!valid) |
---|
115 | + VERBOSE_XML(VB_IMPORTANT, filename, e, |
---|
116 | + LOC_ERR + "timeoutlong value ignored; not an integer"); |
---|
117 | + else |
---|
118 | + *timeoutlong = timeout; |
---|
119 | + } |
---|
120 | + } |
---|
121 | + } |
---|
122 | + } |
---|
123 | + } |
---|
124 | + } |
---|
125 | + n = n.nextSibling(); |
---|
126 | + } |
---|
127 | + } |
---|
128 | + } |
---|
129 | + } |
---|