Browse Source

Merge pull request #17187 from Chocobo1/names

Fix wrong file names displayed in tooltip
adaptive-webui-19844
Chocobo1 3 years ago committed by GitHub
parent
commit
5b0cbf9eb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/app/filelogger.cpp
  2. 23
      src/gui/properties/piecesbar.cpp

10
src/app/filelogger.cpp

@ -134,19 +134,19 @@ void FileLogger::addLogMessage(const Log::Msg &msg) @@ -134,19 +134,19 @@ void FileLogger::addLogMessage(const Log::Msg &msg)
switch (msg.type)
{
case Log::INFO:
stream << "(I) ";
stream << u"(I) ";
break;
case Log::WARNING:
stream << "(W) ";
stream << u"(W) ";
break;
case Log::CRITICAL:
stream << "(C) ";
stream << u"(C) ";
break;
default:
stream << "(N) ";
stream << u"(N) ";
}
stream << QDateTime::fromMSecsSinceEpoch(msg.timestamp).toString(Qt::ISODate) << " - " << msg.message << '\n';
stream << QDateTime::fromMSecsSinceEpoch(msg.timestamp).toString(Qt::ISODate) << u" - " << msg.message << u'\n';
if (m_backup && (m_logFile.size() >= m_maxSize))
{

23
src/gui/properties/piecesbar.cpp

@ -265,30 +265,25 @@ void PiecesBar::showToolTip(const QHelpEvent *e) @@ -265,30 +265,25 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
{
const PieceIndexToImagePos transform {torrentInfo, m_image};
const int pieceIndex = transform.pieceIndex(imagePos);
const QVector<int> files {torrentInfo.fileIndicesForPiece(pieceIndex)};
const QVector<int> fileIndexes = torrentInfo.fileIndicesForPiece(pieceIndex);
QString tooltipTitle;
if (files.count() > 1)
{
if (fileIndexes.count() > 1)
tooltipTitle = tr("Files in this piece:");
}
else if (torrentInfo.fileSize(fileIndexes.front()) == torrentInfo.pieceLength(pieceIndex))
tooltipTitle = tr("File in this piece:");
else
{
if (torrentInfo.fileSize(files.front()) == torrentInfo.pieceLength(pieceIndex))
tooltipTitle = tr("File in this piece");
else
tooltipTitle = tr("File in these pieces");
}
tooltipTitle = tr("File in these pieces:");
toolTipText.reserve(files.size() * 128);
toolTipText.reserve(fileIndexes.size() * 128);
toolTipText += u"<html><body>";
DetailedTooltipRenderer renderer {toolTipText, tooltipTitle};
for (const int f : files)
for (const int index : fileIndexes)
{
const Path filePath = torrentInfo.filePath(f);
renderer(Utils::Misc::friendlyUnit(torrentInfo.fileSize(f)), filePath);
const Path filePath = m_torrent->filePath(index);
renderer(Utils::Misc::friendlyUnit(torrentInfo.fileSize(index)), filePath);
}
toolTipText += u"</body></html>";
}

Loading…
Cancel
Save