From 078f6df4d646bd83ab810e28c8f057eeb46cf016 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Tue, 16 Jul 2024 11:56:29 +0200 Subject: [PATCH] VCS: Improve dialog when files cannot be added Avoid making the dialog larger than the screen. Also remove the special handling for single files. Fixes: QTCREATORBUG-31161 Change-Id: I5a85834505351493c51ee708c81527147d1a1270 Reviewed-by: Orgad Shaneh Reviewed-by: Leena Miettinen --- src/plugins/coreplugin/vcsmanager.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index 5180a356c26..04414e3a06d 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -370,11 +370,15 @@ QString VcsManager::msgAddToVcsFailedTitle() QString VcsManager::msgToAddToVcsFailed(const QStringList &files, const IVersionControl *vc) { - return files.size() == 1 - ? Tr::tr("Could not add the file\n%1\nto version control (%2)\n") - .arg(files.front(), vc->displayName()) - : Tr::tr("Could not add the following files to version control (%1)\n%2") - .arg(vc->displayName(), files.join(QString(QLatin1Char('\n')))); + QStringList fileList = files; + const qsizetype size = files.size(); + const qsizetype maxSize = 10; + if (size > maxSize) { + fileList = files.first(maxSize); + fileList.append(Tr::tr("... and %1 more.").arg(size - maxSize)); + } + return Tr::tr("Could not add the following files to version control (%1)\n%2") + .arg(vc->displayName(), fileList.join(QString(QLatin1Char('\n')))); } FilePaths VcsManager::additionalToolsPath()