12 #include <QDomElement>
26 #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 : std::as_const(
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 : std::as_const(
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);
564 area.adjust(breakin, breakin, -breakin, -breakin);
573 fillColor = fillColor.darker();
574 area.adjust(breakin, breakin, -breakin, -breakin);
578 overColor = fillColor.darker();
580 int second = area.width() - first;
582 overArea.setWidth(first);
583 area.translate(first, 0);
584 area.setWidth(second);
586 area.adjust(0, breakin, -breakin, -breakin);
587 overArea.adjust(breakin, breakin, 0, -breakin);
592 area.adjust(breakin, breakin, -breakin, -breakin);
596 if (area.width() <= 1)
599 if (area.height() <= 1)
602 static const QPen kNoPen(Qt::NoPen);
603 area.translate(xoffset, yoffset);
604 p->DrawRect(area, QBrush(fillColor), kNoPen, alphaMod);
606 if (overArea.width() > 0) {
607 overArea.translate(xoffset, yoffset);
608 p->DrawRect(overArea, QBrush(overColor), kNoPen, alphaMod);
633 msg += QString(
" (%1)").arg(data->
m_category);
637 area.translate(xoffset, yoffset);
644 area.setTop(area.top() +
m_arrowImages[2]->GetArea().height());
647 area.setBottom(area.bottom() -
m_arrowImages[3]->GetArea().height());
652 area.setLeft(area.left() +
m_arrowImages[0]->GetArea().width());
655 area.setRight(area.right() -
m_arrowImages[1]->GetArea().width());
658 if (area.width() <= 0 || area.height() <= 0)
668 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
670 for (
int col = 0; it !=
m_allData[i].end(); ++it, ++col)
684 [[maybe_unused]]
int col,
const QRect area,
685 const QString &title,
const QString &genre,
686 int arrow,
int recType,
int recStat,
689 auto *data =
new UIGTCon(area, title, genre, arrow, recType, recStat);
696 if (!data->m_categoryColor.isValid())
709 for (
const auto & path : std::as_const(searchpath))
711 f.setFileName(path +
"categories.xml");
713 if (f.open(QIODevice::ReadOnly))
717 #ifndef Q_OS_ANDROID // Android does not get a file handle for assets file system
718 if (f.handle() == -1)
720 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unable to open '%1'")
731 if (!doc.setContent(&f,
false, &errorMsg, &errorLine, &errorColumn))
733 LOG(VB_GENERAL, LOG_ERR,
LOC +
734 QString(
"Parsing colors: %1 at line: %2 column: %3")
735 .arg(f.fileName()).arg(errorLine).arg(errorColumn) +
736 QString(
"\n\t\t\t%1").arg(errorMsg));
743 QDomElement element = doc.documentElement();
745 for (QDomNode child = element.firstChild(); !child.isNull();
746 child = child.nextSibling())
748 QDomElement
info = child.toElement();
750 if (!
info.isNull() &&
info.tagName() ==
"catcolor")
752 QString
cat =
info.attribute(
"category");
753 QString col =
info.attribute(
"color");
755 catColors[
cat.toLower()] = col;
764 for (QMap<QString, QString>::const_iterator it = catC.begin();
765 it != catC.end(); ++it)
774 uiimage->m_imageProperties.m_isThemeImage =
true;
775 uiimage->SetVisible(
false);
776 uiimage->Load(
false);
786 uiimage->m_imageProperties.m_isThemeImage =
true;
787 uiimage->SetVisible(
false);
788 uiimage->Load(
false);