From 613dc0a44057ad6454004328c0408815a07ec5c7 Mon Sep 17 00:00:00 2001 From: Mathias Soeken Date: Mon, 19 Jan 2009 11:43:49 +0000 Subject: [PATCH] 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 --- klineal.cpp | 23 +++++++++++++++++++++++ klineal.h | 1 + kruler.kcfg | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/klineal.cpp b/klineal.cpp index 17f11e3..7087a2a 100644 --- a/klineal.cpp +++ b/klineal.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -189,6 +191,20 @@ KLineal::KLineal( QWidget *parent ) new QShortcut( Qt::Key_O, this, SLOT( slotOffset() ) ); 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->addSeparator(); KAction *copyColorAction = KStandardAction::copy( this, SLOT( copyColor() ), this ); @@ -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() { KConfigDialog *dialog = new KConfigDialog( this, "settings", RulerSettings::self() ); diff --git a/klineal.h b/klineal.h index bc0915b..db2b9c1 100644 --- a/klineal.h +++ b/klineal.h @@ -101,6 +101,7 @@ public slots: void centerOrigin(); void slotOffset(); void slotLength(); + void slotOpacity( int value ); void slotPreferences(); void switchRelativeScale( bool checked ); void copyColor(); diff --git a/kruler.kcfg b/kruler.kcfg index 7fce971..e495bf4 100644 --- a/kruler.kcfg +++ b/kruler.kcfg @@ -37,5 +37,9 @@ false + + + 100 + -- GitLab