-rw-r--r-- | core/settings/light-and-power/calibration.cpp | 14 |
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 | |||
@@ -134,18 +134,18 @@ void Calibration::checkPoints ( ) | |||
134 | m_p [0]. setX ( m_p [1]. x ( )); | 134 | m_p [0]. setX ( m_p [1]. x ( )); |
135 | 135 | ||
136 | if ( m_p [1]. y ( ) < 0 ) | 136 | if ( m_p [1]. y ( ) < 0 ) |
137 | m_p [1]. setY ( 0 ); | 137 | m_p [1]. setY ( 0 ); |
138 | if ( m_p [1]. y ( ) >= dy ) | 138 | if ( m_p [1]. y ( ) >= dy ) |
139 | m_p [1]. setY ( dy - 1 ); | 139 | m_p [1]. setY ( dy - 1 ); |
140 | if ( m_p [0]. y ( ) < 0 ) | 140 | if ( m_p [0]. y ( ) < 0 ) |
141 | m_p [0]. setY ( 0 ); | 141 | m_p [0]. setY ( 0 ); |
142 | if ( m_p [0]. y ( ) > m_p [1]. y ( )) | 142 | if ( m_p [0]. y ( ) >= dy ) |
143 | m_p [0]. setY ( m_p [1]. y ( )); | 143 | m_p [0]. setY ( dy - 1 ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) | 147 | #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) |
148 | #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) | 148 | #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) |
149 | 149 | ||
150 | 150 | ||
151 | static QRect around ( int x, int y ) | 151 | static QRect around ( int x, int y ) |
@@ -200,18 +200,18 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) | |||
200 | if ( n [m_dragged]. x ( ) >= m_scale. width ( )) | 200 | if ( n [m_dragged]. x ( ) >= m_scale. width ( )) |
201 | n [m_dragged]. setX ( m_scale. width ( ) - 1 ); | 201 | n [m_dragged]. setX ( m_scale. width ( ) - 1 ); |
202 | if ( n [0]. x ( ) > n [1]. x ( )) | 202 | if ( n [0]. x ( ) > n [1]. x ( )) |
203 | n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); | 203 | n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); |
204 | if ( n [m_dragged]. y ( ) < 0 ) | 204 | if ( n [m_dragged]. y ( ) < 0 ) |
205 | n [m_dragged]. setY ( 0 ); | 205 | n [m_dragged]. setY ( 0 ); |
206 | if ( n [m_dragged]. y ( ) >= m_scale. height ( )) | 206 | if ( n [m_dragged]. y ( ) >= m_scale. height ( )) |
207 | n [m_dragged]. setY ( m_scale. height ( ) - 1 ); | 207 | n [m_dragged]. setY ( m_scale. height ( ) - 1 ); |
208 | if ( n [0]. y ( ) > n [1]. y ( )) | 208 | //if ( n [0]. y ( ) > n [1]. y ( )) |
209 | n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); | 209 | // n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); |
210 | 210 | ||
211 | QRect r; | 211 | QRect r; |
212 | int ox [2], oy [2], nx [2], ny [2]; | 212 | int ox [2], oy [2], nx [2], ny [2]; |
213 | 213 | ||
214 | for ( int i = 0; i < 2; i++ ) { | 214 | for ( int i = 0; i < 2; i++ ) { |
215 | nx [i] = SCALEX( n [i]. x ( )); | 215 | nx [i] = SCALEX( n [i]. x ( )); |
216 | ny [i] = SCALEY( n [i]. y ( )); | 216 | ny [i] = SCALEY( n [i]. y ( )); |
217 | ox [i] = SCALEX( m_p [i]. x ( )); | 217 | ox [i] = SCALEX( m_p [i]. x ( )); |
@@ -232,18 +232,18 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) | |||
232 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); | 232 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); |
233 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); | 233 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); |
234 | 234 | ||
235 | emit endPointChanged ( endPoint ( )); | 235 | emit endPointChanged ( endPoint ( )); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | if ( r. isValid ( )) { | 239 | if ( r. isValid ( )) { |
240 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ); | 240 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ). normalize ( ); |
241 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ); | 241 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ). normalize ( ); |
242 | 242 | ||
243 | repaint ( r, false ); | 243 | repaint ( r, false ); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) | 247 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) |
248 | { | 248 | { |
249 | if ( e-> button ( ) != LeftButton ) | 249 | if ( e-> button ( ) != LeftButton ) |
@@ -269,17 +269,17 @@ void Calibration::paintEvent ( QPaintEvent *pe ) | |||
269 | int y0 = SCALEY( m_p [0]. y ( )); | 269 | int y0 = SCALEY( m_p [0]. y ( )); |
270 | int x1 = SCALEX( m_p [1]. x ( )); | 270 | int x1 = SCALEX( m_p [1]. x ( )); |
271 | int y1 = SCALEY( m_p [1]. y ( )); | 271 | int y1 = SCALEY( m_p [1]. y ( )); |
272 | 272 | ||
273 | int dx = x1 - x0; | 273 | int dx = x1 - x0; |
274 | int dy = y1 - y0; | 274 | int dy = y1 - y0; |
275 | 275 | ||
276 | // restrict steps to real x and y resolution | 276 | // restrict steps to real x and y resolution |
277 | int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( dy + 1 )); | 277 | int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 )); |
278 | 278 | ||
279 | QString stepstr = tr( "%1 Steps" ). arg ( st ); | 279 | QString stepstr = tr( "%1 Steps" ). arg ( st ); |
280 | QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); | 280 | QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); |
281 | tr. setLeft ( tr. left ( ) - 20 ); | 281 | tr. setLeft ( tr. left ( ) - 20 ); |
282 | if ( p. hasClipping ( )) | 282 | if ( p. hasClipping ( )) |
283 | p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); | 283 | p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); |
284 | 284 | ||
285 | QColorGroup g = colorGroup ( ); | 285 | QColorGroup g = colorGroup ( ); |