Fix #4201: BB editor: adjust cursor position (#5489)

This fixes an offset for cursors whose pointer position varies between
different themes.
This commit is contained in:
Johannes Lorenz
2020-05-24 13:20:05 +02:00
committed by GitHub
parent d5a2366fc8
commit 3a985ff1fc
4 changed files with 27 additions and 3 deletions

View File

@@ -257,6 +257,8 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
m_textShadowColor( 0, 0, 0 ),
m_BBPatternBackground( 0, 0, 0 ),
m_gradient( true ),
m_mouseHotspotHand( 0, 0 ),
m_cursorSetYet( false ),
m_needsUpdate( true )
{
if( s_textFloat == NULL )
@@ -268,7 +270,7 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
setAttribute( Qt::WA_OpaquePaintEvent, true );
setAttribute( Qt::WA_DeleteOnClose, true );
setFocusPolicy( Qt::StrongFocus );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
move( 0, 0 );
show();
@@ -317,6 +319,12 @@ TrackContentObjectView::~TrackContentObjectView()
*/
void TrackContentObjectView::update()
{
if( !m_cursorSetYet )
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
m_cursorSetYet = true;
}
if( fixedTCOs() )
{
updateLength();
@@ -387,6 +395,11 @@ void TrackContentObjectView::setBBPatternBackground( const QColor & c )
void TrackContentObjectView::setGradient( const bool & b )
{ m_gradient = b; }
void TrackContentObjectView::setMouseHotspotHand(const QSize & s)
{
m_mouseHotspotHand = s;
}
// access needsUpdate member variable
bool TrackContentObjectView::needsUpdate()
{ return m_needsUpdate; }
@@ -572,7 +585,7 @@ void TrackContentObjectView::leaveEvent( QEvent * e )
{
if( cursor().shape() != Qt::BitmapCursor )
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
}
if( e != NULL )
{