MythTV  master
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

A simple text clock widget. More...

#include <mythuiclock.h>

Inheritance diagram for MythUIClock:
Inheritance graph
[legend]
Collaboration diagram for MythUIClock:
Collaboration graph
[legend]

Public Member Functions

 MythUIClock (MythUIType *parent, const QString &name)
 
 ~MythUIClock () override
 
void Pulse (void) override
 Looks up the time and sets the clock if the current time is greater than or equal to m_nextUpdate. More...
 
void SetText (const QString &text) override
 This sets the text, unless the string is blank, in that case the time is looked up and set as the text instead. More...
 
- Public Member Functions inherited from MythUIText
 MythUIText (MythUIType *parent, const QString &name)
 
 MythUIText (const QString &text, const MythFontProperties &font, QRect displayRect, QRect altDisplayRect, MythUIType *parent, const QString &name)
 
 ~MythUIText () override
 
void Reset (void) override
 Reset the widget to it's original state, should not reset changes made by the theme. More...
 
void ResetMap (const InfoMap &map)
 
QString GetText (void) const
 
QString GetDefaultText (void) const
 
void SetTextFromMap (const InfoMap &map)
 
void SetTemplateText (const QString &text)
 
QString GetTemplateText (void) const
 
void Pulse (void) override
 Pulse is called 70 times a second to trigger a single frame of an animation. More...
 
QPoint CursorPosition (int text_offset)
 
int MoveCursor (int lines)
 
void SetDBValue (const QString &text) override
 
QString GetDBValue (void) const override
 
void SetFontState (const QString &state)
 
void SetJustification (int just)
 
- Public Member Functions inherited from MythUIType
 MythUIType (QObject *parent, const QString &name)
 
void AddChild (MythUIType *child)
 Add a child UIType. More...
 
MythUITypeGetChild (const QString &name) const
 Get a named child of this UIType. More...
 
MythUITypeGetChildAt (QPoint p, bool recursive=true, bool focusable=true) const
 Return the first MythUIType at the given coordinates. More...
 
QList< MythUIType * > * GetAllChildren (void)
 Return a list of all child widgets. More...
 
QList< MythUIType * > GetAllDescendants (void)
 
void DeleteChild (const QString &name)
 Delete a named child of this UIType. More...
 
void DeleteChild (MythUIType *child)
 Delete the given UIType if it is a child of this UIType. More...
 
void DeleteAllChildren (void)
 Delete all child widgets. More...
 
bool NeedsRedraw (void) const
 
void ResetNeedsRedraw (void)
 
void SetRedraw (void)
 
void SetChildNeedsRedraw (MythUIType *child)
 
bool CanTakeFocus (void) const
 Return if this widget can accept input focus. More...
 
void SetCanTakeFocus (bool set=true)
 Set whether this widget can take focus. More...
 
void SetFocusOrder (int order)
 
bool IsEnabled (void) const
 
void SetEnabled (bool enable)
 
bool MoveToTop (void)
 
bool MoveChildToTop (MythUIType *child)
 
void ActivateAnimations (MythUIAnimation::Trigger trigger)
 
QList< MythUIAnimation * > * GetAnimations (void)
 
void Draw (MythPainter *p, int xoffset, int yoffset, int alphaMod=255, QRect clipRect=QRect())
 
void SetPosition (int x, int y)
 Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality. More...
 
void SetPosition (QPoint point)
 
virtual MythPoint GetPosition (void) const
 
virtual void SetSize (QSize size)
 
virtual void SetMinSize (const MythPoint &size)
 Set the minimum size of this widget, for widgets which can be rescaled. More...
 
virtual QSize GetMinSize (void) const
 
virtual void AdjustMinArea (int delta_x, int delta_y, int delta_w, int delta_h)
 Adjust the size of a sibling. More...
 
virtual void VanishSibling (void)
 
virtual void SetMinAreaParent (MythRect actual_area, MythRect allowed_area, MythUIType *child)
 Adjust the size of sibling objects within the button. More...
 
virtual void SetMinArea (const MythRect &rect)
 Set the minimum area based on the given size. More...
 
