summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/settings/light-and-power/calibration.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp
index aed2bc8..c5377d0 100644
--- a/core/settings/light-and-power/calibration.cpp
+++ b/core/settings/light-and-power/calibration.cpp
@@ -126,34 +126,34 @@ void Calibration::checkPoints ( )
if ( m_p [1]. x ( ) < 0 )
m_p [1]. setX ( 0 );
if ( m_p [1]. x ( ) >= dx )
m_p [1]. setX ( dx - 1 );
if ( m_p [0]. x ( ) < 0 )
m_p [0]. setX ( 0 );
if ( m_p [0]. x ( ) > m_p [1]. x ( ))
m_p [0]. setX ( m_p [1]. x ( ));
if ( m_p [1]. y ( ) < 0 )
m_p [1]. setY ( 0 );
if ( m_p [1]. y ( ) >= dy )
m_p [1]. setY ( dy - 1 );
if ( m_p [0]. y ( ) < 0 )
m_p [0]. setY ( 0 );
- if ( m_p [0]. y ( ) > m_p [1]. y ( ))
- m_p [0]. setY ( m_p [1]. y ( ));
+ if ( m_p [0]. y ( ) >= dy )
+ m_p [0]. setY ( dy - 1 );
}
#define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width())
#define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height())
static QRect around ( int x, int y )
{
return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 );
}
void Calibration::mousePressEvent ( QMouseEvent *e )
{
if ( e-> button ( ) != LeftButton )
return QWidget::mousePressEvent ( e );
@@ -192,66 +192,66 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e )
QPoint n [2];
n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD ));
n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD ));
n [1 - m_dragged] = m_p [1 - m_dragged];
if ( n [m_dragged]. x ( ) < 0 )
n [m_dragged]. setX ( 0 );
if ( n [m_dragged]. x ( ) >= m_scale. width ( ))
n [m_dragged]. setX ( m_scale. width ( ) - 1 );
if ( n [0]. x ( ) > n [1]. x ( ))
n [m_dragged]. setX ( n [1 - m_dragged]. x ( ));
if ( n [m_dragged]. y ( ) < 0 )
n [m_dragged]. setY ( 0 );
if ( n [m_dragged]. y ( ) >= m_scale. height ( ))
n [m_dragged]. setY ( m_scale. height ( ) - 1 );
- if ( n [0]. y ( ) > n [1]. y ( ))
- n [m_dragged]. setY ( n [1 - m_dragged]. y ( ));
+// if ( n [0]. y ( ) > n [1]. y ( ))
+// n [m_dragged]. setY ( n [1 - m_dragged]. y ( ));
QRect r;
int ox [2], oy [2], nx [2], ny [2];
for ( int i = 0; i < 2; i++ ) {
nx [i] = SCALEX( n [i]. x ( ));
ny [i] = SCALEY( n [i]. y ( ));
ox [i] = SCALEX( m_p [i]. x ( ));
oy [i] = SCALEY( m_p [i]. y ( ));
if ( n [i] != m_p [i] ) {
r |= around ( nx [i], ny [i] );
r |= around ( ox [i], oy [i] );
m_p [i] = n [i];
if ( i == 0 ) {
r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 );
r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 );
emit startPointChanged ( startPoint ( ));
}
else if ( i == 1 ) {
r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 );
r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 );
emit endPointChanged ( endPoint ( ));
}
}
}
if ( r. isValid ( )) {
- r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 );
- r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 );
+ r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ). normalize ( );
+ r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ). normalize ( );
repaint ( r, false );
}
}
void Calibration::mouseReleaseEvent ( QMouseEvent *e )
{
if ( e-> button ( ) != LeftButton )
return QWidget::mouseReleaseEvent ( e );
if ( m_dragged < 0 )
return;
int x = SCALEX( m_p [m_dragged]. x ( ));
int y = SCALEY( m_p [m_dragged]. y ( ));
m_dragged = -1;
@@ -261,33 +261,33 @@ void Calibration::mouseReleaseEvent ( QMouseEvent *e )
void Calibration::paintEvent ( QPaintEvent *pe )
{
QPixmap pix ( size ( ));
QPainter p ( &pix, this );
QRect cr = pe-> rect ( );
int x0 = SCALEX( m_p [0]. x ( ));
int y0 = SCALEY( m_p [0]. y ( ));
int x1 = SCALEX( m_p [1]. x ( ));
int y1 = SCALEY( m_p [1]. y ( ));
int dx = x1 - x0;
int dy = y1 - y0;
// restrict steps to real x and y resolution
- int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( dy + 1 ));
+ int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 ));
QString stepstr = tr( "%1 Steps" ). arg ( st );
QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr );
tr. setLeft ( tr. left ( ) - 20 );
if ( p. hasClipping ( ))
p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr ));
QColorGroup g = colorGroup ( );
p. fillRect ( cr, g. base ( ));
p. fillRect ( tr, g. base ( ));
int ex = x0, ey = y0;
p. setPen ( g. mid ( ));