diff --git a/es-app/src/guis/GuiThemeDownloader.cpp b/es-app/src/guis/GuiThemeDownloader.cpp index 7772e334c..21f571060 100644 --- a/es-app/src/guis/GuiThemeDownloader.cpp +++ b/es-app/src/guis/GuiThemeDownloader.cpp @@ -99,7 +99,7 @@ GuiThemeDownloader::GuiThemeDownloader(std::function updateCallback) mScreenshot->setLinearInterpolation(true); mCenterGrid->setEntry(mScreenshot, glm::ivec2 {1, 3}, false, true, glm::ivec2 {4, 1}); - mAuthor = std::make_shared("", Font::get(FONT_SIZE_MINI, FONT_PATH_LIGHT), + mAuthor = std::make_shared("", Font::get(FONT_SIZE_MINI * 0.9f, FONT_PATH_LIGHT), 0x555555FF, ALIGN_LEFT); mCenterGrid->setEntry(mAuthor, glm::ivec2 {1, 4}, false, true, glm::ivec2 {4, 1}, GridFlags::BORDER_BOTTOM); @@ -412,6 +412,7 @@ void GuiThemeDownloader::makeInventory() for (auto& theme : mThemeSets) { const std::string path {mThemeDirectory + theme.reponame}; theme.invalidRepository = false; + theme.shallowRepository = false; theme.manuallyDownloaded = false; theme.hasLocalChanges = false; theme.isCloned = false; @@ -436,6 +437,12 @@ void GuiThemeDownloader::makeInventory() continue; } + if (git_repository_is_shallow(repository)) { + theme.shallowRepository = true; + git_repository_free(repository); + continue; + } + theme.isCloned = true; if (checkLocalChanges(repository)) @@ -581,7 +588,7 @@ void GuiThemeDownloader::populateGUI() themeName.append(" ").append(ViewController::BRANCH_CHAR); if (theme.isCloned) themeName.append(" ").append(ViewController::TICKMARK_CHAR); - if (theme.manuallyDownloaded || theme.invalidRepository) + if (theme.manuallyDownloaded || theme.invalidRepository || theme.shallowRepository) themeName.append(" ").append(ViewController::CROSSEDCIRCLE_CHAR); if (theme.hasLocalChanges) themeName.append(" ").append(ViewController::EXCLAMATION_CHAR); @@ -620,6 +627,29 @@ void GuiThemeDownloader::populateGUI() 0.75f : 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); } + else if (theme.shallowRepository) { + mWindow->pushGui(new GuiMsgBox( + getHelpStyle(), + "IT SEEMS AS IF THIS IS A SHALLOW REPOSITORY WHICH MEANS THAT IT'S BEEN " + "DOWNLOADED USING SOME OTHER TOOL THAN THIS THEME DOWNLOADER. A FRESH DOWNLOAD " + "IS REQUIRED AND THE OLD THEME DIRECTORY \"" + + theme.reponame + theme.manualExtension + "\" WILL BE RENAMED TO \"" + + theme.reponame + theme.manualExtension + "_DISABLED\"", + "PROCEED", + [this, theme] { + renameDirectory(mThemeDirectory + theme.reponame + theme.manualExtension); + std::promise().swap(mPromise); + mFuture = mPromise.get_future(); + mFetchThread = std::thread(&GuiThemeDownloader::cloneRepository, this, + theme.reponame, theme.url); + mStatusType = StatusType::STATUS_DOWNLOADING; + mStatusText = "DOWNLOADING THEME"; + }, + "ABORT", [] { return; }, "", nullptr, true, true, + (mRenderer->getIsVerticalOrientation() ? + 0.75f : + 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); + } else if (theme.hasLocalChanges) { mWindow->pushGui(new GuiMsgBox( getHelpStyle(), @@ -678,7 +708,8 @@ void GuiThemeDownloader::updateGUI() themeName.append(" ").append(ViewController::BRANCH_CHAR); if (mThemeSets[i].isCloned) themeName.append(" ").append(ViewController::TICKMARK_CHAR); - if (mThemeSets[i].manuallyDownloaded || mThemeSets[i].invalidRepository) + if (mThemeSets[i].manuallyDownloaded || mThemeSets[i].invalidRepository || + mThemeSets[i].shallowRepository) themeName.append(" ").append(ViewController::CROSSEDCIRCLE_CHAR); if (mThemeSets[i].hasLocalChanges) themeName.append(" ").append(ViewController::EXCLAMATION_CHAR); @@ -703,6 +734,10 @@ void GuiThemeDownloader::updateInfoPane() mDownloadStatus->setText(ViewController::CROSSEDCIRCLE_CHAR + " MANUAL DOWNLOAD"); mDownloadStatus->setColor(0x992222FF); } + else if (mThemeSets[mList->getCursorId()].shallowRepository) { + mDownloadStatus->setText(ViewController::CROSSEDCIRCLE_CHAR + " SHALLOW REPO"); + mDownloadStatus->setColor(0x992222FF); + } else { if (mThemeSets[mList->getCursorId()].newEntry) mDownloadStatus->setText("NOT INSTALLED (NEW)"); diff --git a/es-app/src/guis/GuiThemeDownloader.h b/es-app/src/guis/GuiThemeDownloader.h index e54e2f795..89398ddb3 100644 --- a/es-app/src/guis/GuiThemeDownloader.h +++ b/es-app/src/guis/GuiThemeDownloader.h @@ -68,12 +68,14 @@ private: std::vector screenshots; bool newEntry; bool invalidRepository; + bool shallowRepository; bool manuallyDownloaded; bool hasLocalChanges; bool isCloned; ThemeEntry() : newEntry {false} , invalidRepository {false} + , shallowRepository {false} , manuallyDownloaded {false} , hasLocalChanges {false} , isCloned {false} @@ -121,11 +123,9 @@ private: enum class RepositoryError { NO_REPO_ERROR, - MANUALLY_DOWNLOADED, NOT_A_REPOSITORY, INVALID_ORIGIN, - HAS_DIVERGED, - HAS_LOCAL_CHANGES + HAS_DIVERGED }; RepositoryError mRepositoryError;