26#define LOC QString("MythUIGuideGrid: ")
32 QMap<QString, QString> catColors;
64 const QString &
filename, QDomElement &element,
bool showWarnings)
66 if (element.tagName() ==
"layout")
71 else if (element.tagName() ==
"channels")
77 else if (element.tagName() ==
"timeslots")
83 else if (element.tagName() ==
"solidcolor")
88 else if (element.tagName() ==
"selector")
91 QString lineColor = element.attribute(
"linecolor",
"");
92 QString fillColor = element.attribute(
"fillcolor",
"");
94 if (!lineColor.isEmpty())
104 if (!fillColor.isEmpty())
113 else if (element.tagName() ==
"recordingcolor")
118 else if (element.tagName() ==
"conflictingcolor")
123 else if (element.tagName() ==
"categoryalpha")
129 else if (element.tagName() ==
"showcategories")
133 else if (element.tagName() ==
"showcategorycolors")
137 else if (element.tagName() ==
"cutdown")
141 else if (element.tagName() ==
"multiline")
145 else if (element.tagName() ==
"textoffset")
149 else if (element.tagName() ==
"font")
167 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Unknown font: " + fontname);
170 else if (element.tagName() ==
"recordstatus")
173 QString typ = element.attribute(
"type");
174 QString img = element.attribute(
"image");
176 if (typ ==
"SingleRecord")
178 else if (typ ==
"TimeslotRecord")
180 else if (typ ==
"ChannelRecord")
182 else if (typ ==
"AllRecord")
184 else if (typ ==
"WeekslotRecord")
186 else if (typ ==
"FindOneRecord")
188 else if (typ ==
"OverrideRecord")
193 else if (element.tagName() ==
"arrow")
195 QString dir = element.attribute(
"direction");
196 QString image = element.attribute(
"image");
200 else if (dir ==
"right")
202 else if (dir ==
"up")
204 else if (dir ==
"down")
221 LOG(VB_GENERAL, LOG_ERR,
LOC +
"bad parsing");
258 QColor newColor(color);
259 newColor.setAlpha((
int)(color.alpha() *(alphaMod / 255.0)));
288 int alphaMod, QRect clipRect)
290 p->SetClipRect(clipRect);
293 for (
auto *data : std::as_const(
m_allData[i]))
295 if (data->m_recStat == 0)
297 else if (data->m_recStat == 1)
301 drawText(
p, xoffset, yoffset, data, alphaMod);
311 for (
auto *data : std::as_const(
m_allData[i]))
341 area.translate(xoffset, yoffset);
342 area.adjust(breakin, breakin, -breakin, -breakin);
351 else if (status == 2)
368 else if (status == 2)
371 brush.setColor(brush.color().lighter());
372 p->DrawRect(area, brush, pen, alphaMod);
381 else if (status == 2)
411 area.translate(xoffset, yoffset);
412 area.adjust(breakin, breakin, -breakin, -breakin);
424 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
425 area.top(), alphaMod, area);
434 area.center().y() - (arrowarea.height() / 2),
447 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
448 area.top() + area.height() - arrowarea.height(),
458 area.right() - arrowarea.width(),
459 area.center().y() - (arrowarea.height() / 2),
471 image->
DrawSelf(
p, area.right() - imagearea.width(),
472 area.bottom() - imagearea.height(),
500 area.translate(xoffset, yoffset);
501 area.adjust(breakin, breakin, -breakin, -breakin);
503 static const QPen kNoPen(Qt::NoPen);
547 fillColor = fillColor.darker();
548 area.adjust(breakin, breakin, -breakin, -breakin);
552 overColor = fillColor.darker();
554 int second = area.height() - first;
556 overArea.setHeight(first);
557 area.translate(0, first);
558 area.setHeight(second);
560 area.adjust(0, -breakin, -breakin, -breakin);
561 overArea.adjust(0, breakin, -breakin, -breakin);
566 area.adjust(breakin, breakin, -breakin, -breakin);
575 fillColor = fillColor.darker();
576 area.adjust(breakin, breakin, -breakin, -breakin);
580 overColor = fillColor.darker();
582 int second = area.width() - first;
584 overArea.setWidth(first);
585 area.translate(first, 0);
586 area.setWidth(second);
588 area.adjust(0, breakin, -breakin, -breakin);
589 overArea.adjust(breakin, breakin, 0, -breakin);
594 area.adjust(breakin, breakin, -breakin, -breakin);
598 if (area.width() <= 1)
601 if (area.height() <= 1)
604 static const QPen kNoPen(Qt::NoPen);
605 area.translate(xoffset, yoffset);
606 p->DrawRect(area, QBrush(fillColor), kNoPen, alphaMod);
608 if (overArea.width() > 0) {
609 overArea.translate(xoffset, yoffset);
610 p->DrawRect(overArea, QBrush(overColor), kNoPen, alphaMod);
635 msg += QString(
" (%1)").arg(data->
m_category);
639 area.translate(xoffset, yoffset);
646 area.setTop(area.top() +
m_arrowImages[2]->GetArea().height());
649 area.setBottom(area.bottom() -
m_arrowImages[3]->GetArea().height());
654 area.setLeft(area.left() +
m_arrowImages[0]->GetArea().width());
657 area.setRight(area.right() -
m_arrowImages[1]->GetArea().width());
660 if (area.width() <= 0 || area.height() <= 0)
670 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
672 for (
int col = 0; it !=
m_allData[i].end(); ++it, ++col)
686 [[maybe_unused]]
int col,
const QRect area,
687 const QString &title,
const QString &genre,
688 int arrow,
int recType,
int recStat,
691 auto *data =
new UIGTCon(area, title, genre, arrow, recType, recStat);
698 if (!data->m_categoryColor.isValid())
711 for (
const auto & path : std::as_const(searchpath))
713 f.setFileName(path +
"categories.xml");
715 if (f.open(QIODevice::ReadOnly))
720 if (f.handle() == -1)
722 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unable to open '%1'")
729#if QT_VERSION < QT_VERSION_CHECK(6,5,0)
734 if (!doc.setContent(&f,
false, &errorMsg, &errorLine, &errorColumn))
736 LOG(VB_GENERAL, LOG_ERR,
LOC +
737 QString(
"Parsing colors: %1 at line: %2 column: %3")
738 .arg(f.fileName()).arg(errorLine).arg(errorColumn) +
739 QString(
"\n\t\t\t%1").arg(errorMsg));
744 auto parseResult = doc.setContent(&f);
747 LOG(VB_GENERAL, LOG_ERR,
LOC +
748 QString(
"Parsing colors: %1 at line: %2 column: %3")
749 .arg(f.fileName()).arg(parseResult.errorLine).arg(parseResult.errorColumn) +
750 QString(
"\n\t\t\t%1").arg(parseResult.errorMessage));
758 QDomElement element = doc.documentElement();
760 for (QDomNode child = element.firstChild(); !child.isNull();
761 child = child.nextSibling())
763 QDomElement
info = child.toElement();
765 if (!
info.isNull() &&
info.tagName() ==
"catcolor")
767 QString
cat =
info.attribute(
"category");
768 QString col =
info.attribute(
"color");
770 catColors[
cat.toLower()] = col;
779 for (QMap<QString, QString>::const_iterator it = catC.begin();
780 it != catC.end(); ++it)
789 uiimage->m_imageProperties.m_isThemeImage =
true;
790 uiimage->SetVisible(
false);
791 uiimage->Load(
false);
801 uiimage->m_imageProperties.m_isThemeImage =
true;
802 uiimage->SetVisible(
false);
803 uiimage->Load(
false);
MythFontProperties * GetFont(const QString &text)
void AdjustStretch(int stretch)
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
A narrow purpose widget used to show television programs and the timeslots they occupy on channels.
~MythUIGuideGrid() override
void drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws selection indication for a GuideGrid item.
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
static bool parseDefaultCategoryColors(QMap< QString, QString > &catColors)
void drawRecDecoration(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws decoration items for a GuideGrid item.
void SetMultiLine(bool multiline)
void SetArrow(int direction, const QString &file)
void SetProgramInfo(int row, int col, QRect area, const QString &title, const QString &genre, int arrow, int recType, int recStat, bool selected)
void LoadImage(int recType, const QString &file)
void drawBox(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, const QColor &color, int alphaMod)
Draws the background for a GuideGrid item to be recorded.
void Finalize(void) override
Perform any post-xml parsing initialisation tasks.
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
void drawBackground(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws the background for a GuideGrid item that will not be recorded.
QPoint GetRowAndColumn(QPoint position)
std::array< MythUIImage *, ARROWIMAGESIZE > m_arrowImages
MythUIGuideGrid(MythUIType *parent, const QString &name)
static QColor calcColor(const QColor &color, int alpha)
QColor m_conflictingColor
std::array< MythUIImage *, RECSTATUSSIZE > m_recImages
void SetCategoryColors(const QMap< QString, QString > &catColors)
void SetProgPast(int ppast)
QList< UIGTCon * > * m_allData
MythFontProperties * m_font
bool m_drawCategoryColors
void drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws text strings for a GuideGrid item.
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
Draws an entire GuideGrid.
QMap< QString, QColor > m_categoryColors
Image widget, displays a single image or multiple images in sequence.
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
int GetFontStretch() const
QStringList GetThemeSearchPath()
The base class on which all widgets and screens are based.
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
MythFontProperties * GetFont(const QString &text) const
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
static MythPoint parsePoint(const QString &text, bool normalize=true)
static QString getFirstText(QDomElement &element)
static bool parseBool(const QString &text)
FontMap * GetGlobalFontMap(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
static constexpr int MAX_DISPLAY_TIMES
static constexpr uint8_t GridTimeNormal
static constexpr int MAX_DISPLAY_CHANS
static constexpr uint8_t GridTimeEndsAfter
static constexpr uint8_t GridTimeStartsBefore
MythUIHelper * GetMythUI()
static eu8 clamp(eu8 value, eu8 low, eu8 high)
QColor createColor(const QString &color)