[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;
|
return CalamaresUtils::defaultFontSize() + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize
|
static void
|
||||||
ProgressTreeDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
paintViewStep( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index )
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
QRect textRect = option.rect.adjusted( item_margin, item_margin, -item_margin, -item_margin );
|
QRect textRect = option.rect.adjusted( item_margin, item_margin, -item_margin, -item_margin );
|
||||||
QFont font = qApp->font();
|
QFont font = qApp->font();
|
||||||
@ -122,3 +80,42 @@ ProgressTreeDelegate::paintViewStep( QPainter* painter,
|
|||||||
}
|
}
|
||||||
} while ( shrinkSteps <= maximumShrink );
|
} 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:
|
protected:
|
||||||
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
|
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
|
||||||
void paint( QPainter* painter, 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
|
#endif // PROGRESSTREEDELEGATE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user