diff --git a/src/calamares/progresstree/ProgressTreeDelegate.cpp b/src/calamares/progresstree/ProgressTreeDelegate.cpp index 48b5b4328..388f4508c 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.cpp +++ b/src/calamares/progresstree/ProgressTreeDelegate.cpp @@ -25,50 +25,8 @@ item_fontsize() return CalamaresUtils::defaultFontSize() + 4; } -QSize -ProgressTreeDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const -{ - if ( !index.isValid() ) - { - return option.rect.size(); - } - - QFont font = qApp->font(); - - font.setPointSize( item_fontsize() ); - QFontMetrics fm( font ); - int height = fm.height(); - - height += 2 * item_margin; - - return QSize( option.rect.width(), height ); -} - - -void -ProgressTreeDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const -{ - QStyleOptionViewItem opt = option; - - painter->save(); - - initStyleOption( &opt, index ); - opt.text.clear(); - - painter->setBrush( - QColor( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarBackground ) ) ); - painter->setPen( QColor( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarText ) ) ); - - paintViewStep( painter, opt, index ); - - painter->restore(); -} - - -void -ProgressTreeDelegate::paintViewStep( QPainter* painter, - const QStyleOptionViewItem& option, - const QModelIndex& index ) const +static void +paintViewStep( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) { QRect textRect = option.rect.adjusted( item_margin, item_margin, -item_margin, -item_margin ); QFont font = qApp->font(); @@ -122,3 +80,42 @@ ProgressTreeDelegate::paintViewStep( QPainter* painter, } } while ( shrinkSteps <= maximumShrink ); } + +QSize +ProgressTreeDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const +{ + if ( !index.isValid() ) + { + return option.rect.size(); + } + + QFont font = qApp->font(); + + font.setPointSize( item_fontsize() ); + QFontMetrics fm( font ); + int height = fm.height(); + + height += 2 * item_margin; + + return QSize( option.rect.width(), height ); +} + + +void +ProgressTreeDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const +{ + QStyleOptionViewItem opt = option; + + painter->save(); + + initStyleOption( &opt, index ); + opt.text.clear(); + + painter->setBrush( + QColor( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarBackground ) ) ); + painter->setPen( QColor( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarText ) ) ); + + paintViewStep( painter, opt, index ); + + painter->restore(); +} diff --git a/src/calamares/progresstree/ProgressTreeDelegate.h b/src/calamares/progresstree/ProgressTreeDelegate.h index 55dcf7ac4..d5a5abcbc 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.h +++ b/src/calamares/progresstree/ProgressTreeDelegate.h @@ -26,9 +26,6 @@ public: protected: QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const override; void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override; - -private: - void paintViewStep( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; }; #endif // PROGRESSTREEDELEGATE_H