Ticket #3506: reuse_button_images.diff
File reuse_button_images.diff, 3.9 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_buttonImages; 138 139 QString titleText; 139 140 QPoint titlePos; 140 141 … … 952 953 bool hasicon = false; 953 954 954 955 QString name = ""; 955 QImage *image = NULL; 956 QImage *activeimage = NULL; 957 QImage *watermark = NULL; 956 QImage *tmpimg = NULL; 957 MythImage *image = NULL; 958 MythImage *activeimage = NULL; 959 MythImage *watermark = NULL; 958 960 QPoint offset; 959 961 960 962 name = element.attribute("name", ""); … … 963 965 964 966 for (QDomNode child = element.firstChild(); !child.isNull(); 965 967 child = child.nextSibling()) 966 { 968 { 967 969 QDomElement info = child.toElement(); 968 970 if (!info.isNull()) 969 971 { 970 972 if (info.tagName() == "image") 971 973 { 972 QString imagepath = dir + getFirstText(info); 973 image = gContext->LoadScaleImage(imagepath); 974 QString imagepath = dir + getFirstText(info); 975 976 if (m_buttonImages[imagepath]) 977 { 978 image = m_buttonImages[imagepath]; 979 image->UpRef(); 980 } 981 else 982 { 983 tmpimg = gContext->LoadScaleImage(imagepath); 984 image = MythImage::FromQImage(&tmpimg); 985 m_buttonImages.insert(imagepath, image); 986 } 987 974 988 if (image) 975 989 hasicon = true; 976 990 } 977 991 else if (info.tagName() == "activeimage") 978 992 { 979 993 QString imagepath = dir + getFirstText(info); 980 activeimage = gContext->LoadScaleImage(imagepath); 994 995 if (m_buttonImages[imagepath]) 996 { 997 activeimage = m_buttonImages[imagepath]; 998 activeimage->UpRef(); 999 } 1000 else 1001 { 1002 tmpimg = gContext->LoadScaleImage(imagepath); 1003 activeimage = MythImage::FromQImage(&tmpimg); 1004 m_buttonImages.insert(imagepath, activeimage); 1005 } 981 1006 } 982 1007 else if (info.tagName() == "offset") 983 1008 { … … 987 1012 else if (info.tagName() == "watermarkimage") 988 1013 { 989 1014 QString imagepath = dir + getFirstText(info); 990 watermark = gContext->LoadScaleImage(imagepath); 991 } 1015 1016 if (m_buttonImages[imagepath]) 1017 { 1018 watermark = m_buttonImages[imagepath]; 1019 watermark->UpRef(); 1020 } 1021 else 1022 { 1023 tmpimg = gContext->LoadScaleImage(imagepath); 1024 watermark = MythImage::FromQImage(&tmpimg); 1025 m_buttonImages.insert(imagepath, watermark); 1026 } 1027 } 992 1028 else 993 1029 { 994 1030 VERBOSE(VB_GENERAL, QString("MythThemedMenuPrivate: Unknown tag %1 " … … 1021 1057 ButtonIcon newbutton; 1022 1058 1023 1059 newbutton.name = name; 1024 newbutton.icon = MythImage::FromQImage(&image);1060 newbutton.icon = image; 1025 1061 newbutton.offset = offset; 1026 newbutton.activeicon = MythImage::FromQImage(&activeimage);1062 newbutton.activeicon = activeimage; 1027 1063 1028 1064 if (watermark) 1029 1065 { … … 1034 1070 watermarkRect.setHeight(watermark->height()); 1035 1071 } 1036 1072 1037 newbutton.watermark = MythImage::FromQImage(&watermark);1073 newbutton.watermark = watermark; 1038 1074 1039 1075 allButtonIcons[name] = newbutton; 1076 1077 if (tmpimg) 1078 delete tmpimg; 1040 1079 } 1041 1080 1042 1081 void MythThemedMenuState::setDefaults(void)