1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-12 15:57:57 +00:00

Merge pull request #5339 from evsh/files-tooltip

Fix empty tooltips showed at the progress bar borders
This commit is contained in:
sledgehammer999 2016-06-02 14:53:14 -05:00
commit fd996f15f0

View File

@ -253,11 +253,11 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
QTextStream stream(&toolTipText, QIODevice::WriteOnly); QTextStream stream(&toolTipText, QIODevice::WriteOnly);
bool showDetailedInformation = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier); bool showDetailedInformation = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
if (showDetailedInformation) { if (showDetailedInformation) {
stream << "<html><body>";
const int imagePos = e->pos().x() - borderWidth; const int imagePos = e->pos().x() - borderWidth;
if ((imagePos >=0) && (imagePos < m_image.width())) { if ((imagePos >=0) && (imagePos < m_image.width())) {
stream << "<html><body>";
PieceIndexToImagePos transform {m_torrent->info(), m_image}; PieceIndexToImagePos transform {m_torrent->info(), m_image};
int pieceIndex = transform.pieceIndex(e->pos().x() - borderWidth); int pieceIndex = transform.pieceIndex(imagePos);
QVector<int> files {m_torrent->info().fileIndicesForPiece(pieceIndex)}; QVector<int> files {m_torrent->info().fileIndicesForPiece(pieceIndex)};
QString tooltipTitle; QString tooltipTitle;
@ -281,9 +281,9 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
renderer(Utils::Misc::friendlyUnit(m_torrent->info().fileSize(f)), filePath); renderer(Utils::Misc::friendlyUnit(m_torrent->info().fileSize(f)), filePath);
} }
}
stream << "</body></html>"; stream << "</body></html>";
} }
}
else { else {
stream << simpleToolTipText(); stream << simpleToolTipText();
stream << '\n' << tr("Hold Shift key for detailed information"); stream << '\n' << tr("Hold Shift key for detailed information");