Ticket #1393: mythtv.wide.2.diff
File mythtv.wide.2.diff, 16.0 KB (added by , 18 years ago) |
---|
-
libs/libmyth/mythcontext.h
294 294 295 295 QString FindThemeDir(const QString &themename); 296 296 QString GetThemeDir(void); 297 QValueList<QString> GetThemeSearchPath(void); 297 298 298 299 QString GetMenuThemeDir(void); 299 300 -
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 true; 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; … … 5444 5374 } 5445 5375 } 5446 5376 5377 // vim:set sw=4 expandtab: -
libs/libmyth/mythcontext.cpp
1359 1359 1360 1360 void MythContext::CacheThemeImages(void) 1361 1361 { 1362 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";1363 1364 1362 if (d->m_screenwidth == d->m_baseWidth && d->m_screenheight == d->m_baseHeight) 1365 1363 return; 1366 1364 1367 1365 CacheThemeImagesDirectory(d->m_themepathname); 1368 CacheThemeImagesDirectory(baseDir); 1366 if (d->IsWideMode()) 1367 CacheThemeImagesDirectory(GetThemesParentDir() + "default-wide/"); 1368 CacheThemeImagesDirectory(GetThemesParentDir() + "default/"); 1369 1369 } 1370 1370 1371 1371 void MythContext::CacheThemeImagesDirectory(const QString &dirname, … … 1645 1645 if (dir.exists()) 1646 1646 return testdir; 1647 1647 1648 testdir = d->m_installprefix + "/share/mythtv/themes/"+ themename;1648 testdir = GetThemesParentDir() + themename; 1649 1649 dir.setPath(testdir); 1650 1650 if (dir.exists()) 1651 1651 return testdir; … … 1659 1659 // Don't complain about the "default" theme being missing 1660 1660 if (themename == QObject::tr("Default")) 1661 1661 { 1662 testdir = d->m_installprefix + "/share/mythtv/";1662 testdir = GetShareDir(); 1663 1663 dir.setPath(testdir); 1664 1664 if (dir.exists()) 1665 1665 return testdir; 1666 1666 } 1667 1667 1668 testdir = d->m_installprefix + "/share/mythtv/themes/G.A.N.T.";1668 testdir = GetThemesParentDir() + "G.A.N.T."; 1669 1669 dir.setPath(testdir); 1670 1670 if (dir.exists()) 1671 1671 return testdir; … … 1683 1683 return d->m_themepathname; 1684 1684 } 1685 1685 1686 QValueList<QString> MythContext::GetThemeSearchPath(void) 1687 { 1688 QValueList<QString> searchpath; 1689 1690 searchpath.append(GetThemeDir()); 1691 if (d->IsWideMode()) 1692 searchpath.append(GetThemesParentDir() + "default-wide/"); 1693 searchpath.append(GetThemesParentDir() + "default/"); 1694 searchpath.append("/tmp/"); 1695 return searchpath; 1696 } 1697 1686 1698 MDBManager *MythContext::GetDBManager(void) 1687 1699 { 1688 1700 return &d->m_dbmanager; … … 2039 2051 2040 2052 bool MythContext::FindThemeFile(QString &filename) 2041 2053 { 2042 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/"; 2043 QString file; 2054 // Given a full path, or in current working directory? 2055 if (QFile::exists(filename)) 2056 return true; 2057 2044 2058 int pathStart = filename.findRev('/'); 2045 bool bFound = false; 2059 QString basename; 2060 if (pathStart > 0) 2061 basename = filename.mid(pathStart + 1); 2046 2062 2047 // Given a full path? 2048 file = filename; 2049 bFound = QFile::exists(file); 2050 2051 // look in theme directory first including any sub directory 2052 if (!bFound) 2063 QString file; 2064 QValueList<QString> searchpath = GetThemeSearchPath(); 2065 for (QValueList<QString>::const_iterator ii = searchpath.begin(); 2066 ii != searchpath.end(); ii++) 2053 2067 { 2054 file = d->m_themepathname + filename; 2055 bFound = QFile::exists(file); 2068 if (QFile::exists((file = *ii + filename))) 2069 goto found; 2070 if (pathStart > 0 && QFile::exists((file = *ii + basename))) 2071 goto found; 2056 2072 } 2057 2073 2058 if (!bFound && pathStart > 0) 2059 { 2060 // look in theme directory minus any sub directories 2061 file = d->m_themepathname + filename.mid(pathStart + 1); 2062 bFound = QFile::exists(file); 2063 } 2074 return false; 2064 2075 2065 // look in default theme directory 2066 if (!bFound) 2067 { 2068 file = baseDir + filename; 2069 bFound = QFile::exists(file); 2070 } 2071 2072 if (!bFound && pathStart > 0) 2073 { 2074 file = baseDir + filename.mid(pathStart + 1); 2075 bFound = QFile::exists(file); 2076 } 2077 2078 // look in tmp directory 2079 if (!bFound) 2080 { 2081 file = "/tmp/" + filename; 2082 bFound = QFile::exists(file); 2083 } 2084 2085 if (!bFound) 2086 return false; 2087 2076 found: 2088 2077 filename = file; 2089 2078 return true; 2090 2079 } … … 2093 2082 { 2094 2083 if (filename.left(5) == "myth:") 2095 2084 return NULL; 2096 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";2097 2085 2098 2086 if (d->themecachedir != "" && fromcache) 2099 2087 { … … 2187 2175 { 2188 2176 if (filename.left(5) == "myth:") 2189 2177 return NULL; 2190 QString baseDir = d->m_installprefix + "/share/mythtv/themes/default/";2191 2178 2192 2179 if (d->themecachedir != "" && fromcache) 2193 2180 { … … 2726 2713 } 2727 2714 2728 2715 if (priority <= d->m_logprintlevel) 2729 VERBOSE(VB_IMPORTANT, module + ": " + message); 2716 { 2717 if (details.isEmpty()) 2718 VERBOSE(VB_IMPORTANT, module + ": " + message); 2719 else 2720 VERBOSE(VB_IMPORTANT, module + ": " + message + ": " + details); 2721 } 2730 2722 } 2731 2723 } 2732 2724