Commit e0f25568 authored by Mathias Soeken's avatar Mathias Soeken

With Qt 4.5 we can create real ARGB translucent widgets. Now kruler can be...

With Qt 4.5 we can create real ARGB translucent widgets. Now kruler can be made transparent, but with 
painting the scale fully opaque. This makes it more the ruler feeling!

svn path=/trunk/KDE/kdegraphics/kruler/; revision=922751
parent a86f742b
......@@ -84,7 +84,7 @@ KLineal::KLineal( QWidget *parent )
KWindowSystem::setType( winId(), NET::Override ); // or NET::Normal
KWindowSystem::setState( winId(), NET::KeepAbove );
//setAttribute( Qt::WA_TranslucentBackground );
setAttribute( Qt::WA_TranslucentBackground );
setWindowFlags( Qt::FramelessWindowHint );
setMinimumSize( 60, 60 );
......@@ -185,15 +185,15 @@ KLineal::KLineal( QWidget *parent )
connect( relativeScaleAction, SIGNAL( toggled( bool ) ), this, SLOT( switchRelativeScale( bool ) ) );
mMenu->addMenu( scaleMenu );
setWindowOpacity( RulerSettings::self()->opacity() / 100.0 );
mOpacity = RulerSettings::self()->opacity();
KMenu* opacityMenu = new KMenu( i18n( "O&pacity" ), this );
QWidgetAction *opacityAction = new QWidgetAction( this );
QSlider *slider = new QSlider( this );
slider->setMinimum( 10 );
slider->setMaximum( 100 );
slider->setMinimum( 0 );
slider->setMaximum( 255 );
slider->setSingleStep( 1 );
slider->setOrientation( Qt::Horizontal );
slider->setValue( int( windowOpacity() * 100 ) );
slider->setValue( RulerSettings::self()->opacity() );
connect( slider, SIGNAL( valueChanged( int ) ), this, SLOT( slotOpacity( int ) ) );
opacityAction->setDefaultWidget( slider );
opacityMenu->addAction( opacityAction );
......@@ -322,6 +322,8 @@ void KLineal::drawBackground( QPainter& painter )
gradient = QLinearGradient( 0, 1, width(), 1 );
break;
}
a.setAlpha( mOpacity );
b.setAlpha( mOpacity );
gradient.setColorAt( 0, a );
gradient.setColorAt( 1, b );
painter.fillRect( rect(), QBrush( gradient ) );
......@@ -577,7 +579,8 @@ void KLineal::slotLength()
void KLineal::slotOpacity( int value )
{
setWindowOpacity( value / 100.0 );
mOpacity = value;
repaint();
RulerSettings::self()->setOpacity( value );
RulerSettings::self()->writeConfig();
}
......
......@@ -89,6 +89,7 @@ private:
int mOffset;
bool mRelativeScale;
KActionCollection *mActionCollection;
int mOpacity;
public slots:
void setOrientation( int );
......
......@@ -39,7 +39,7 @@
</entry>
<entry name="Opacity" type="Int">
<label>Opacity of the window</label>
<default>100</default>
<default>255</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