13 #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")
160 fontcopy.
Rescale(screenHeight);
166 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")
215 auto *gg = dynamic_cast<MythUIGuideGrid *>(base);
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 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
303 drawText(
p, xoffset, yoffset, data, alphaMod);
313 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
346 area.translate(xoffset, yoffset);
347 area.adjust(breakin, breakin, -breakin, -breakin);
356 else if (status == 2)
373 else if (status == 2)
376 brush.setColor(brush.color().lighter());
377 p->DrawRect(area, brush, pen, alphaMod);
386 else if (status == 2)
416 area.translate(xoffset, yoffset);
417 area.adjust(breakin, breakin, -breakin, -breakin);
429 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
430 area.top(), alphaMod, area);
439 area.center().y() - (arrowarea.height() / 2),
452 arrow->
DrawSelf(
p, area.center().x() - (arrowarea.width() / 2),
453 area.top() + area.height() - arrowarea.height(),
463 area.right() - arrowarea.width(),
464 area.center().y() - (arrowarea.height() / 2),
476 image->
DrawSelf(
p, area.right() - imagearea.width(),
477 area.bottom() - imagearea.height(),
505 area.translate(xoffset, yoffset);
506 area.adjust(breakin, breakin, -breakin, -breakin);
508 static const QPen kNoPen(Qt::NoPen);
552 fillColor = fillColor.darker();
553 area.adjust(breakin, breakin, -breakin, -breakin);
557 overColor = fillColor.darker();
559 int second = area.height() - first;
561 overArea.setHeight(first);
562 area.translate(0, first);
563 area.setHeight(second);
565 area.adjust(0, -breakin, -breakin, -breakin);
566 overArea.adjust(0, breakin, -breakin, -breakin);
570 area.adjust(breakin, breakin, -breakin, -breakin);
578 fillColor = fillColor.darker();
579 area.adjust(breakin, breakin, -breakin, -breakin);
583 overColor = fillColor.darker();
585 int second = area.width() - first;
587 overArea.setWidth(first);
588 area.translate(first, 0);
589 area.setWidth(second);
591 area.adjust(0, breakin, -breakin, -breakin);
592 overArea.adjust(breakin, breakin, 0, -breakin);
596 area.adjust(breakin, breakin, -breakin, -breakin);
599 if (area.width() <= 1)
602 if (area.height() <= 1)
605 static const QPen kNoPen(Qt::NoPen);
606 area.translate(xoffset, yoffset);
607 p->DrawRect(area, QBrush(fillColor), kNoPen, alphaMod);
609 if (overArea.width() > 0) {
610 overArea.translate(xoffset, yoffset);
611 p->DrawRect(overArea, QBrush(overColor), kNoPen, alphaMod);
636 msg += QString(
" (%1)").arg(data->
m_category);
640 area.translate(xoffset, yoffset);
661 if (area.width() <= 0 || area.height() <= 0)
671 QList<UIGTCon *>::iterator it =
m_allData[i].begin();
673 for (
int col = 0; it !=
m_allData[i].end(); ++it, ++col)
687 const QString &title,
const QString &genre,
688 int arrow,
int recType,
int recStat,
692 auto *data =
new UIGTCon(area, title, genre, arrow, recType, recStat);
699 if (!data->m_categoryColor.isValid())
712 for (QStringList::const_iterator ii = searchpath.begin();
713 ii != searchpath.end(); ++ii)
715 f.setFileName(*ii +
"categories.xml");
717 if (f.open(QIODevice::ReadOnly))
721 #ifndef Q_OS_ANDROID // Android does not get a file handle for assets file system 722 if (f.handle() == -1)
724 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unable to open '%1'")
735 if (!doc.setContent(&f,
false, &errorMsg, &errorLine, &errorColumn))
737 LOG(VB_GENERAL, LOG_ERR,
LOC +
738 QString(
"Parsing colors: %1 at line: %2 column: %3")
739 .arg(f.fileName()).arg(errorLine).arg(errorColumn) +
740 QString(
"\n\t\t\t%1").arg(errorMsg));
747 QDomElement element = doc.documentElement();
749 for (QDomNode child = element.firstChild(); !child.isNull();
750 child = child.nextSibling())
752 QDomElement info = child.toElement();
754 if (!info.isNull() && info.tagName() ==
"catcolor")
756 QString
cat = info.attribute(
"category");
757 QString col = info.attribute(
"color");
759 catColors[
cat.toLower()] = col;
768 for (QMap<QString, QString>::const_iterator it = catC.begin();
769 it != catC.end(); ++it)
778 uiimage->m_imageProperties.m_isThemeImage =
true;
779 uiimage->SetVisible(
false);
780 uiimage->Load(
false);
790 uiimage->m_imageProperties.m_isThemeImage =
true;
791 uiimage->SetVisible(
false);
792 uiimage->Load(
false);
bool m_drawCategoryColors
void SetCategoryColors(const QMap< QString, QString > &catColors)
Image widget, displays a single image or multiple images in sequence.
void drawBackground(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws the background for a GuideGrid item that will not be recorded.
#define GridTimeEndsAfter
The base class on which all widgets and screens are based.
void SetProgPast(int ppast)
MythUIImage * m_arrowImages[ARROWIMAGESIZE]
static MythPoint parsePoint(const QString &text, bool normalize=true)
MythUIImage * m_recImages[RECSTATUSSIZE]
FontMap * GetGlobalFontMap(void)
void drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws selection indication for a GuideGrid item.
QStringList GetThemeSearchPath(void)
void LoadImage(int, const QString &file)
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
Draws an entire GuideGrid.
static QString getFirstText(QDomElement &element)
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.
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
void AdjustStretch(int stretch)
int GetFontStretch(void) const
MythUIHelper * GetMythUI()
#define GridTimeStartsBefore
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
void drawRecDecoration(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws decoration items for a GuideGrid item.
MythMainWindow * GetMythMainWindow(void)
static bool parseDefaultCategoryColors(QMap< QString, QString > &catColors)
MythFontProperties * GetFont(const QString &text) const
#define LOG(_MASK_, _LEVEL_, _STRING_)
QColor createColor(const QString &color)
QList< UIGTCon * > * m_allData
MythFontProperties * GetFont(const QString &text)
QColor m_conflictingColor
#define MAX_DISPLAY_TIMES
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
void SetArrow(int, const QString &file)
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
void SetMultiLine(bool multiline)
void drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data, int alphaMod)
Draws text strings for a GuideGrid item.
#define MAX_DISPLAY_CHANS
void SetProgramInfo(int row, int col, const QRect &area, const QString &title, const QString &genre, int arrow, int recType, int recStat, bool selected)
QPoint GetRowAndColumn(QPoint position)
void Finalize(void) override
Perform any post-xml parsing initialisation tasks.
static bool parseBool(const QString &text)
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
MythUIGuideGrid(MythUIType *parent, const QString &name)
QMap< QString, QColor > m_categoryColors
MythFontProperties * m_font
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
static QColor calcColor(const QColor &color, int alpha)