Ticket #1393: mythtv.wide.diff

File mythtv.wide.diff, 15.8 KB (added by Robert Tsai <rtsai1111>, 18 years ago)
  • libs/libmyth/mythcontext.h

     
    293293
    294294    QString FindThemeDir(const QString &themename);
    295295    QString GetThemeDir(void);
     296    QValueList<QString> GetThemeSearchPath(void);
    296297
    297298    QString GetMenuThemeDir(void);
    298299
  • libs/libmyth/xmlparse.cpp

     
    3333
    3434    fontSizeType = gContext->GetSetting("ThemeFontSizeType", "default");
    3535
    36    
    37     // first try to load the theme from the current theme directory
    38     QString themepath = gContext->GetThemeDir();
    39     QString themefile = themepath + specialfile + "ui.xml";
    40      
    41     if (doLoadTheme(ele, winName, themefile))
    42         return true;
    43        
    44     // not found so now try the default theme directory
    45     themepath = gContext->GetShareDir() + "themes/default/";
    46     themefile = themepath + specialfile + "ui.xml";
    47 
    48     if (doLoadTheme(ele, winName, themefile))
    49     {   
    50         //cout << "XMLParse::LoadTheme(): Using default theme file" << endl;
    51         return true;
     36    QValueList<QString> searchpath = gContext->GetThemeSearchPath();
     37    for (QValueList<QString>::const_iterator ii = searchpath.begin();
     38        ii != searchpath.end(); ii++)
     39    {
     40        QString themefile = *ii + specialfile + "ui.xml";
     41        if (doLoadTheme(ele, winName, themefile))
     42        {
     43            VERBOSE(VB_GENERAL, "XMLParse::LoadTheme using " << themefile);
     44            return true;
     45        }
    5246    }
    5347   
    5448    return false;
     
    665659
    666660bool XMLParse::parseDefaultCategoryColors(QMap<QString, QString> &catColors)
    667661{
    668     QString catColorFile = gContext->GetThemesParentDir() + "default/categories.xml";
    669    
    670     QDomDocument doc;
    671     QFile f(catColorFile);
    672    
    673     if (!f.open(IO_ReadOnly))
     662    QFile f;
     663    QValueList<QString> searchpath = gContext->GetThemeSearchPath();
     664    for (QValueList<QString>::const_iterator ii = searchpath.begin();
     665        ii != searchpath.end(); ii++)
    674666    {
    675         cerr << "Error: Unable to open " << catColorFile << endl;
     667        f.setName(*ii + "categories.xml");
     668        if (f.open(IO_ReadOnly))
     669            break;
     670    }
     671    if (f.handle() == -1)
     672    {
     673        VERBOSE(VB_IMPORTANT, "Error: Unable to open " << f.name());
    676674        return false;
    677675    }
    678    
     676
     677    QDomDocument doc;
    679678    QString errorMsg;
    680679    int errorLine = 0;
    681680    int errorColumn = 0;
    682681   
    683682    if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
    684683    {
    685         cerr << "Error parsing: " << catColorFile << endl;
    686         cerr << "at line: " << errorLine << "  column: " << errorColumn << endl;
    687         cerr << errorMsg << endl;
     684        VERBOSE(VB_IMPORTANT, "Error parsing: " << f.name()
     685                << " line: " << errorLine << "  column: " << errorColumn
     686                << ": " << errorMsg);
    688687        f.close();
    689        
    690688        return false;
    691689    }
    692690   
     
    38553853        }
    38563854    }
    38573855}
     3856
     3857// vim:set sw=4 expandtab:
  • libs/libmyth/uitypes.cpp

     
    387387
    388388void UIBarType::LoadImage(int loc, QString myFile)
    389389{
     390    QImage sourceImg;
     391    int doX = 0;
     392    int doY = 0;
     393    QImage scalerImg;
     394
    390395    if (m_size == 0)
    391396    {
    392         cerr << "uitypes.cpp:UIBarType:LoadImage:m_size == 0";
     397        VERBOSE(VB_IMPORTANT, "uitypes.cpp:UIBarType:LoadImage:m_size == 0");
    393398        return;
    394399    }
    395400    QString filename = m_filename;
    396401    if (loc != -1)
    397402        filename = myFile;
    398403
    399     QString file;
     404    QString file = filename;
     405    if (!gContext->FindThemeFile(file))
     406        goto error;
    400407
    401     QString themeDir = gContext->GetThemeDir();
    402     QString baseDir = gContext->GetShareDir() + "themes/default/";
     408    if (!sourceImg.load(file))
     409        goto error;
    403410
    404     QFile checkFile(themeDir + filename);
    405 
    406     if (checkFile.exists())
    407         file = themeDir + filename;
    408     else
    409         file = baseDir + filename;
    410     checkFile.setName(file);
    411     if (!checkFile.exists())
    412         file = "/tmp/" + filename;
    413 
    414     checkFile.setName(file);
    415     if (!checkFile.exists())
    416         file = filename;
    417 
    418     if (m_debug == true)
    419         cerr << "     -Filename: " << file << endl;
    420 
    421     QImage *sourceImg = new QImage();
    422     if (sourceImg->load(file))
     411    if (m_orientation == 1)
    423412    {
    424         QImage scalerImg;
    425         int doX = 0;
    426         int doY = 0;
    427         if (m_orientation == 1)
    428         {
    429             doX = m_displaysize.width() / m_size;
    430             doY = m_displaysize.height();
    431         }
    432         else if (m_orientation == 2)
    433         {
    434             doX = m_displaysize.width();
    435             doY = m_displaysize.height() / m_size;
    436         }
    437         if (loc != -1)
    438         {
    439             doX = m_iconsize.x();
    440             doY = m_iconsize.y();
    441         }
    442 
    443         scalerImg = sourceImg->smoothScale(doX, doY);
    444         if (loc == -1)
    445             m_image.convertFromImage(scalerImg);
    446         else
    447             iconData[loc].convertFromImage(scalerImg);
    448 
    449         if (m_debug == true)
    450             cerr << "     -Image: " << file << " loaded.\n";
     413        doX = m_displaysize.width() / m_size;
     414        doY = m_displaysize.height();
    451415    }
    452     else
     416    else if (m_orientation == 2)
    453417    {
    454       if (m_debug == true)
    455           cerr << "     -Image: " << file << " failed to load.\n";
    456       iconData[loc].resize(0, 0);
     418        doX = m_displaysize.width();
     419        doY = m_displaysize.height() / m_size;
    457420    }
     421    if (loc != -1)
     422    {
     423        doX = m_iconsize.x();
     424        doY = m_iconsize.y();
     425    }
    458426
    459     delete sourceImg;
     427    scalerImg = sourceImg.smoothScale(doX, doY);
     428    if (loc == -1)
     429        m_image.convertFromImage(scalerImg);
     430    else
     431        iconData[loc].convertFromImage(scalerImg);
    460432
     433    if (m_debug == true)
     434        VERBOSE(VB_IMPORTANT, "     -Image: " << file << " loaded.");
     435    return;
     436
     437error:
     438    if (m_debug == true)
     439        VERBOSE(VB_IMPORTANT, "     -Image: " << file << " failed to load.");
     440    iconData[loc].resize(0, 0);
    461441}
    462442
    463443void UIBarType::Draw(QPainter *dr, int drawlayer, int context)
     
    13131293    QString file;
    13141294    if (m_flex == true)
    13151295    {
     1296        QString flexprefix = m_transparent ? "trans-" : "solid-";
    13161297        int pathStart = m_filename.findRev('/');
    1317         if (m_transparent)
    1318         {
    1319             if (pathStart < 0 )
    1320                 m_filename = "trans-" + m_filename;
    1321             else
    1322                 m_filename.replace(pathStart, 1, "/trans-");
    1323         }
     1298        if (pathStart < 0 )
     1299            m_filename = flexprefix + m_filename;
    13241300        else
    1325         {
    1326             if (pathStart < 0 )
    1327                 m_filename = "solid-" + m_filename;
    1328             else
    1329                 m_filename.replace(pathStart, 1, "/solid-");
    1330         }
     1301            m_filename.replace(pathStart, 1, "/" + flexprefix);
    13311302    }
    13321303
    1333     QString themeDir = gContext->GetThemeDir();
    1334     QString baseDir = gContext->GetShareDir() + "themes/default/";
     1304    QString filename = gContext->GetThemeDir() + m_filename;
    13351305
    1336     QString filename = themeDir + m_filename;
    1337 
    13381306    if (m_force_x == -1 && m_force_y == -1)
    13391307    {
    13401308        QPixmap *tmppix = gContext->LoadScalePixmap(filename);
     
    13541322
    13551323    if (!gContext->FindThemeFile(file))
    13561324    {
    1357         cerr << "UIImageType::LoadImage() - Cannot find image: " << m_filename << endl;
     1325        VERBOSE(VB_IMPORTANT, "UIImageType::LoadImage() - Cannot find image: "
     1326                << m_filename);
    13581327        m_show = false;
    13591328        return;
    13601329    }
    13611330
    13621331    if (m_debug == true)
    1363         cerr << "     -Filename: " << file << endl;
     1332        VERBOSE(VB_GENERAL, "     -Filename: " << file);
    13641333
    13651334    if (m_hmult == 1 && m_wmult == 1 && m_force_x == -1 && m_force_y == -1)
    13661335    {
     
    13791348            {
    13801349                doX = m_force_x;
    13811350                if (m_debug == true)
    1382                     cerr << "         +Force X: " << doX << endl;
     1351                    VERBOSE(VB_GENERAL, "         +Force X: " << doX);
    13831352            }
    13841353            if (m_force_y != -1)
    13851354            {
    13861355                doY = m_force_y;
    13871356                if (m_debug == true)
    1388                     cerr << "         +Force Y: " << doY << endl;
     1357                    VERBOSE(VB_GENERAL, "         +Force Y: " << doY);
    13891358            }
    13901359
    13911360            scalerImg = sourceImg->smoothScale((int)(doX * m_wmult),
     
    13931362            m_show = true;
    13941363            img.convertFromImage(scalerImg);
    13951364            if (m_debug == true)
    1396                     cerr << "     -Image: " << file << " loaded.\n";
     1365                VERBOSE(VB_GENERAL, "     -Image: " << file << " loaded.");
    13971366        }
    13981367        else
    13991368        {
    14001369            m_show = false;
    14011370            if (m_debug == true)
    1402                 cerr << "     -Image: " << file << " failed to load.\n";
     1371                VERBOSE(VB_GENERAL, "     -Image: " << file << " failed to load.");
    14031372        }
    14041373        delete sourceImg;
    14051374    }
     
    15641533    if (imageNo > m_imagecount)
    15651534        return false;
    15661535
    1567     bool bSuccess = false;
    1568     QString file;
    1569 
    1570     file = m_filename.arg(imageNo);
    1571 
    1572     // first try the absolute filename
    1573     bool  filefound = false;
    1574     QString filename;
    1575     QString themeDir = gContext->GetThemeDir();
    1576     QString baseDir = gContext->GetShareDir() + "themes/default/";
    1577     QFile checkFile(file);
    1578 
    1579     if (checkFile.exists())
    1580     {
    1581         filefound = true;
    1582         filename = file;
    1583     }
    1584 
    1585     if (!filefound)
    1586     {
    1587         checkFile.setName(baseDir + file);
    1588         if (checkFile.exists())
    1589         {
    1590             filefound = true;
    1591             filename = baseDir + file;
    1592         }
    1593     }
    1594 
    1595     if (!filefound)
    1596     {
    1597         checkFile.setName(themeDir + file);
    1598         if (checkFile.exists())
    1599         {
    1600             filefound = true;
    1601             filename = themeDir + file;
    1602         }
    1603     }
    1604 
    1605     if (!filefound)
    1606     {
     1536    QString filename = m_filename.arg(imageNo);
     1537    if (!gContext->FindThemeFile(filename))
    16071538         return false;
    1608     }
    16091539
     1540    bool bSuccess = false;
    16101541    if (m_force_x == -1 && m_force_y == -1)
    16111542    {
    16121543        QPixmap *tmppix = gContext->LoadScalePixmap(filename);
     
    16321563    }
    16331564    else
    16341565    {
    1635         QPixmap *img = new QPixmap();
    1636         QImage *sourceImg = new QImage();
    1637 
    1638         if (sourceImg->load(filename))
     1566        QImage sourceImg(filename);
     1567        if (!sourceImg.isNull())
    16391568        {
    1640             QImage scalerImg;
    1641             int doX = sourceImg->width();
    1642             int doY = sourceImg->height();
     1569            int doX = sourceImg.width();
     1570            int doY = sourceImg.height();
    16431571            if (m_force_x != -1)
    16441572            {
    16451573                doX = m_force_x;
     
    16491577                doY = m_force_y;
    16501578            }
    16511579
    1652             scalerImg = sourceImg->smoothScale((int)(doX * m_wmult),
     1580            QImage scalerImg = sourceImg.smoothScale((int)(doX * m_wmult),
    16531581                                               (int)(doY * m_hmult));
    1654             bSuccess = true;
     1582
     1583            QPixmap *img = new QPixmap();
    16551584            img->convertFromImage(scalerImg);
    16561585            imageList->push_back(img);
     1586
     1587            bSuccess = true;
    16571588        }
    1658         delete sourceImg;
    16591589    }
    16601590
    16611591    return bSuccess;
     
    54455375    }
    54465376}
    54475377
     5378// vim:set sw=4 expandtab:
  • libs/libmyth/mythcontext.cpp

     
    13471347   
    13481348void MythContext::CacheThemeImages(void)
    13491349{
    1350     QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
    1351 
    13521350    if (d->m_screenwidth == d->m_baseWidth && d->m_screenheight == d->m_baseHeight)
    13531351        return;
    13541352
    13551353    CacheThemeImagesDirectory(d->m_themepathname);
    1356     CacheThemeImagesDirectory(baseDir);
     1354    if (d->IsWideMode())
     1355        CacheThemeImagesDirectory(GetThemesParentDir() + "default-wide/");
     1356    CacheThemeImagesDirectory(GetThemesParentDir() + "default/");
    13571357}
    13581358
    13591359void MythContext::CacheThemeImagesDirectory(const QString &dirname,
     
    16331633    if (dir.exists())
    16341634        return testdir;
    16351635
    1636     testdir = d->m_installprefix + "/share/mythtv/themes/" + themename;
     1636    testdir = GetThemesParentDir() + themename;
    16371637    dir.setPath(testdir);
    16381638    if (dir.exists())
    16391639        return testdir;
     
    16471647    // Don't complain about the "default" theme being missing
    16481648    if (themename == QObject::tr("Default"))
    16491649    {
    1650         testdir = d->m_installprefix + "/share/mythtv/";
     1650        testdir = GetShareDir();
    16511651        dir.setPath(testdir);
    16521652        if (dir.exists())
    16531653            return testdir;
    16541654    }
    16551655
    1656     testdir = d->m_installprefix + "/share/mythtv/themes/G.A.N.T.";
     1656    testdir = GetThemesParentDir() + "G.A.N.T.";
    16571657    dir.setPath(testdir);
    16581658    if (dir.exists())
    16591659        return testdir;
     
    16711671    return d->m_themepathname;
    16721672}
    16731673
     1674QValueList<QString> MythContext::GetThemeSearchPath(void)
     1675{
     1676    QValueList<QString> searchpath;
     1677
     1678    searchpath.append(GetThemeDir());
     1679    if (d->IsWideMode())
     1680        searchpath.append(GetThemesParentDir() + "default-wide/");
     1681    searchpath.append(GetThemesParentDir() + "default/");
     1682    searchpath.append("/tmp/");
     1683    return searchpath;
     1684}
     1685
    16741686MDBManager *MythContext::GetDBManager(void)
    16751687{
    16761688    return &d->m_dbmanager;
     
    20202032
    20212033bool MythContext::FindThemeFile(QString &filename)
    20222034{
    2023     QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
    2024     QString file;
     2035    // Given a full path, or in current working directory?
     2036    if (QFile::exists(filename))
     2037        return true;
     2038
    20252039    int pathStart = filename.findRev('/');
    2026     bool bFound = false;
     2040    QString basename;
     2041    if (pathStart > 0)
     2042        basename = filename.mid(pathStart + 1);
    20272043
    2028     // Given a full path?
    2029     file = filename;
    2030     bFound = QFile::exists(file);
    2031 
    2032     // look in theme directory first including any sub directory
    2033     if (!bFound)
     2044    QString file;
     2045    QValueList<QString> searchpath = GetThemeSearchPath();
     2046    for (QValueList<QString>::const_iterator ii = searchpath.begin();
     2047        ii != searchpath.end(); ii++)
    20342048    {
    2035         file = d->m_themepathname + filename;
    2036         bFound = QFile::exists(file);
     2049        if (QFile::exists((file = *ii + filename)))
     2050            goto found;
     2051        if (pathStart > 0 && QFile::exists((file = *ii + basename)))
     2052            goto found;
    20372053    }
    20382054
    2039     if (!bFound && pathStart > 0)
    2040     {
    2041         // look in theme directory minus any sub directories
    2042         file = d->m_themepathname + filename.mid(pathStart + 1);
    2043         bFound = QFile::exists(file);
    2044     }
     2055    return false;
    20452056
    2046     // look in default theme directory
    2047     if (!bFound)
    2048     {
    2049         file = baseDir + filename;
    2050         bFound = QFile::exists(file);
    2051     }
    2052 
    2053     if (!bFound && pathStart > 0)
    2054     {
    2055         file = baseDir + filename.mid(pathStart + 1);
    2056         bFound = QFile::exists(file);
    2057     }
    2058 
    2059     // look in tmp directory
    2060     if (!bFound)
    2061     {
    2062         file = "/tmp/" + filename;
    2063         bFound = QFile::exists(file);
    2064     }
    2065 
    2066     if (!bFound)
    2067         return false;
    2068 
     2057found:
    20692058    filename = file;
    20702059    return true;
    20712060}
     
    20742063{
    20752064    if (filename.left(5) == "myth:")
    20762065        return NULL;
    2077     QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
    20782066
    20792067    if (d->themecachedir != "" && fromcache)
    20802068    {
     
    21682156{
    21692157    if (filename.left(5) == "myth:")
    21702158        return NULL;
    2171     QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";
    21722159
    21732160    if (d->themecachedir != "" && fromcache)
    21742161    {
     
    28162803    return currentLocation.last();
    28172804}
    28182805
     2806// vim:set sw=4 expandtab: