Mercurial > minori
view src/progress.cpp @ 7:07a9095eaeed
Update
Refactored some code, moved some around
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 24 Aug 2023 23:11:38 -0400 |
parents | 1d82f6e04d7d |
children |
line wrap: on
line source
#include "progress.h" #include <QPainter> #include <QPalette> #include <QStyleOptionProgressBar> #include <QStyleOptionViewItem> #include <QProxyStyle> #include <QMessageBox> AnimeProgressBar::AnimeProgressBar() { #if (defined(WIN32) || defined(MACOSX)) auto *fusionStyle = new QProxyStyle {"fusion"}; fusionStyle->setParent(&dummy_progress); dummy_progress.setStyle(fusionStyle); #endif } void AnimeProgressBar::paint(QPainter *painter, const QStyleOptionViewItem &option, const QString &text, const int progress, const int episodes) const { QStyleOptionProgressBar styleOption; styleOption.initFrom(&dummy_progress); styleOption.maximum = episodes; styleOption.minimum = 0; styleOption.progress = progress; styleOption.text = text; styleOption.textVisible = true; styleOption.rect = option.rect; styleOption.state = option.state; const bool enabled = option.state.testFlag(QStyle::State_Enabled); styleOption.palette.setCurrentColorGroup(enabled ? QPalette::Active : QPalette::Disabled); painter->save(); const QStyle *style = dummy_progress.style(); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, option.widget); style->drawControl(QStyle::CE_ProgressBar, &styleOption, painter, &dummy_progress); painter->restore(); }