mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-24 21:28:41 -05:00
Temporary text only progress display for macOS sample downloads
A Qt defect is breaking the display of progress bar item delegates, this change replaces them with simple text item delegate.
This commit is contained in:
parent
64d501d256
commit
e38af47915
@ -14,28 +14,42 @@ void DirectoryDelegate::paint (QPainter * painter, QStyleOptionViewItem const& o
|
|||||||
{
|
{
|
||||||
if (1 == index.column ())
|
if (1 == index.column ())
|
||||||
{
|
{
|
||||||
QStyleOptionProgressBar progress_bar_option;
|
|
||||||
progress_bar_option.rect = option.rect;
|
|
||||||
progress_bar_option.state = QStyle::State_Enabled;
|
|
||||||
progress_bar_option.direction = QApplication::layoutDirection ();
|
|
||||||
progress_bar_option.fontMetrics = QApplication::fontMetrics ();
|
|
||||||
progress_bar_option.minimum = 0;
|
|
||||||
progress_bar_option.maximum = 100;
|
|
||||||
auto progress = index.data ().toLongLong ();
|
auto progress = index.data ().toLongLong ();
|
||||||
|
qint64 percent;
|
||||||
if (progress > 0)
|
if (progress > 0)
|
||||||
{
|
{
|
||||||
auto percent = int (progress * 100 / index.data (Qt::UserRole).toLongLong ());
|
percent = int (progress * 100 / index.data (Qt::UserRole).toLongLong ());
|
||||||
progress_bar_option.progress = percent;
|
}
|
||||||
progress_bar_option.text = QString::number (percent) + '%';
|
#if !defined (Q_OS_DARWIN)
|
||||||
progress_bar_option.textVisible = true;
|
QStyleOptionProgressBar progress_option;
|
||||||
progress_bar_option.textAlignment = Qt::AlignCenter;
|
auto control_element = QStyle::CE_ProgressBar;
|
||||||
|
progress_option.minimum = 0;
|
||||||
|
progress_option.maximum = 100;
|
||||||
|
progress_option.textAlignment = Qt::AlignCenter;
|
||||||
|
if (progress > 0)
|
||||||
|
{
|
||||||
|
progress_option.progress = percent;
|
||||||
|
progress_option.textVisible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// not started
|
// not started
|
||||||
progress_bar_option.progress = -1;
|
progress_option.progress = -1;
|
||||||
}
|
}
|
||||||
QApplication::style ()->drawControl (QStyle::CE_ProgressBar, &progress_bar_option, painter);
|
#else
|
||||||
|
// workaround for broken QProgressBar item delegates on macOS
|
||||||
|
QStyleOptionViewItem progress_option;
|
||||||
|
auto control_element = QStyle::CE_ItemViewItem;
|
||||||
|
progress_option.displayAlignment = Qt::AlignLeft;
|
||||||
|
progress_option.index = index;
|
||||||
|
progress_option.features = QStyleOptionViewItem::HasDisplay;
|
||||||
|
#endif
|
||||||
|
progress_option.rect = option.rect;
|
||||||
|
progress_option.state = QStyle::State_Enabled;
|
||||||
|
progress_option.direction = QApplication::layoutDirection ();
|
||||||
|
progress_option.fontMetrics = QApplication::fontMetrics ();
|
||||||
|
progress_option.text = QString::number (progress > 0 ? percent : 0) + '%';
|
||||||
|
QApplication::style ()->drawControl (control_element, &progress_option, painter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user