mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Shorten description if we have remove btn and config wrench
This commit is contained in:
@@ -249,7 +249,7 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
else if ( canDelete )
|
else if ( canDelete )
|
||||||
{
|
{
|
||||||
const QString btnText = tr( "Remove" );
|
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,
|
QRect btnRect = QRect( opt.rect.right() - 3 * PADDING - btnWidth,
|
||||||
center - installMetrics.height() / 2 - PADDING,
|
center - installMetrics.height() / 2 - PADDING,
|
||||||
@@ -311,7 +311,9 @@ AccountDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// description
|
// description
|
||||||
const int descWidth = rightEdge - leftTitleEdge - PADDING;
|
int descWidth = rightEdge - leftTitleEdge - PADDING;
|
||||||
|
if ( canDelete )
|
||||||
|
descWidth -= removeBtnWidth( opt ) + PADDING;
|
||||||
painter->setFont( descFont );
|
painter->setFont( descFont );
|
||||||
const QRect descRect( leftTitleEdge, runningBottom + PADDING, descWidth, painter->fontMetrics().height() );
|
const QRect descRect( leftTitleEdge, runningBottom + PADDING, descWidth, painter->fontMetrics().height() );
|
||||||
desc = painter->fontMetrics().elidedText( desc, Qt::ElideRight, descWidth );
|
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
|
void
|
||||||
AccountDelegate::startInstalling( const QPersistentModelIndex& idx )
|
AccountDelegate::startInstalling( const QPersistentModelIndex& idx )
|
||||||
{
|
{
|
||||||
|
@@ -78,6 +78,8 @@ private:
|
|||||||
|
|
||||||
QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx ) const;
|
QRect checkRectForIndex( const QStyleOptionViewItem &option, const QModelIndex &idx ) const;
|
||||||
|
|
||||||
|
int removeBtnWidth( QStyleOptionViewItemV4 opt ) const;
|
||||||
|
|
||||||
int m_hoveringOver;
|
int m_hoveringOver;
|
||||||
QPersistentModelIndex m_hoveringItem, m_configPressed;
|
QPersistentModelIndex m_hoveringItem, m_configPressed;
|
||||||
mutable QHash< QPersistentModelIndex, QRect > m_cachedButtonRects;
|
mutable QHash< QPersistentModelIndex, QRect > m_cachedButtonRects;
|
||||||
|
Reference in New Issue
Block a user