Skip to content

Commit

Permalink
Always display the sync status in one line.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
camilasan committed Jul 5, 2024
1 parent e3c6d7f commit 9565f71
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/gui/folderstatusdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,26 +319,22 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
#else
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOpt, painter, option.widget);
#endif

// Overall Progress Text
QRect overallProgressRect;
overallProgressRect.setTop(progressBarRect.bottom() + margin);
overallProgressRect.setHeight(fileNameTextHeight);
overallProgressRect.setLeft(progressBarRect.left());
overallProgressRect.setWidth(progressBarRect.width());
painter->setFont(progressFont);

painter->drawText(QStyle::visualRect(option.direction, option.rect, overallProgressRect), Qt::AlignLeft | Qt::AlignVCenter, overallString);
// overallString is e.g. About to start syncing, file 0 of 4
// itemString is e.g. moving fileName
auto generalSyncStatus = overallString;
if (!itemString.isEmpty() && generalSyncStatus.isEmpty()) {
generalSyncStatus = itemString;
}

// More detailed sync progress
QRect itemStringRect;
itemStringRect.setTop(overallProgressRect.bottom() + margin);
itemStringRect.setHeight(fileNameTextHeight);
itemStringRect.setLeft(overallProgressRect.left());
itemStringRect.setWidth(overallProgressRect.width());
QRect generalSyncStatusRect;
generalSyncStatusRect.setTop(progressBarRect.bottom() + margin);
generalSyncStatusRect.setHeight(fileNameTextHeight);
generalSyncStatusRect.setLeft(progressBarRect.left());
generalSyncStatusRect.setWidth(progressBarRect.width());
painter->setFont(progressFont);

painter->drawText(QStyle::visualRect(option.direction, option.rect, itemStringRect), Qt::AlignLeft | Qt::AlignVCenter, itemString);
painter->drawText(QStyle::visualRect(option.direction, option.rect, generalSyncStatusRect), Qt::AlignLeft | Qt::AlignVCenter, generalSyncStatus);

painter->restore();
}
Expand Down

0 comments on commit 9565f71

Please sign in to comment.