virtual MythRect GetArea (void) const
 If the object has a minimum area defined, return it, other wise return the default area. More...
 
virtual MythRect GetFullArea (void) const
 
virtual void RecalculateArea (bool recurse=true)
 
void ExpandArea (QRect rect)
 
virtual QRegion GetDirtyArea (void) const
 
bool IsVisible (bool recurse=false) const
 
virtual void SetVisible (bool visible)
 
void MoveTo (QPoint destXY, QPoint speedXY)
 
void AdjustAlpha (int mode, int alphachange, int minalpha=0, int maxalpha=255)
 
void SetAlpha (int newalpha)
 
int GetAlpha (void) const
 
virtual bool keyPressEvent (QKeyEvent *event)
 Key event handler. More...
 
virtual bool inputMethodEvent (QInputMethodEvent *event)
 Input Method event handler. More...
 
virtual bool gestureEvent (MythGestureEvent *event)
 Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop. More...
 
virtual void mediaEvent (MythMediaEvent *event)
 Media/Device status event handler, received from MythMediaMonitor. More...
 
MythFontPropertiesGetFont (const QString &text) const
 
bool AddFont (const QString &text, MythFontProperties *fontProp)
 
void SetHelpText (const QString &text)
 
QString GetHelpText (void) const
 
void SetXMLLocation (const QString &filename, int where)
 
QString GetXMLLocation (void) const
 
void SetXMLName (const QString &name)
 
QString GetXMLName (void) const
 
bool IsDeferredLoading (bool recurse=false) const
 
void SetDeferLoad (bool defer)
 
virtual void LoadNow (void)
 Cause images in this and child widgets to be loaded. More...
 
bool ContainsPoint (QPoint point) const
 Check if the given point falls within this widgets area. More...
 
virtual MythPainterGetPainter (void)
 
void SetPainter (MythPainter *painter)
 
void SetCentre (UIEffects::Centre centre)
 
void SetZoom (float zoom)
 
void SetHorizontalZoom (float zoom)
 
void SetVerticalZoom (float zoom)
 
void SetAngle (float angle)
 
void SetDependIsDefault (bool isDefault)
 
void SetReverseDependence (MythUIType *dependee, bool reverse)
 
void SetDependsMap (QMap< QString, QString > dependsMap)
 
QMap< QString, QString > GetDependsMap () const
 
- Public Member Functions inherited from StorageUser
virtual ~StorageUser ()=default
 

Protected Member Functions

bool ParseElement (const QString &filename, QDomElement &element, bool showWarnings) override
 Parse the xml definition of this widget setting the state of the object accordingly. More...
 
void CopyFrom (MythUIType *base) override
 Copy this widgets state from another. More...
 
void CreateCopy (MythUIType *parent) override
 Copy the state of this widget to the one given, it must be of the same type. More...
 
QString GetTimeText (void)
 This creates a string based on m_time, and sets m_nextUpdate to the second following m_time. More...
 
