MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / getIconTexture

Method getIconTexture

source/ui/data/boxedApp.cpp:243–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243const BoxedAppIcon* BoxedApp::getIconTexture(int iconSize) {
244 if (iconSize==0) {
245 iconSize = UiSettings::ICON_SIZE;
246 }
247 if (!this->iconsBySize.contains(iconSize)) {
248 int width = 0;
249 int height = 0;
250 std::shared_ptr<U8[]> data;
251 BString nativeExePath = this->container->getNativePathForApp(*this);
252
253 if (Fs::doesNativePathExist(nativeExePath)) {
254 data = extractIconFromExe(this->container->getNativePathForApp(*this), iconSize, &width, &height);
255 } else {
256 BString nativeDir = this->container->getDir().stringByApppendingPath("tmp");
257 std::shared_ptr<FileSystemZip> fs = container->getFileSystem().lock();
258 if (fs) {
259 FsZip::extractFileFromZip(fs->filePath, this->path.substr(1) + "/" + this->cmd, nativeDir);
260 BString nativePath = nativeDir.stringByApppendingPath(this->cmd);
261 data = extractIconFromExe(nativePath, iconSize, &width, &height);
262 Fs::deleteNativeFile(nativePath);
263 }
264 }
265 if (!data) {
266 if (Fs::doesNativePathExist(this->iconPath)) {
267 data.reset(LoadImageFromFile(this->iconPath.c_str(), &width, &height));
268 }
269 }
270 if (data) {
271 this->iconsBySize.set(iconSize, new BoxedAppIcon(data, width, height));
272 } else {
273 this->iconsBySize.set(iconSize, nullptr);
274 }
275 }
276 return this->iconsBySize[iconSize];
277}
278
279void BoxedApp::remove() {
280 Fs::deleteNativeFile(this->iniFilePath);

Callers 3

loadAppsFunction · 0.80
ContainersViewMethod · 0.80
drawItemsMethod · 0.80

Calls 12

extractIconFromExeFunction · 0.85
LoadImageFromFileFunction · 0.85
getNativePathForAppMethod · 0.80
getDirMethod · 0.80
getFileSystemMethod · 0.80
substrMethod · 0.80
containsMethod · 0.45
lockMethod · 0.45
resetMethod · 0.45
c_strMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected