12 #include <QDomElement>
26 #define LOC QString("MythUIGuideGrid: ")
33 QMap<QString, QString> catColors;
63 const QString &
filename, QDomElement &element,
bool showWarnings)
65 if (element.tagName() ==
"layout")
70 else if (element.tagName() ==
"channels")
76 else if (element.tagName() ==
"timeslots")
82 else if (element.tagName() ==
"solidcolor")
87 else if (element.tagName() ==
"selector")
90 QString lineColor = element.attribute(
"linecolor",
"");
91 QString fillColor = element.attribute(
"fillcolor",
"");
93 if (!lineColor.isEmpty())
103 if (!fillColor.isEmpty())
112 else if (element.tagName() ==
"recordingcolor")
117 else if (element.tagName() ==
"conflictingcolor")
122 else if (element.tagName() ==
"categoryalpha")
128 else if (element.tagName() ==
"showcategories")
132 else if (element.tagName() ==
"showcategorycolors")
136 else if (element.tagName() ==
"cutdown")
140 else if (element.tagName() ==
"multiline")
144 else if (element.tagName() ==
"textoffset")
148 else if (element.tagName() ==
"font")
166 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown font: " + fontname);
169 else if (element.tagName() ==
"recordstatus")
172 QString typ = element.attribute(
"type");
173 QString img = element.attribute(
"image");
175 if (typ ==
"SingleRecord")
177 else if (typ ==
"TimeslotRecord")
179 else if (typ ==
"ChannelRecord")
181 else if (typ ==
"AllRecord")
183 else if (typ ==
"WeekslotRecord")
185 else if (typ ==
"FindOneRecord")
187 else if (typ ==
"OverrideRecord")
192 else if (element.tagName() ==
"arrow")
194 QString dir = element.attribute(
"direction");
195 QString image = element.attribute(
"image");
199 else if (dir ==
"right")
201 else if (dir ==
"up")
203 else if (dir ==
"down")
220 LOG(VB_GENERAL, LOG_ERR,
LOC +
"bad parsing");
257 QColor newColor(color);
258 newColor.setAlpha((
int)(color.alpha() *(alphaMod / 255.0)));
287 int alphaMod, QRect clipRect)
289 p->SetClipRect(clipRect);
292 for (
auto *data : qAsConst(
m_allData[i]))
294 if (data->m_recStat == 0)
296 else if (data->m_recStat == 1)
300 drawText(
p, xoffset, yoffset, data, alphaMod);
310 for (
auto *data : qAsConst(
m_allData[i]))
340 area.translate(xoffset, yoffset);
341 area.adjust(breakin, breakin, -breakin, -breakin);
350 else if (status == 2)
367 else if (status == 2)
370 brush.setColor(brush.color().lighter());
371 p->DrawRect(area, brush, pen, alphaMod);
380 else if (status == 2)
410 area.translate(xoffset, yoffset);
411 area.adjust(breakin, breakin, -breakin, -breakin);
423 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
424 area.top(), alphaMod, area);
433 area.center().y() - (arrowarea.height() / 2),
446 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
447 area.top() + area.height() - arrowarea.height(),
457 area.right() - arrowarea.width(),
458 area.center().y() - (arrowarea.height() / 2),
470 image->
DrawSelf(
p, area.right() - imagearea.width(),
471 area.bottom() - imagearea.height(),
499 area.translate(xoffset, yoffset);
500 area.adjust(breakin, breakin, -breakin, -breakin);
502 static const QPen kNoPen(Qt::NoPen);
546 fillColor = fillColor.darker();
547 area.adjust(breakin, breakin, -breakin, -breakin);
551 overColor = fillColor.darker();
553 int second = area.height() - first;
555 overArea.setHeight(first);
556 area.translate(0, first);
557 area.setHeight(second);
559 area.adjust(0, -breakin, -breakin, -breakin);
560 overArea.adjust(0, breakin, -breakin, -breakin);
564 area.adjust(breakin, breakin, -breakin, -breakin);
572 fillColor = fillColor.darker();
573 area.adjust(breakin, breakin, -breakin, -breakin);
577 overColor = fillColor.darker();
579 int second = area.width() - first;
581 overArea.setWidth(first);
582 area.translate(first, 0);
583 area.setWidth(second);
585 area.adjust(0, breakin, -breakin, -breakin);
586 overArea.adjust(breakin, breakin, 0, -breakin);
590 area.adjust(breakin, breakin, -breakin, -breakin);
593 if (area.width() <= 1)
596 if (area.height() <= 1)
599 static const QPen kNoPen(Qt::NoPen);
600 area.translate(xoffset, yoffset);
601 p->DrawRect(area, QBrush(fillColor), kNoPen, alphaMod);
603 if (overArea.width() > 0) {
604 overArea.translate(xoffset, yoffset);
605 p->DrawRect(overArea, QBrush(overColor), kNoPen, alphaMod);
630 msg += QString(
" (%1)").arg(data->
m_category);
634 area.translate(xoffset, yoffset);
641 area.setTop(area.top() +
m_arrowImages[2]->GetArea().height());
644 area.setBottom(area.bottom() -
m_arrowImages[3]->GetArea().height());
649 area.setLeft(area.left() +
m_arrowImages[0]->GetArea().width());
652 area.setRight(area.right() -
m_arrowImages[1]->GetArea().width());
655 if (area.width() <= 0 || area.height() <= 0)
665 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
667 for (
int col = 0; it !=
m_allData[i].end(); ++it, ++col)
681 [[maybe_unused]]
int col,
const QRect area,
682 const QString &title,
const QString &genre,
683 int arrow,
int recType,
int recStat,
686 auto *data =
new UIGTCon(area, title, genre, arrow, recType, recStat);
693 if (!data->m_categoryColor.isValid())
706 for (
const auto & path : qAsConst(searchpath))
708 f.setFileName(path +
"categories.xml");
710 if (f.open(QIODevice::ReadOnly))
714 #ifndef Q_OS_ANDROID // Android does not get a file handle for assets file system
715 if (f.handle() == -1)
717 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unable to open '%1'")
728 if (!doc.setContent(&f,
false, &errorMsg, &errorLine, &errorColumn))
730 LOG(VB_GENERAL, LOG_ERR,
LOC +
731 QString(
"Parsing colors: %1 at line: %2 column: %3")
732 .arg(f.fileName()).arg(errorLine).arg(errorColumn) +
733 QString(
"\n\t\t\t%1").arg(errorMsg));
740 QDomElement element = doc.documentElement();
742 for (QDomNode child = element.firstChild(); !child.isNull();
743 child = child.nextSibling())
745 QDomElement info = child.toElement();
747 if (!info.isNull() && info.tagName() ==
"catcolor")
749 QString
cat = info.attribute(
"category");
750 QString col = info.attribute(
"color");
752 catColors[
cat.toLower()] = col;
761 for (QMap<QString, QString>::const_iterator it = catC.begin();
762 it != catC.end(); ++it)
771 uiimage->m_imageProperties.m_isThemeImage =
true;
772 uiimage->SetVisible(
false);
773 uiimage->Load(
false);
783 uiimage->m_imageProperties.m_isThemeImage =
true;
784 uiimage->SetVisible(
false);
785 uiimage->Load(
false);