- Protected Member Functions inherited from MythUIText
void DrawSelf (MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
 
bool ParseElement (const QString &filename, QDomElement &element, bool showWarnings) override
 Parse the xml definition of this widget setting the state of the object accordingly. More...
 
void CopyFrom (MythUIType *base) override
 Copy this widgets state from another. More...
 
void CreateCopy (MythUIType *parent) override
 Copy the state of this widget to the one given, it must be of the same type. More...
 
void Finalize (void) override
 Perform any post-xml parsing initialisation tasks. More...
 
void SetFontProperties (const MythFontProperties &fontProps)
 
const MythFontPropertiesGetFontProperties ()
 
void CycleColor (const QColor &startColor, const QColor &endColor, int numSteps)
 
void StopCycling ()
 
int GetJustification (void) const
 
void SetCutDown (Qt::TextElideMode mode)
 
Qt::TextElideMode GetCutDown (void) const
 
void SetMultiLine (bool multiline)
 
bool GetMultiLine (void) const
 
void SetArea (const MythRect &rect) override
 
void SetPosition (const MythPoint &pos) override
 
MythRect GetDrawRect (void)
 
void SetCanvasPosition (int x, int y)
 
void ShiftCanvas (int x, int y)
 
bool FormatTemplate (QString &paragraph, QTextLayout *layout)
 
bool Layout (QString &paragraph, QTextLayout *layout, bool final, bool &overflow, qreal width, qreal &height, bool force, qreal &last_line_width, QRectF &min_rect, int &num_lines)
 
bool LayoutParagraphs (const QStringList &paragraphs, const QTextOption &textoption, qreal width, qreal &height, QRectF &min_rect, qreal &last_line_width, int &num_lines, bool final)
 
bool GetNarrowWidth (const QStringList &paragraphs, const QTextOption &textoption, qreal &width)
 
void FillCutMessage (void)
 
- Protected Member Functions inherited from MythUIType
 ~MythUIType () override
 
void customEvent (QEvent *event) override
 
void AddFocusableChildrenToList (FocusInfoType &focusList)
 
void HandleAlphaPulse ()
 Handle one frame of an alpha (transparency) change animation. More...
 
void HandleMovementPulse ()
 Handle one frame of a movement animation. More...
 
int CalcAlpha (int alphamod) const
 
void ConnectDependants (bool recurse=false)
 

Protected Attributes

QDateTime m_time
 
QDateTime m_nextUpdate
 
QString m_format
 
QString m_timeFormat {"h:mm ap"}
 
QString m_dateFormat {"ddd d MMM yyyy"}
 
QString m_shortDateFormat {"ddd M/d"}
 
bool m_flash {false}
 
- Protected Attributes inherited from MythUIText
int m_justification {Qt::AlignLeft | Qt::AlignTop}
 
MythRect m_origDisplayRect
 
MythRect m_altDisplayRect
 
MythRect m_canvas
 
MythRect m_drawRect
 
QPoint m_cursorPos {-1,-1}
 
QString m_message
 
QString m_cutMessage
 
QString m_defaultMessage
 
QString m_templateText
 
bool m_shrinkNarrow {true}
 
Qt::TextElideMode m_cutdown {Qt::ElideRight}
 
bool m_multiLine {false}
 
int m_ascent {0}
 
int m_descent {0}
 
int m_leftBearing {0}
 
int m_rightBearing {0}
 
int m_leading {1}
 
int m_extraLeading {0}
 
int m_lineHeight {0}
 
int m_textCursor {-1}
 
QVector< QTextLayout * > m_layouts
 
MythFontPropertiesm_font {nullptr}
 
FontStates m_fontStates
 
bool m_colorCycling {false}
 
QColor m_startColor
 
QColor m_endColor
 
int m_numSteps {0}
 
int m_curStep {0}
 
float m_curR {0.0}
 
float m_curG {0.0}
 
float m_curB {0.0}
 
float m_incR {0.0}
 
float m_incG {0.0}
 
float m_incB {0.0}
 
int m_scrollStartDelay {ScrollBounceDelay}
 
int m_scrollReturnDelay {ScrollBounceDelay}
 
float m_scrollPause {0.0}
 
float m_scrollForwardRate {1.0}
 
float m_scrollReturnRate {1.0}
 
bool m_scrollBounce {false}
 
int m_scrollOffset {0}
 
float m_scrollPos {0}
 
int m_scrollPosWhole {0}
 
ScrollDir m_scrollDirection {ScrollNone}
 
bool m_scrolling {false}
 
int64_t m_lastUpdate {QDateTime::currentMSecsSinceEpoch()}
 
TextCase m_textCase {CaseNormal}
 
- Protected Attributes inherited from MythUIType
QList< MythUIType * > m_childrenList
 
QMap< QString, QString > m_dependsMap
 
QList< QPair< MythUIType *, bool > > m_dependsValue
 
QList< int > m_dependOperator
 
bool m_visible {true}
 
bool m_hasFocus {false}
 
bool m_canHaveFocus {false}
 
bool m_enabled {true}
 
bool m_enableInitiator {false}
 
bool m_initiator {false}
 
bool m_vanish {false}
 
bool m_vanished {false}
 
bool m_isDependDefault {false}
 
QMap< MythUIType *, boolm_reverseDepend
 
int m_focusOrder {0}
 
MythRect m_area {0,0,0,0}
 
MythRect m_minArea {0,0,0,0}
 
MythPoint m_minSize
 
QRegion m_dirtyRegion {0,0,0,0}
 
bool m_needsRedraw {false}
 
UIEffects m_effects
 
int m_alphaChangeMode {0}
 
int m_alphaChange {0}
 
int m_alphaMin {0}
 
int m_alphaMax {255}
 
bool m_moving {false}
 
QPoint m_xyDestination {0,0}
 
QPoint m_xySpeed {0,0}
 
FontMapm_fonts {nullptr}
 
MythUITypem_parent {nullptr}
 
MythPainterm_painter {nullptr}
 
QList< MythUIAnimation * > m_animations
 
QString m_helptext
 
QString m_xmlName
 
QString m_xmlLocation
 
bool m_deferload {false}
 
QColor m_borderColor {Qt::black}
 

Additional Inherited Members

- Public Slots inherited from MythUIType
void LoseFocus ()
 
bool TakeFocus ()
 
void Activate ()
 
void Hide (void)
 
void Show (void)
 
void Refresh (void)
 
void UpdateDependState (bool isDefault)
 
void UpdateDependState (MythUIType *dependee, bool isDefault)
 
- Signals inherited from MythUIType
void RequestUpdate ()
 
void RequestRegionUpdate (const QRect &)
 
void TakingFocus ()
 
void LosingFocus ()
 
void VisibilityChanged (bool Visible)
 
void Showing ()
 
void Hiding ()
 
void Enabling ()
 
void Disabling ()
 
void FinishedMoving ()
 
void FinishedFading ()
 
void DependChanged (bool isDefault)
 
- Static Public Member Functions inherited from XMLParseBase
static QString getFirstText (QDomElement &element)
 
static bool parseBool (const QString &text)
 
static bool parseBool (QDomElement &element)
 
static MythPoint parsePoint (const QString &text, bool normalize=true)
 
static MythPoint parsePoint (QDomElement &element, bool normalize=true)
 
static QSize parseSize (const QString &text, bool normalize=true)
 
static QSize parseSize (QDomElement &element, bool normalize=true)
 
static MythRect parseRect (const QString &text, bool normalize=true)
 
static MythRect parseRect (QDomElement &element, bool normalize=true)
 
static int parseAlignment (const QString &text)
 
static int parseAlignment (QDomElement &element)
 
static QBrush parseGradient (const QDomElement &element)
 
static QString parseText (QDomElement &element)
 
static MythUITypeGetGlobalObjectStore (void)
 
static void ClearGlobalObjectStore (void)
 
static void ParseChildren (const QString &filename, QDomElement &element, MythUIType *parent, bool showWarnings)
 
static MythUITypeParseUIType (const QString &filename, QDomElement &element, const QString &type, MythUIType *parent, MythScreenType *screen, bool showWarnings, QMap< QString, QString > &parentDependsMap)
 
static bool WindowExists (const QString &xmlfile, const QString &windowname)
 
static bool LoadWindowFromXML (const QString &xmlfile, const QString &windowname, MythUIType *parent)
 
static bool LoadBaseTheme (void)
 
static bool LoadBaseTheme (const QString &baseTheme)
 
static bool CopyWindowFromBase (const QString &windowname, MythScreenType *win)
 
- Protected Types inherited from MythUIText
enum  Constants { ScrollBounceDelay = DEFAULT_REFRESH_RATE * 3 }
 
enum  ScrollDir {
  ScrollNone, ScrollLeft, ScrollRight, ScrollUp,
  ScrollDown, ScrollHorizontal, ScrollVertical
}
 
enum  TextCase {
  CaseNormal, CaseUpper, CaseLower, CaseCapitaliseFirst,
  CaseCapitaliseAll
}
 
- Static Protected Member Functions inherited from MythUIType
static int NormX (int width)
 
static int NormY (int height)
 

Detailed Description

A simple text clock widget.

Updates once a second and inherits from MythUIText, so it supports all the text styles and decorations offered by that class.

Basic manipulation of the clock format is supported using any of the following in the "format" element of the theme: TIME% - The time, in a format defined in the locale settings DATE% - Long date format, as defined in the locale settings SHORTDATE% - Short date format, as defined in the locale settings

Definition at line 25 of file mythuiclock.h.

Constructor & Destructor Documentation

◆ MythUIClock()

MythUIClock::MythUIClock ( MythUIType parent,
const QString &  name 
)

Definition at line 16 of file mythuiclock.cpp.

Referenced by CreateCopy().

◆ ~MythUIClock()

MythUIClock::~MythUIClock ( )
override

Definition at line 25 of file mythuiclock.cpp.

Member Function Documentation

◆ Pulse()

void MythUIClock::Pulse ( void  )
overridevirtual

Looks up the time and sets the clock if the current time is greater than or equal to m_nextUpdate.

Reimplemented from MythUIType.

Definition at line 34 of file mythuiclock.cpp.

◆ SetText()

void MythUIClock::SetText ( const QString &  text)
overridevirtual

This sets the text, unless the string is blank, in that case the time is looked up and set as the text instead.

Reimplemented from MythUIText.

Definition at line 67 of file mythuiclock.cpp.

◆ ParseElement()

bool MythUIClock::ParseElement ( const QString &  filename,
QDomElement &  element,
bool  showWarnings 
)
overrideprotectedvirtual

Parse the xml definition of this widget setting the state of the object accordingly.

Reimplemented from MythUIType.

Definition at line 83 of file mythuiclock.cpp.

◆ CopyFrom()

void MythUIClock::CopyFrom ( MythUIType base)
overrideprotectedvirtual

Copy this widgets state from another.

Reimplemented from MythUIType.

Definition at line 109 of file mythuiclock.cpp.

◆ CreateCopy()

void MythUIClock::CreateCopy ( MythUIType parent)
overrideprotectedvirtual

Copy the state of this widget to the one given, it must be of the same type.

Reimplemented from MythUIType.

Definition at line 135 of file mythuiclock.cpp.

◆ GetTimeText()

QString MythUIClock::GetTimeText ( void  )
protected

This creates a string based on m_time, and sets m_nextUpdate to the second following m_time.

It's important to note that this function do not look up the wall clock time, but depends on m_time being set ahead of time.

Definition at line 51 of file mythuiclock.cpp.

Referenced by Pulse(), and SetText().

Member Data Documentation

◆ m_time

QDateTime MythUIClock::m_time
protected

Definition at line 42 of file mythuiclock.h.

Referenced by CopyFrom(), GetTimeText(), Pulse(), and SetText().

◆ m_nextUpdate

QDateTime MythUIClock::m_nextUpdate
protected

Definition at line 43 of file mythuiclock.h.

Referenced by CopyFrom(), GetTimeText(), and Pulse().

◆ m_format

QString MythUIClock::m_format
protected

Definition at line 45 of file mythuiclock.h.

Referenced by CopyFrom(), GetTimeText(), MythUIClock(), and ParseElement().

◆ m_timeFormat

QString MythUIClock::m_timeFormat {"h:mm ap"}
protected

Definition at line 46 of file mythuiclock.h.

Referenced by CopyFrom(), MythUIClock(), and ParseElement().

◆ m_dateFormat

QString MythUIClock::m_dateFormat {"ddd d MMM yyyy"}
protected

Definition at line 47 of file mythuiclock.h.

Referenced by CopyFrom(), MythUIClock(), and ParseElement().

◆ m_shortDateFormat

QString MythUIClock::m_shortDateFormat {"ddd M/d"}
protected

Definition at line 48 of file mythuiclock.h.

Referenced by CopyFrom(), and ParseElement().

◆ m_flash

bool MythUIClock::m_flash {false}
protected

Definition at line 50 of file mythuiclock.h.

Referenced by CopyFrom().


The documentation for this class was generated from the following files: