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 <orgads@gmail.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Andre Hartmann
2024-07-16 11:56:29 +02:00
committed by André Hartmann
parent 9b7016f519
commit 078f6df4d6

View File

@@ -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()