12 #include <QDomElement>
25 #define LOC QString("MythUIGuideGrid: ")
32 QMap<QString, QString> catColors;
62 const QString &
filename, QDomElement &element,
bool showWarnings)
64 if (element.tagName() ==
"layout")
69 else if (element.tagName() ==
"channels")
75 else if (element.tagName() ==
"timeslots")
81 else if (element.tagName() ==
"solidcolor")
86 else if (element.tagName() ==
"selector")
89 QString lineColor = element.attribute(
"linecolor",
"");
90 QString fillColor = element.attribute(
"fillcolor",
"");
92 if (!lineColor.isEmpty())
102 if (!fillColor.isEmpty())
111 else if (element.tagName() ==
"recordingcolor")
116 else if (element.tagName() ==
"conflictingcolor")
121 else if (element.tagName() ==
"categoryalpha")
127 else if (element.tagName() ==
"showcategories")
131 else if (element.tagName() ==
"showcategorycolors")
135 else if (element.tagName() ==
"cutdown")
139 else if (element.tagName() ==
"multiline")
143 else if (element.tagName() ==
"textoffset")
147 else if (element.tagName() ==
"font")
165 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown font: " + fontname);
168 else if (element.tagName() ==
"recordstatus")
171 QString typ = element.attribute(
"type");
172 QString img = element.attribute(
"image");
174 if (typ ==
"SingleRecord")
176 else if (typ ==
"TimeslotRecord")
178 else if (typ ==
"ChannelRecord")
180 else if (typ ==
"AllRecord")
182 else if (typ ==
"WeekslotRecord")
184 else if (typ ==
"FindOneRecord")
186 else if (typ ==
"OverrideRecord")
191 else if (element.tagName() ==
"arrow")
193 QString
dir = element.attribute(
"direction");
194 QString image = element.attribute(
"image");
198 else if (
dir ==
"right")
200 else if (
dir ==
"up")
202 else if (
dir ==
"down")
219 LOG(VB_GENERAL, LOG_ERR,
LOC +
"bad parsing");
256 QColor newColor(color);
257 newColor.setAlpha((
int)(color.alpha() *(alphaMod / 255.0)));
286 int alphaMod, QRect clipRect)
288 p->SetClipRect(clipRect);
291 for (
auto *data : qAsConst(
m_allData[i]))
293 if (data->m_recStat == 0)
295 else if (data->m_recStat == 1)
299 drawText(
p, xoffset, yoffset, data, alphaMod);
309 for (
auto *data : qAsConst(
m_allData[i]))
339 area.translate(xoffset, yoffset);
340 area.adjust(breakin, breakin, -breakin, -breakin);
349 else if (status == 2)
366 else if (status == 2)
369 brush.setColor(brush.color().lighter());
370 p->DrawRect(area, brush, pen, alphaMod);
379 else if (status == 2)
409 area.translate(xoffset, yoffset);
410 area.adjust(breakin, breakin, -breakin, -breakin);
422 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
423 area.top(), alphaMod, area);
432 area.center().y() - (arrowarea.height() / 2),
445 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
446 area.top() + area.height() - arrowarea.height(),
456 area.right() - arrowarea.width(),
457 area.center().y() - (arrowarea.height() / 2),
469 image->
DrawSelf(
p, area.right() - imagearea.width(),
470 area.bottom() - imagearea.height(),
498 area.translate(xoffset, yoffset);
499 area.adjust(breakin, breakin, -breakin, -breakin);
501 static const QPen kNoPen(Qt::NoPen);
545 fillColor = fillColor.darker();
546 area.adjust(breakin, breakin, -breakin, -breakin);
550 overColor = fillColor.darker();
552 int second = area.height() - first;
554 overArea.setHeight(first);
555 area.translate(0, first);
556 area.setHeight(second);
558 area.adjust(0, -breakin, -breakin, -breakin);
559 overArea.adjust(0, breakin, -breakin, -breakin);
563 area.adjust(breakin, breakin, -breakin, -breakin);
571 fillColor = fillColor.darker();
572 area.adjust(breakin, breakin, -breakin, -breakin);
576 overColor = fillColor.darker();
578 int second = area.width() - first;
580 overArea.setWidth(first);
581 area.translate(first, 0);
582 area.setWidth(second);
584 area.adjust(0, breakin, -breakin, -breakin);
585 overArea.adjust(breakin, breakin, 0, -breakin);
589 area.adjust(breakin, breakin, -breakin, -breakin);
592 if (area.width() <= 1)
595 if (area.height() <= 1)
598 static const QPen kNoPen(Qt::NoPen);
599 area.translate(xoffset, yoffset);
600 p->DrawRect(area, QBrush(fillColor), kNoPen, alphaMod);
602 if (overArea.width() > 0) {
603 overArea.translate(xoffset, yoffset);
604 p->DrawRect(overArea, QBrush(overColor), kNoPen, alphaMod);
629 msg += QString(
" (%1)").arg(data->
m_category);
633 area.translate(xoffset, yoffset);
640 area.setTop(area.top() +
m_arrowImages[2]->GetArea().height());
643 area.setBottom(area.bottom() -
m_arrowImages[3]->GetArea().height());
648 area.setLeft(area.left() +
m_arrowImages[0]->GetArea().width());
651 area.setRight(area.right() -
m_arrowImages[1]->GetArea().width());
654 if (area.width() <= 0 || area.height() <= 0)
664 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
666 for (
int col = 0; it !=
m_allData[i].end(); ++it, ++col)
680 const QString &
title,
const QString &genre,
681 int arrow,
int recType,
int recStat,
685 auto *data =
new UIGTCon(area,
title, genre, arrow, recType, recStat);
692 if (!data->m_categoryColor.isValid())
705 for (
const auto & path : qAsConst(searchpath))
707 f.setFileName(path +
"categories.xml");
709 if (
f.open(QIODevice::ReadOnly))
713 #ifndef Q_OS_ANDROID // Android does not get a file handle for assets file system
714 if (
f.handle() == -1)
716 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unable to open '%1'")
727 if (!
doc.setContent(&
f,
false, &errorMsg, &errorLine, &errorColumn))
729 LOG(VB_GENERAL, LOG_ERR,
LOC +
730 QString(
"Parsing colors: %1 at line: %2 column: %3")
731 .
arg(
f.fileName()).arg(errorLine).arg(errorColumn) +
732 QString(
"\n\t\t\t%1").
arg(errorMsg));
739 QDomElement element =
doc.documentElement();
741 for (QDomNode child = element.firstChild(); !child.isNull();
742 child = child.nextSibling())
744 QDomElement info = child.toElement();
746 if (!info.isNull() && info.tagName() ==
"catcolor")
748 QString
cat = info.attribute(
"category");
749 QString col = info.attribute(
"color");
751 catColors[
cat.toLower()] = col;
760 for (QMap<QString, QString>::const_iterator it = catC.begin();
761 it != catC.end(); ++it)
770 uiimage->m_imageProperties.m_isThemeImage =
true;
771 uiimage->SetVisible(
false);
772 uiimage->Load(
false);
782 uiimage->m_imageProperties.m_isThemeImage =
true;
783 uiimage->SetVisible(
false);
784 uiimage->Load(
false);