Commit 613dc0a4 authored by Mathias Soeken's avatar Mathias Soeken

kruler is now configurable to be (semi-)transparent. There is a new menu...

kruler is now configurable to be (semi-)transparent. There is a new menu "Opacity" in the context menu 
with a slider to set windowOpacity. This value is stored and restored in the settings file.

BUGS: 116318


svn path=/trunk/KDE/kdegraphics/kruler/; revision=913428
parent 2c1742ce
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include <QPainter> #include <QPainter>
#include <QMouseEvent> #include <QMouseEvent>
#include <QShortcut> #include <QShortcut>
#include <QSlider>
#include <QWidgetAction>
#include <KAction> #include <KAction>
#include <KColorDialog> #include <KColorDialog>
...@@ -189,6 +191,20 @@ KLineal::KLineal( QWidget *parent ) ...@@ -189,6 +191,20 @@ KLineal::KLineal( QWidget *parent )
new QShortcut( Qt::Key_O, this, SLOT( slotOffset() ) ); new QShortcut( Qt::Key_O, this, SLOT( slotOffset() ) );
mMenu->addMenu( scaleMenu ); mMenu->addMenu( scaleMenu );
setWindowOpacity( RulerSettings::self()->opacity() / 100.0 );
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->setSingleStep( 1 );
slider->setOrientation( Qt::Horizontal );
slider->setValue( int( windowOpacity() * 100 ) );
connect( slider, SIGNAL( valueChanged( int ) ), this, SLOT( slotOpacity( int ) ) );
opacityAction->setDefaultWidget( slider );
opacityMenu->addAction( opacityAction );
mMenu->addMenu( opacityMenu );
mMenu->addAction( KStandardAction::preferences( this, SLOT( slotPreferences() ), this ) ); mMenu->addAction( KStandardAction::preferences( this, SLOT( slotPreferences() ), this ) );
mMenu->addSeparator(); mMenu->addSeparator();
KAction *copyColorAction = KStandardAction::copy( this, SLOT( copyColor() ), this ); KAction *copyColorAction = KStandardAction::copy( this, SLOT( copyColor() ), this );
...@@ -514,6 +530,13 @@ void KLineal::slotLength() ...@@ -514,6 +530,13 @@ void KLineal::slotLength()
} }
} }
void KLineal::slotOpacity( int value )
{
setWindowOpacity( value / 100.0 );
RulerSettings::self()->setOpacity( value );
RulerSettings::self()->writeConfig();
}
void KLineal::slotPreferences() void KLineal::slotPreferences()
{ {
KConfigDialog *dialog = new KConfigDialog( this, "settings", RulerSettings::self() ); KConfigDialog *dialog = new KConfigDialog( this, "settings", RulerSettings::self() );
......
...@@ -101,6 +101,7 @@ public slots: ...@@ -101,6 +101,7 @@ public slots:
void centerOrigin(); void centerOrigin();
void slotOffset(); void slotOffset();
void slotLength(); void slotLength();
void slotOpacity( int value );
void slotPreferences(); void slotPreferences();
void switchRelativeScale( bool checked ); void switchRelativeScale( bool checked );
void copyColor(); void copyColor();
......
...@@ -37,5 +37,9 @@ ...@@ -37,5 +37,9 @@
<label>Is a tray icon used</label> <label>Is a tray icon used</label>
<default>false</default> <default>false</default>
</entry> </entry>
<entry name="Opacity" type="Int">
<label>Opacity of the window</label>
<default>100</default>
</entry>
</group> </group>
</kcfg> </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