Commit a99f77ca authored by Mathias Soeken's avatar Mathias Soeken

Add buttons to rotate the ruler (turn left, turn right). The buttons are only...

Add buttons to rotate the ruler (turn left, turn right). The buttons are only visible when hovering over 
the ruler and if they are configured to be visible (default: not visible).

BUGS: 87987

svn path=/trunk/KDE/kdegraphics/kruler/; revision=923701
parent e0f25568
......@@ -34,13 +34,20 @@
<item row="2" column="1" >
<widget class="KFontRequester" name="kcfg_ScaleFont" />
</item>
<item row="3" column="1" >
<item row="4" column="1" >
<widget class="QCheckBox" name="kcfg_TrayIcon" >
<property name="text" >
<string>Show tray icon</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QCheckBox" name="kcfg_RotateButtonsVisible" >
<property name="text" >
<string>Show rotation buttons</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutfunction spacing="KDialog::spacingHint" margin="KDialog::marginHint" />
......
......@@ -24,6 +24,7 @@
#include <QMouseEvent>
#include <QShortcut>
#include <QSlider>
#include <QToolButton>
#include <QWidgetAction>
#include <KAction>
......@@ -131,12 +132,24 @@ KLineal::KLineal( QWidget *parent )
"The rectangles background shows the color of the pixel inside the "
"little square at the end of the line cursor." ) );
mBtnRotateLeft = new QToolButton( this );
mBtnRotateLeft->setGeometry( mLongEdgeLen / 2 - 28, 5, 26, 26 );
mBtnRotateLeft->setIcon( KIcon( "object-rotate-left" ) );
mBtnRotateLeft->hide();
connect( mBtnRotateLeft, SIGNAL( clicked() ), this, SLOT( turnLeft() ) );
mBtnRotateRight = new QToolButton( this );
mBtnRotateRight->setGeometry( mLongEdgeLen / 2 + 2, 5, 26, 26 );
mBtnRotateRight->setIcon( KIcon( "object-rotate-right" ) );
mBtnRotateRight->hide();
connect( mBtnRotateRight, SIGNAL( clicked() ), this, SLOT( turnRight() ) );
resize( QSize( mLongEdgeLen, mShortEdgeLen ) );
//BEGIN setup menu and actions
mActionCollection = new KActionCollection( this );
mActionCollection->setConfigGroup( "Actions" );
//BEGIN setup menu and actions
mMenu = new KMenu( this );
mMenu->addTitle( i18n( "KRuler" ) );
KMenu *oriMenu = new KMenu( i18n( "&Orientation"), this );
......@@ -380,24 +393,32 @@ void KLineal::setOrientation( int inOrientation )
case North:
mLabel->move( 4, height()-mLabel->height() - 4 );
mColorLabel->move( mLabel->pos() + QPoint( 0, -20 ) );
mBtnRotateLeft->move( mLongEdgeLen / 2 - 28, height() - 31 );
mBtnRotateRight->move( mLongEdgeLen / 2 + 2, height() - 31 );
mCurrentCursor = mNorthCursor;
break;
case South:
mLabel->move( 4, 4 );
mColorLabel->move( mLabel->pos() + QPoint( 0, 20 ) );
mBtnRotateLeft->move( mLongEdgeLen / 2 - 28, 5 );
mBtnRotateRight->move( mLongEdgeLen / 2 + 2, 5 );
mCurrentCursor = mSouthCursor;
break;
case East:
mLabel->move( 4, 4 );
mColorLabel->move( mLabel->pos() + QPoint( 0, 20 ) );
mBtnRotateLeft->move( 5, mLongEdgeLen / 2 - 28 );
mBtnRotateRight->move( 5, mLongEdgeLen / 2 + 2 );
mCurrentCursor = mEastCursor;
break;
case West:
mLabel->move( width()-mLabel->width() - 4, 4 );
mColorLabel->move( mLabel->pos() + QPoint( -5, 20 ) );
mBtnRotateLeft->move( width() - 31, mLongEdgeLen / 2 - 28 );
mBtnRotateRight->move( width() - 31, mLongEdgeLen / 2 + 2 );
mCurrentCursor = mWestCursor;
break;
}
......@@ -679,6 +700,10 @@ void KLineal::showLabel()
adjustLabel();
mLabel->show();
mColorLabel->show();
if ( RulerSettings::self()->rotateButtonsVisible() ) {
mBtnRotateLeft->show();
mBtnRotateRight->show();
}
}
/**
......@@ -688,6 +713,8 @@ void KLineal::hideLabel()
{
mLabel->hide();
mColorLabel->hide();
mBtnRotateLeft->hide();
mBtnRotateRight->hide();
}
/**
......
......@@ -21,6 +21,7 @@
#include <QWidget>
class QAutoSizeLabel;
class QToolButton;
class KAction;
class KActionCollection;
......@@ -90,6 +91,7 @@ private:
bool mRelativeScale;
KActionCollection *mActionCollection;
int mOpacity;
QToolButton *mBtnRotateLeft, *mBtnRotateRight;
public slots:
void setOrientation( int );
......
......@@ -41,5 +41,9 @@
<label>Opacity of the window</label>
<default>255</default>
</entry>
<entry name="RotateButtonsVisible" type="Bool">
<label>Are the rotate buttons visible?</label>
<default>false</default>
</entry>
</group>
</kcfg>
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