Skip to content

Commit

Permalink
mouseHotspotHand: Use QSize instead of 2 variables
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLorenz committed May 24, 2020
1 parent 47caf32 commit 943062a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 1 addition & 2 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,7 @@ TrackContentObjectView {
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: true; /* boolean property, set true to have a gradient */
/* finger tip offset of cursor */
qproperty-mouseHotspotX: 3;
qproperty-mouseHotspotY: 3;
qproperty-mouseHotspotHand: 3px 3px;
}

/* instrument pattern */
Expand Down
3 changes: 1 addition & 2 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,7 @@ TrackContentObjectView {
qproperty-textShadowColor: rgba(0,0,0,200);
qproperty-gradient: false; /* boolean property, set true to have a gradient */
/* finger tip offset of cursor */
qproperty-mouseHotspotX: 7;
qproperty-mouseHotspotY: 2;
qproperty-mouseHotspotHand: 7px 2px;
}

/* instrument pattern */
Expand Down
13 changes: 6 additions & 7 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QtCore/QList>
#include <QWidget>
#include <QSignalMapper>
#include <QSize>
#include <QColor>
#include <QMimeData>

Expand Down Expand Up @@ -201,8 +202,9 @@ class TrackContentObjectView : public selectableObject, public ModelView
Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor )
Q_PROPERTY( QColor BBPatternBackground READ BBPatternBackground WRITE setBBPatternBackground )
Q_PROPERTY( bool gradient READ gradient WRITE setGradient )
Q_PROPERTY( int mouseHotspotX WRITE setMouseHotspotX )
Q_PROPERTY( int mouseHotspotY WRITE setMouseHotspotY )
// We have to use a QSize here because using QPoint isn't supported.
// width -> x, height -> y
Q_PROPERTY( QSize mouseHotspotHand WRITE setMouseHotspotHand )

public:
TrackContentObjectView( TrackContentObject * tco, TrackView * tv );
Expand Down Expand Up @@ -235,9 +237,7 @@ class TrackContentObjectView : public selectableObject, public ModelView
void setTextShadowColor( const QColor & c );
void setBBPatternBackground( const QColor & c );
void setGradient( const bool & b );
void setMouseHotspotX(int x) { m_mouseHotspotX = x; }
void setMouseHotspotY(int y) { m_mouseHotspotY = y; }

void setMouseHotspotHand(const QSize & s);

// access needsUpdate member variable
bool needsUpdate();
Expand Down Expand Up @@ -307,8 +307,7 @@ protected slots:
QColor m_textShadowColor;
QColor m_BBPatternBackground;
bool m_gradient;
int m_mouseHotspotX;
int m_mouseHotspotY;
QSize m_mouseHotspotHand; // QSize must be used because QPoint isn't supported by property system
bool m_cursorSetYet;

bool m_needsUpdate;
Expand Down
14 changes: 9 additions & 5 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
m_textShadowColor( 0, 0, 0 ),
m_BBPatternBackground( 0, 0, 0 ),
m_gradient( true ),
m_mouseHotspotX( 0 ),
m_mouseHotspotY( 0 ),
m_mouseHotspotHand( 0, 0 ),
m_cursorSetYet( false ),
m_needsUpdate( true )
{
Expand All @@ -271,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" ), m_mouseHotspotX, m_mouseHotspotY ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
move( 0, 0 );
show();

Expand Down Expand Up @@ -322,7 +321,7 @@ void TrackContentObjectView::update()
{
if( !m_cursorSetYet )
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
m_cursorSetYet = true;
}

Expand Down Expand Up @@ -396,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; }
Expand Down Expand Up @@ -581,7 +585,7 @@ void TrackContentObjectView::leaveEvent( QEvent * e )
{
if( cursor().shape() != Qt::BitmapCursor )
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
}
if( e != NULL )
{
Expand Down

0 comments on commit 943062a

Please sign in to comment.