mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
Enforce minimum distance between allow/deny buttons for ACL request
This commit is contained in:
@@ -78,22 +78,31 @@ AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
|
|
||||||
int totalwidth = opt.rect.width();
|
int totalwidth = opt.rect.width();
|
||||||
int thirds = totalwidth/3;
|
int thirds = totalwidth/3;
|
||||||
QRect btnRect;
|
QRect allowBtnRect;
|
||||||
|
QRect denyBtnRect;
|
||||||
painter->setPen( Qt::white );
|
painter->setPen( Qt::white );
|
||||||
|
|
||||||
QString btnText = tr( "Allow Streaming" );
|
int minPixels = 20;
|
||||||
int btnWidth = fm.width( btnText ) + 2*PADDING;
|
|
||||||
btnRect = QRect( opt.rect.left() + thirds - btnWidth/2, opt.rect.bottom() - fm.height() - 4*PADDING, btnWidth + 2*PADDING, fm.height() + 2*PADDING );
|
|
||||||
drawRoundedButton( painter, btnRect, btnRect.contains( m_savedHoverPos ) );
|
|
||||||
painter->drawText( btnRect, Qt::AlignCenter, btnText );
|
|
||||||
m_savedAcceptRect = btnRect;
|
|
||||||
|
|
||||||
btnText = tr( "Deny Access" );
|
QString allowBtnText = tr( "Allow Streaming" );
|
||||||
btnWidth = fm.width( btnText ) + 2*PADDING;
|
int allowBtnWidth = fm.width( allowBtnText ) + 2*PADDING;
|
||||||
btnRect = QRect( opt.rect.right() - thirds - btnWidth/2, opt.rect.bottom() - fm.height() - 4*PADDING, btnWidth + 2*PADDING, fm.height() + 2*PADDING );
|
allowBtnRect = QRect( opt.rect.left() + thirds - allowBtnWidth/2, opt.rect.bottom() - fm.height() - 4*PADDING, allowBtnWidth + 2*PADDING, fm.height() + 2*PADDING );
|
||||||
drawRoundedButton( painter, btnRect, btnRect.contains( m_savedHoverPos ) );
|
QString denyBtnText = tr( "Deny Access" );
|
||||||
painter->drawText( btnRect, Qt::AlignCenter, btnText );
|
int denyBtnWidth = fm.width( denyBtnText ) + 2*PADDING;
|
||||||
m_savedDenyRect = btnRect;
|
denyBtnRect = QRect( opt.rect.right() - thirds - denyBtnWidth/2, opt.rect.bottom() - fm.height() - 4*PADDING, denyBtnWidth + 2*PADDING, fm.height() + 2*PADDING );
|
||||||
|
|
||||||
|
if ( allowBtnRect.right() >= denyBtnRect.left() )
|
||||||
|
{
|
||||||
|
allowBtnRect.moveLeft( minPixels / 2 );
|
||||||
|
denyBtnRect.moveRight( minPixels / 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
drawRoundedButton( painter, allowBtnRect, allowBtnRect.contains( m_savedHoverPos ) );
|
||||||
|
painter->drawText( allowBtnRect, Qt::AlignCenter, allowBtnText );
|
||||||
|
m_savedAcceptRect = allowBtnRect;
|
||||||
|
drawRoundedButton( painter, denyBtnRect, denyBtnRect.contains( m_savedHoverPos ) );
|
||||||
|
painter->drawText( denyBtnRect, Qt::AlignCenter, denyBtnText );
|
||||||
|
m_savedDenyRect = denyBtnRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize
|
QSize
|
||||||
|
Reference in New Issue
Block a user