MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / LoadCover

Method LoadCover

src/render_panel/ui/tab_game.cpp:357–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355 }
356
357 void TabGame::LoadCover(const tc::TcDBGamePtr& game) {
358 auto steam_manager = context_->GetSteamManager();
359 if (!steam_manager) {
360 return;
361 }
362 auto image_cache_path = steam_manager->GetSteamImageCachePath();
363 std::string from_cover_path = std::format("{}/{}/library_600x900.jpg", image_cache_path, game->game_id_);
364 LOGI("cover path: {}", from_cover_path);
365
366 std::string steam_cover_folder_path = this->context_->GetCurrentExeFolder() + "/resources/steam_covers";
367 FolderUtil::CreateDir(steam_cover_folder_path);
368 std::string target_cover_name = std::format("{}_library_600x900.jpg", game->game_id_);
369 std::string target_cover_path = std::format("{}/{}", steam_cover_folder_path, target_cover_name);
370 FileUtil::CopyFileExt(from_cover_path, target_cover_path, false);
371
372 QImage image;
373 if (!image.load(QString::fromStdString(target_cover_path))) {
374 LOGI("not find cover: {}", target_cover_path);
375 return;
376 }
377 auto item_size = GetItemSize();
378 auto pixmap = QPixmap::fromImage(image);
379 pixmap = pixmap.scaled(item_size.width(), item_size.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
380 game->cover_pixmap_ = pixmap;
381 }
382
383 void TabGame::UpdateRunningStatus(const std::vector<uint64_t>& game_ids) {
384 this->VisitListWidget([=, this](QListWidgetItem* item, QWidget* item_widget) {

Callers 1

ScanInstalledGamesMethod · 0.95

Calls 2

GetSteamManagerMethod · 0.80
GetCurrentExeFolderMethod · 0.45

Tested by

no test coverage detected