[calamares] Don't need a method for painting, reduce API
This commit is contained in:
parent
7db14cb5cf
commit
7b22546b14
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user