Ticket #3017: mythtv-0.20fixes-halignvaligntags.diff

File mythtv-0.20fixes-halignvaligntags.diff, 3.5 KB (added by anonymous, 19 years ago)
  • libs/libmythui/myththemedmenu.cpp

    ! Summary: Patch to add <halign> and <valign> elements to MythTV's themes
    ! Author: Dagmar d'Surreal
    ! Date: Tue Jan 30 10:13:41 CST 2007
    ! 
    ! This patch adds two more text-alignment tags to the <genericbutton> element
    ! for the MythTV theme parser.  The <centered> element is effectively obsolete
    ! with this patch.  <halign> sets the horizontal alignment of text in the
    ! button bounding boxes, with possible values of left, right, and center.
    ! <valign> sets the vertical alignment of text in the button bounding boxes,
    ! with possible values of top, bottom, and center.
    ! The curious behaviour of horizontal centering also affecting vertical
    ! centering when the language is set to Japanese has been preserved in the
    ! new <halign> element and <halign>center</halign> should in all ways behave
    ! identically to <centered>yes</centered>.
    ! 
    diff -urN mythtv-0.20-fixes-svn12674/libs/libmythui/myththemedmenu.cpp mythtv/libs/libmythui/myththemedmenu.cpp
    old new  
    517517    QString fontname = "Arial";
    518518    bool italic = false;
    519519
     520    attributes.textflags = Qt::WordBreak;
    520521    for (QDomNode child = element.firstChild(); !child.isNull();
    521522         child = child.nextSibling())
    522523    {
     
    578579                    }
    579580                }
    580581            }
     582            // halign has three possible values: center, left, and right. //
     583            else if (info.tagName() == "halign")
     584            {
     585                if (getFirstText(info) == "center")
     586                {
     587                    // Apparently Japanese is drawn along a _center_ line //
     588                    if (gContext->GetLanguage() == "ja")
     589                    {
     590                        attributes.textflags = attributes.textflags &
     591                                               ~Qt::AlignHorizontal_Mask |
     592                                               Qt::AlignCenter;
     593                    }
     594                    else
     595                    {
     596                        attributes.textflags = attributes.textflags &
     597                                               ~Qt::AlignHorizontal_Mask |
     598                                               Qt::AlignHCenter;
     599                    }
     600                }
     601                else if (getFirstText(info) == "left")
     602                {
     603                    attributes.textflags = attributes.textflags &
     604                                           ~Qt::AlignHorizontal_Mask |
     605                                           Qt::AlignLeft |
     606                                           Qt::WordBreak;
     607                }
     608                else if (getFirstText(info) == "right")
     609                {
     610                    attributes.textflags = attributes.textflags &
     611                                           ~Qt::AlignHorizontal_Mask |
     612                                           Qt::AlignRight |
     613                                           Qt::WordBreak;
     614                }
     615                else
     616                {
     617                    VERBOSE(VB_GENERAL,
     618                        QString("MythThemedMenuPrivate: Unknown value %1 "
     619                                            "for halign").arg(getFirstText(info)));
     620                }
     621            }
     622            // valign has three possible values: center, top, and bottom. //
     623            else if (info.tagName() == "valign")
     624            {
     625                if (getFirstText(info) == "center")
     626                {
     627                    attributes.textflags = attributes.textflags &
     628                                           ~Qt::AlignVertical_Mask |
     629                                           Qt::AlignVCenter;
     630                }
     631                else if (getFirstText(info) == "top")
     632                {
     633                    attributes.textflags = attributes.textflags &
     634                                           ~Qt::AlignVertical_Mask |
     635                                           Qt::AlignTop;
     636                }
     637                else if (getFirstText(info) == "bottom")
     638                {
     639                    attributes.textflags = attributes.textflags &
     640                                           ~Qt::AlignVertical_Mask |
     641                                           Qt::AlignBottom;
     642                }
     643                else
     644                {
     645                    VERBOSE(VB_GENERAL,
     646                        QString("MythThemedMenuPrivate: Unknown value %1 "
     647                                            "for valign").arg(getFirstText(info)));
     648                }
     649            }
    581650            else if (info.tagName() == "outline")
    582651            {
    583652                parseOutline(attributes, info);