Ticket #3506: reuse_button_images.2.diff
File reuse_button_images.2.diff, 5.1 KB (added by , 17 years ago) |
---|
-
mythtv/libs/libmythui/myththemedmenu.cpp
135 135 bool buttoncenter; 136 136 137 137 QMap<QString, MythImage *> titleIcons; 138 QMap<QString, MythImage *> m_loadedImages; 138 139 QString titleText; 139 140 QPoint titlePos; 140 141 … … 834 835 { 835 836 if (info.tagName() == "image") 836 837 { 838 837 839 QString titlepath = dir + getFirstText(info); 838 QImage *tmppix = gContext->LoadScaleImage(titlepath);839 840 840 if (!tmppix)841 continue;842 843 841 QString name = info.attribute("mode", ""); 844 842 if (name != "") 845 843 { 846 titleIcons[name] = MythImage::FromQImage(&tmppix); 844 MythImage *icon; 845 QImage *tmppix; 846 847 if (m_loadedImages[titlepath]) 848 { 849 icon = m_loadedImages[titlepath]; 850 icon->UpRef(); 851 } 852 else 853 { 854 tmppix = gContext->LoadScaleImage(titlepath); 855 856 if (!tmppix) 857 continue; 858 859 icon = MythImage::FromQImage(&tmppix); 860 m_loadedImages.insert(titlepath, icon); 861 } 862 863 titleIcons[name] = icon; 847 864 } 848 865 else 849 866 { … … 952 969 bool hasicon = false; 953 970 954 971 QString name = ""; 955 QImage *image = NULL; 956 QImage *activeimage = NULL; 957 QImage *watermark = NULL; 972 QImage *tmpimg = NULL; 973 MythImage *image = NULL; 974 MythImage *activeimage = NULL; 975 MythImage *watermark = NULL; 958 976 QPoint offset; 959 977 960 978 name = element.attribute("name", ""); … … 963 981 964 982 for (QDomNode child = element.firstChild(); !child.isNull(); 965 983 child = child.nextSibling()) 966 { 984 { 967 985 QDomElement info = child.toElement(); 968 986 if (!info.isNull()) 969 987 { 970 988 if (info.tagName() == "image") 971 989 { 972 QString imagepath = dir + getFirstText(info); 973 image = gContext->LoadScaleImage(imagepath); 990 QString imagepath = dir + getFirstText(info); 991 992 if (m_loadedImages[imagepath]) 993 { 994 image = m_loadedImages[imagepath]; 995 image->UpRef(); 996 } 997 else 998 { 999 tmpimg = gContext->LoadScaleImage(imagepath); 1000 image = MythImage::FromQImage(&tmpimg); 1001 m_loadedImages.insert(imagepath, image); 1002 } 1003 974 1004 if (image) 975 1005 hasicon = true; 976 1006 } 977 1007 else if (info.tagName() == "activeimage") 978 1008 { 979 1009 QString imagepath = dir + getFirstText(info); 980 activeimage = gContext->LoadScaleImage(imagepath); 1010 1011 if (m_loadedImages[imagepath]) 1012 { 1013 activeimage = m_loadedImages[imagepath]; 1014 activeimage->UpRef(); 1015 } 1016 else 1017 { 1018 tmpimg = gContext->LoadScaleImage(imagepath); 1019 activeimage = MythImage::FromQImage(&tmpimg); 1020 m_loadedImages.insert(imagepath, activeimage); 1021 } 981 1022 } 982 1023 else if (info.tagName() == "offset") 983 1024 { … … 987 1028 else if (info.tagName() == "watermarkimage") 988 1029 { 989 1030 QString imagepath = dir + getFirstText(info); 990 watermark = gContext->LoadScaleImage(imagepath); 991 } 1031 1032 if (m_loadedImages[imagepath]) 1033 { 1034 watermark = m_loadedImages[imagepath]; 1035 watermark->UpRef(); 1036 } 1037 else 1038 { 1039 tmpimg = gContext->LoadScaleImage(imagepath); 1040 watermark = MythImage::FromQImage(&tmpimg); 1041 m_loadedImages.insert(imagepath, watermark); 1042 } 1043 } 992 1044 else 993 1045 { 994 1046 VERBOSE(VB_GENERAL, QString("MythThemedMenuPrivate: Unknown tag %1 " … … 1021 1073 ButtonIcon newbutton; 1022 1074 1023 1075 newbutton.name = name; 1024 newbutton.icon = MythImage::FromQImage(&image);1076 newbutton.icon = image; 1025 1077 newbutton.offset = offset; 1026 newbutton.activeicon = MythImage::FromQImage(&activeimage);1078 newbutton.activeicon = activeimage; 1027 1079 1028 1080 if (watermark) 1029 1081 { … … 1034 1086 watermarkRect.setHeight(watermark->height()); 1035 1087 } 1036 1088 1037 newbutton.watermark = MythImage::FromQImage(&watermark);1089 newbutton.watermark = watermark; 1038 1090 1039 1091 allButtonIcons[name] = newbutton; 1092 1093 if (tmpimg) 1094 delete tmpimg; 1040 1095 } 1041 1096 1042 1097 void MythThemedMenuState::setDefaults(void)