Ticket #762: progdetails-speed.patch

File progdetails-speed.patch, 4.2 KB (added by mythtv@…, 20 years ago)

proposed patch

  • libs/libmyth/uitypes.h

     
    666666    protected:
    667667        void refreshImage();
    668668        void updateBackground();
     669        void loadBackgroundImg(bool &changed);
    669670
    670671        QRect m_displayArea;
    671672        QRect m_textArea;
     
    684685                                  // widget background image
    685686        QPixmap *m_image;         // the completed image including the rich text
    686687
     688        QString m_backgroundFile; //< current source of background image
     689        QImage  m_backgroundImage; //< background image (only m_bgImage*)
     690
    687691        bool     m_showScrollArrows;
    688692        bool     m_showUpArrow;
    689693        bool     m_showDnArrow;
  • libs/libmyth/uitypes.cpp

     
    33#include <qapplication.h>
    44#include <qsimplerichtext.h>
    55#include <qbitmap.h>
     6#include <sys/time.h>
    67
    78using namespace std;
    89
     
    20532054    m_image = new QPixmap(m_displayArea.width(), m_displayArea.height(), 24);
    20542055    m_background = new QPixmap(m_displayArea.width(), m_displayArea.height(), 24);
    20552056    m_compBackground = new QPixmap(m_displayArea.width(), m_displayArea.height(), 24);
     2057    m_backgroundFile = "";
    20562058
    20572059    m_bgImageReg = m_bgImageSel = "";
    20582060    m_showScrollArrows = true;
     
    20872089    m_bgImageReg = bgImageReg;
    20882090    m_bgImageSel = bgImageSel;
    20892091
    2090     updateBackground();
     2092    bool needreload = false;
     2093    loadBackgroundImg(needreload);
     2094    if (needreload) updateBackground();
    20912095}
    20922096
    20932097void UIRichTextType::SetBackground(QPixmap *background)
     
    20982102    updateBackground();
    20992103}
    21002104
    2101 void UIRichTextType::updateBackground(void)
     2105void UIRichTextType::loadBackgroundImg(bool &changed)
    21022106{
    21032107    QString file = "";
     2108    changed = false;
    21042109
    21052110    file = isFocused() ? m_bgImageSel : m_bgImageReg;
    21062111
    21072112    // paint our background image over the window background
    21082113    if (file != "")
    21092114    {
    2110         if (gContext->FindThemeFile(file))
     2115        if (gContext->FindThemeFile(file) && file != m_backgroundFile)
    21112116        {
    2112             QImage *sourceImg = new QImage();
    2113             if (sourceImg->load(file))
     2117            QImage sourceImg;
     2118            if (sourceImg.load(file))
    21142119            {
    2115                 QImage scalerImg;
    2116                 scalerImg = sourceImg->smoothScale(
     2120                m_backgroundImage = sourceImg.smoothScale(
    21172121                        (int)(m_displayArea.width()),
    21182122                        (int)(m_displayArea.height()));
    2119                 QPainter p(m_compBackground);
    2120                 p.drawPixmap(QPoint(0, 0), *m_background);
    2121                 p.drawImage(QPoint(0, 0), scalerImg);
     2123                m_backgroundFile = file;
     2124                changed = true;
    21222125            }
    2123             delete sourceImg;
    21242126        }
    21252127    }
     2128}
     2129
     2130void UIRichTextType::updateBackground(void)
     2131{
     2132    // paint our background image over the window background
     2133    QPainter p(m_compBackground);
     2134    if (m_background) p.drawPixmap(QPoint(0, 0), *m_background);
     2135    if (!m_backgroundFile.isEmpty())
     2136        p.drawImage(QPoint(0, 0), m_backgroundImage);
    21262137    refreshImage();
    21272138}
    21282139
     
    22482259bool UIRichTextType::takeFocus()
    22492260{
    22502261    bool res = UIType::takeFocus();
    2251     updateBackground();
     2262    bool needreload = false;
     2263    loadBackgroundImg(needreload);
     2264    if (needreload) updateBackground();
    22522265
    22532266    return res;
    22542267}
     
    22562269void UIRichTextType::looseFocus()
    22572270{
    22582271    UIType::looseFocus();
    2259 
    2260     updateBackground();
     2272    bool needreload = false;
     2273    loadBackgroundImg(needreload);
     2274    if (needreload) updateBackground();
    22612275}
    22622276
    22632277// ******************************************************************
  • libs/libmythtv/progdetails.cpp

     
    3434    if (m_richText)
    3535    {
    3636        m_richText->SetText(m_details);
    37         m_richText->SetBackground(&my_background);
    3837    }
    3938}
    4039