Commit b60dce5a authored by Mathias Soeken's avatar Mathias Soeken

Changing the offset via the mouse wheel is now possible when holding the left mouse button.

When just using the wheel you can resize the ruler pixel by pixel.

When changing offset or length via wheel the new offset and length are displayed in the label on the 
ruler, respectively

CCBUGS: 87987

svn path=/trunk/KDE/kdegraphics/kruler/; revision=917321
parent 613dc0a4
......@@ -449,6 +449,32 @@ void KLineal::reLength( int percentOfScreen )
saveSettings();
}
void KLineal::reLengthAbsolute( int length )
{
if ( length < 100 ) {
return;
}
QRect r = KGlobalSettings::desktopGeometry( this );
mLongEdgeLen = length;
if ( mOrientation == North || mOrientation == South ) {
resize( mLongEdgeLen, height() );
} else {
resize( width(), mLongEdgeLen );
}
if ( x() + width() < 10 ) {
move( 10, y() );
}
if ( y() + height() < 10 ) {
move( x(), 10 );
}
saveSettings();
}
void KLineal::updateScaleDirectionMenuItem()
{
if ( !mScaleDirectionAction ) return;
......@@ -526,7 +552,7 @@ void KLineal::slotLength()
0, width, 1, &ok, this );
if ( ok ) {
reLength( ( newLength * 100.f ) / width );
reLengthAbsolute( newLength );
}
}
......@@ -793,15 +819,23 @@ void KLineal::mouseReleaseEvent( QMouseEvent *inEvent )
void KLineal::wheelEvent( QWheelEvent *e )
{
if ( !mRelativeScale ) {
int numDegrees = e->delta() / 8;
int numSteps = numDegrees / 15;
mOffset += numSteps;
repaint();
adjustLabel();
saveSettings();
int numDegrees = e->delta() / 8;
int numSteps = numDegrees / 15;
// changing offset
if ( e->buttons() == Qt::LeftButton ) {
if ( !mRelativeScale ) {
mLabel->show();
mOffset += numSteps;
repaint();
mLabel->setText( i18n( "Offset: %1" ).arg( mOffset ) );
saveSettings();
}
} else { // changing length
int newLength = mLongEdgeLen + numSteps;
reLengthAbsolute( newLength );
mLabel->setText( i18n( "Length: %1 px" ).arg( newLength ) );
}
QWidget::wheelEvent( e );
......
......@@ -52,6 +52,7 @@ private:
void drawScale( QPainter &painter );
void drawBackground( QPainter &painter );
void reLength( int percentOfScreen );
void reLengthAbsolute( int length );
void updateScaleDirectionMenuItem();
bool mDragging;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment