mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 16:29:43 +01:00
Shorten description if we have remove btn and config wrench
This commit is contained in:
parent
4b11e1923d
commit
c9d1d2fb7a
src/libtomahawk/accounts
@ -249,7 +249,7 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
else if ( canDelete )
|
||||
{
|
||||
const QString btnText = tr( "Remove" );
|
||||
const int btnWidth = installMetrics.width( btnText ) + 2*PADDING;
|
||||
const int btnWidth = removeBtnWidth( opt );
|
||||
|
||||
QRect btnRect = QRect( opt.rect.right() - 3 * PADDING - btnWidth,
|
||||
center - installMetrics.height() / 2 - PADDING,
|
||||
@ -311,7 +311,9 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
}
|
||||
|
||||
// description
|
||||
const int descWidth = rightEdge - leftTitleEdge - PADDING;
|
||||
int descWidth = rightEdge - leftTitleEdge - PADDING;
|
||||
if ( canDelete )
|
||||
descWidth -= removeBtnWidth( opt ) + PADDING;
|
||||
painter->setFont( descFont );
|
||||
const QRect descRect( leftTitleEdge, runningBottom + PADDING, descWidth, painter->fontMetrics().height() );
|
||||
desc = painter->fontMetrics().elidedText( desc, Qt::ElideRight, descWidth );
|
||||
@ -659,6 +661,17 @@ AccountDelegate::checkRectForIndex( const QStyleOptionViewItem& option, const QM
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AccountDelegate::removeBtnWidth( QStyleOptionViewItemV4 opt ) const
|
||||
{
|
||||
const QString btnText = tr( "Remove" );
|
||||
QFont font = opt.font;
|
||||
font.setItalic( false );
|
||||
return QFontMetrics( font ).width( btnText ) + 2*PADDING;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AccountDelegate::startInstalling( const QPersistentModelIndex& idx )
|
||||
{
|
||||
|
@ -78,6 +78,8 @@ private:
|
||||
|
||||
QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx ) const;
|
||||
|
||||
int removeBtnWidth( QStyleOptionViewItemV4 opt ) const;
|
||||
|
||||
int m_hoveringOver;
|
||||
QPersistentModelIndex m_hoveringItem, m_configPressed;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedButtonRects;
|
||||
|
Loading…
x
Reference in New Issue
Block a user