Ticket #1393: mythtv.wide.diff
File mythtv.wide.diff, 15.8 KB (added by , 18 years ago) |
---|
-
libs/libmyth/mythcontext.h
293 293 294 294 QString FindThemeDir(const QString &themename); 295 295 QString GetThemeDir(void); 296 QValueList<QString> GetThemeSearchPath(void); 296 297 297 298 QString GetMenuThemeDir(void); 298 299 -
libs/libmyth/xmlparse.cpp
33 33 34 34 fontSizeType = gContext->GetSetting("ThemeFontSizeType", "default"); 35 35 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 } 52 46 } 53 47 54 48 return false; … … 665 659 666 660 bool XMLParse::parseDefaultCategoryColors(QMap<QString, QString> &catColors) 667 661 { 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++) 674 666 { 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()); 676 674 return false; 677 675 } 678 676 677 QDomDocument doc; 679 678 QString errorMsg; 680 679 int errorLine = 0; 681 680 int errorColumn = 0; 682 681 683 682 if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn)) 684 683 { 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); 688 687 f.close(); 689 690 688 return false; 691 689 } 692 690 … … 3855 3853 } 3856 3854 } 3857 3855 } 3856 3857 // vim:set sw=4 expandtab: -
libs/libmyth/uitypes.cpp
387 387 388 388 void UIBarType::LoadImage(int loc, QString myFile) 389 389 { 390 QImage sourceImg; 391 int doX = 0; 392 int doY = 0; 393 QImage scalerImg; 394 390 395 if (m_size == 0) 391 396 { 392 cerr << "uitypes.cpp:UIBarType:LoadImage:m_size == 0";397 VERBOSE(VB_IMPORTANT, "uitypes.cpp:UIBarType:LoadImage:m_size == 0"); 393 398 return; 394 399 } 395 400 QString filename = m_filename; 396 401 if (loc != -1) 397 402 filename = myFile; 398 403 399 QString file; 404 QString file = filename; 405 if (!gContext->FindThemeFile(file)) 406 goto error; 400 407 401 QString themeDir = gContext->GetThemeDir();402 QString baseDir = gContext->GetShareDir() + "themes/default/";408 if (!sourceImg.load(file)) 409 goto error; 403 410 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) 423 412 { 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(); 451 415 } 452 else 416 else if (m_orientation == 2) 453 417 { 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; 457 420 } 421 if (loc != -1) 422 { 423 doX = m_iconsize.x(); 424 doY = m_iconsize.y(); 425 } 458 426 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); 460 432 433 if (m_debug == true) 434 VERBOSE(VB_IMPORTANT, " -Image: " << file << " loaded."); 435 return; 436 437 error: 438 if (m_debug == true) 439 VERBOSE(VB_IMPORTANT, " -Image: " << file << " failed to load."); 440 iconData[loc].resize(0, 0); 461 441 } 462 442 463 443 void UIBarType::Draw(QPainter *dr, int drawlayer, int context) … … 1313 1293 QString file; 1314 1294 if (m_flex == true) 1315 1295 { 1296 QString flexprefix = m_transparent ? "trans-" : "solid-"; 1316 1297 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; 1324 1300 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); 1331 1302 } 1332 1303 1333 QString themeDir = gContext->GetThemeDir(); 1334 QString baseDir = gContext->GetShareDir() + "themes/default/"; 1304 QString filename = gContext->GetThemeDir() + m_filename; 1335 1305 1336 QString filename = themeDir + m_filename;1337 1338 1306 if (m_force_x == -1 && m_force_y == -1) 1339 1307 { 1340 1308 QPixmap *tmppix = gContext->LoadScalePixmap(filename); … … 1354 1322 1355 1323 if (!gContext->FindThemeFile(file)) 1356 1324 { 1357 cerr << "UIImageType::LoadImage() - Cannot find image: " << m_filename << endl; 1325 VERBOSE(VB_IMPORTANT, "UIImageType::LoadImage() - Cannot find image: " 1326 << m_filename); 1358 1327 m_show = false; 1359 1328 return; 1360 1329 } 1361 1330 1362 1331 if (m_debug == true) 1363 cerr << " -Filename: " << file << endl;1332 VERBOSE(VB_GENERAL, " -Filename: " << file); 1364 1333 1365 1334 if (m_hmult == 1 && m_wmult == 1 && m_force_x == -1 && m_force_y == -1) 1366 1335 { … … 1379 1348 { 1380 1349 doX = m_force_x; 1381 1350 if (m_debug == true) 1382 cerr << " +Force X: " << doX << endl;1351 VERBOSE(VB_GENERAL, " +Force X: " << doX); 1383 1352 } 1384 1353 if (m_force_y != -1) 1385 1354 { 1386 1355 doY = m_force_y; 1387 1356 if (m_debug == true) 1388 cerr << " +Force Y: " << doY << endl;1357 VERBOSE(VB_GENERAL, " +Force Y: " << doY); 1389 1358 } 1390 1359 1391 1360 scalerImg = sourceImg->smoothScale((int)(doX * m_wmult), … … 1393 1362 m_show = true; 1394 1363 img.convertFromImage(scalerImg); 1395 1364 if (m_debug == true) 1396 cerr << " -Image: " << file << " loaded.\n";1365 VERBOSE(VB_GENERAL, " -Image: " << file << " loaded."); 1397 1366 } 1398 1367 else 1399 1368 { 1400 1369 m_show = false; 1401 1370 if (m_debug == true) 1402 cerr << " -Image: " << file << " failed to load.\n";1371 VERBOSE(VB_GENERAL, " -Image: " << file << " failed to load."); 1403 1372 } 1404 1373 delete sourceImg; 1405 1374 } … … 1564 1533 if (imageNo > m_imagecount) 1565 1534 return false; 1566 1535 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)) 1607 1538 return false; 1608 }1609 1539 1540 bool bSuccess = false; 1610 1541 if (m_force_x == -1 && m_force_y == -1) 1611 1542 { 1612 1543 QPixmap *tmppix = gContext->LoadScalePixmap(filename); … … 1632 1563 } 1633 1564 else 1634 1565 { 1635 QPixmap *img = new QPixmap(); 1636 QImage *sourceImg = new QImage(); 1637 1638 if (sourceImg->load(filename)) 1566 QImage sourceImg(filename); 1567 if (!sourceImg.isNull()) 1639 1568 { 1640 QImage scalerImg; 1641 int doX = sourceImg->width(); 1642 int doY = sourceImg->height(); 1569 int doX = sourceImg.width(); 1570 int doY = sourceImg.height(); 1643 1571 if (m_force_x != -1) 1644 1572 { 1645 1573 doX = m_force_x; … … 1649 1577 doY = m_force_y; 1650 1578 } 1651 1579 1652 scalerImg = sourceImg->smoothScale((int)(doX * m_wmult),1580 QImage scalerImg = sourceImg.smoothScale((int)(doX * m_wmult), 1653 1581 (int)(doY * m_hmult)); 1654 bSuccess = true; 1582 1583 QPixmap *img = new QPixmap(); 1655 1584 img->convertFromImage(scalerImg); 1656 1585 imageList->push_back(img); 1586 1587 bSuccess = true; 1657 1588 } 1658 delete sourceImg;1659 1589 } 1660 1590 1661 1591 return bSuccess; … … 5445 5375 } 5446 5376 } 5447 5377 5378 // vim:set sw=4 expandtab: -
libs/libmyth/mythcontext.cpp
1347 1347 1348 1348 void MythContext::CacheThemeImages(void) 1349 1349 { 1350 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";1351 1352 1350 if (d->m_screenwidth == d->m_baseWidth && d->m_screenheight == d->m_baseHeight) 1353 1351 return; 1354 1352 1355 1353 CacheThemeImagesDirectory(d->m_themepathname); 1356 CacheThemeImagesDirectory(baseDir); 1354 if (d->IsWideMode()) 1355 CacheThemeImagesDirectory(GetThemesParentDir() + "default-wide/"); 1356 CacheThemeImagesDirectory(GetThemesParentDir() + "default/"); 1357 1357 } 1358 1358 1359 1359 void MythContext::CacheThemeImagesDirectory(const QString &dirname, … … 1633 1633 if (dir.exists()) 1634 1634 return testdir; 1635 1635 1636 testdir = d->m_installprefix + "/share/mythtv/themes/"+ themename;1636 testdir = GetThemesParentDir() + themename; 1637 1637 dir.setPath(testdir); 1638 1638 if (dir.exists()) 1639 1639 return testdir; … … 1647 1647 // Don't complain about the "default" theme being missing 1648 1648 if (themename == QObject::tr("Default")) 1649 1649 { 1650 testdir = d->m_installprefix + "/share/mythtv/";1650 testdir = GetShareDir(); 1651 1651 dir.setPath(testdir); 1652 1652 if (dir.exists()) 1653 1653 return testdir; 1654 1654 } 1655 1655 1656 testdir = d->m_installprefix + "/share/mythtv/themes/G.A.N.T.";1656 testdir = GetThemesParentDir() + "G.A.N.T."; 1657 1657 dir.setPath(testdir); 1658 1658 if (dir.exists()) 1659 1659 return testdir; … … 1671 1671 return d->m_themepathname; 1672 1672 } 1673 1673 1674 QValueList<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 1674 1686 MDBManager *MythContext::GetDBManager(void) 1675 1687 { 1676 1688 return &d->m_dbmanager; … … 2020 2032 2021 2033 bool MythContext::FindThemeFile(QString &filename) 2022 2034 { 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 2025 2039 int pathStart = filename.findRev('/'); 2026 bool bFound = false; 2040 QString basename; 2041 if (pathStart > 0) 2042 basename = filename.mid(pathStart + 1); 2027 2043 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++) 2034 2048 { 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; 2037 2053 } 2038 2054 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; 2045 2056 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 2057 found: 2069 2058 filename = file; 2070 2059 return true; 2071 2060 } … … 2074 2063 { 2075 2064 if (filename.left(5) == "myth:") 2076 2065 return NULL; 2077 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";2078 2066 2079 2067 if (d->themecachedir != "" && fromcache) 2080 2068 { … … 2168 2156 { 2169 2157 if (filename.left(5) == "myth:") 2170 2158 return NULL; 2171 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";2172 2159 2173 2160 if (d->themecachedir != "" && fromcache) 2174 2161 { … … 2816 2803 return currentLocation.last(); 2817 2804 } 2818 2805 2806 // vim:set sw=4 expandtab: