diff --git a/kstyle/CMakeLists.txt b/kstyle/CMakeLists.txt
--- a/kstyle/CMakeLists.txt
+++ b/kstyle/CMakeLists.txt
@@ -128,6 +128,7 @@
animations/breezewidgetstateengine.cpp
animations/breezewidgetstatedata.cpp
debug/breezewidgetexplorer.cpp
+ breezeblurhelper.cpp
breezeaddeventfilter.cpp
breezeframeshadow.cpp
breezehelper.cpp
diff --git a/kstyle/breeze.kcfg b/kstyle/breeze.kcfg
--- a/kstyle/breeze.kcfg
+++ b/kstyle/breeze.kcfg
@@ -40,7 +40,7 @@
-
+
true
@@ -97,7 +97,7 @@
true
-
+
true
@@ -185,6 +185,11 @@
false
+
+
+ 100
+
+
diff --git a/kstyle/breezeblurhelper.h b/kstyle/breezeblurhelper.h
new file mode 100644
--- /dev/null
+++ b/kstyle/breezeblurhelper.h
@@ -0,0 +1,84 @@
+#ifndef breezeblurhelper_h
+#define breezeblurhelper_h
+
+//////////////////////////////////////////////////////////////////////////////
+// breezeblurhelper.h
+// handle regions passed to kwin for blurring
+// -------------------
+//
+// Copyright (C) 2018 Alex Nemeth
+//
+// Largely rewritten from Oxygen widget style
+// Copyright (C) 2007 Thomas Luebking
+// Copyright (c) 2010 Hugo Pereira Da Costa
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//////////////////////////////////////////////////////////////////////////////
+
+#include "breeze.h"
+#include "breezehelper.h"
+
+#include
+#include
+
+#if BREEZE_HAVE_X11
+#include
+#endif
+
+namespace Breeze
+{
+ class BlurHelper: public QObject
+ {
+ Q_OBJECT
+
+ public:
+
+ //! constructor
+ BlurHelper( QObject* );
+
+ //! destructor
+ virtual ~BlurHelper( void )
+ {}
+
+ //! register widget
+ void registerWidget( QWidget* );
+
+ //! register widget
+ void unregisterWidget( QWidget* );
+
+ //! event filter
+ bool eventFilter( QObject*, QEvent* ) ;
+
+ protected:
+
+ //! install event filter to object, in a unique way
+ void addEventFilter( QObject* object )
+ {
+ object->removeEventFilter( this );
+ object->installEventFilter( this );
+ }
+
+ //! update blur regions for given widget
+ void update( QWidget* ) const;
+
+ };
+
+}
+
+#endif
diff --git a/kstyle/breezeblurhelper.cpp b/kstyle/breezeblurhelper.cpp
new file mode 100644
--- /dev/null
+++ b/kstyle/breezeblurhelper.cpp
@@ -0,0 +1,111 @@
+//////////////////////////////////////////////////////////////////////////////
+// breezeblurhelper.cpp
+// handle regions passed to kwin for blurring
+// -------------------
+//
+// Copyright (C) 2018 Alex Nemeth
+//
+// Largely rewritten from Oxygen widget style
+// Copyright (C) 2007 Thomas Luebking
+// Copyright (c) 2010 Hugo Pereira Da Costa
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//////////////////////////////////////////////////////////////////////////////
+
+#include "breezeblurhelper.h"
+#include "breezestyleconfigdata.h"
+
+#include
+
+#include
+#include
+
+namespace Breeze
+{
+ //___________________________________________________________
+ BlurHelper::BlurHelper(QObject* parent):
+ QObject(parent)
+ {
+ }
+
+ //___________________________________________________________
+ void BlurHelper::registerWidget(QWidget* widget)
+ {
+ // install event filter
+ addEventFilter(widget);
+
+ // schedule shadow area repaint
+ update(widget);
+ }
+
+ //___________________________________________________________
+ void BlurHelper::unregisterWidget(QWidget* widget)
+ {
+ // remove event filter
+ widget->removeEventFilter(this);
+ }
+
+ //___________________________________________________________
+ bool BlurHelper::eventFilter(QObject* object, QEvent* event)
+ {
+ switch (event->type()) {
+ case QEvent::Hide:
+ case QEvent::Show:
+ case QEvent::Resize:
+ {
+ // cast to widget and check
+ QWidget* widget(qobject_cast(object));
+
+ if (!widget)
+ break;
+
+ update(widget);
+ break;
+ }
+
+ default: break;
+ }
+
+ // never eat events
+ return false;
+ }
+
+ //___________________________________________________________
+ void BlurHelper::update(QWidget* widget) const
+ {
+ #if BREEZE_HAVE_X11
+ /*
+ directly from bespin code. Supposibly prevent playing with some 'pseudo-widgets'
+ that have winId matching some other -random- window
+ */
+ if (!(widget->testAttribute(Qt::WA_WState_Created) || widget->internalWinId()))
+ return;
+
+ KWindowEffects::enableBlurBehind(widget->winId(), true);
+
+ // force update
+ if (widget->isVisible()) {
+ widget->update();
+ }
+
+ #else
+ Q_UNUSED( widget )
+ #endif
+ }
+}
diff --git a/kstyle/breezestyle.h b/kstyle/breezestyle.h
--- a/kstyle/breezestyle.h
+++ b/kstyle/breezestyle.h
@@ -66,6 +66,7 @@
class SplitterFactory;
class WidgetExplorer;
class WindowManager;
+ class BlurHelper;
//* convenience typedef for base class
#if BREEZE_USE_KDE4
@@ -497,6 +498,9 @@
//* keyboard accelerators
Mnemonics* _mnemonics = nullptr;
+ //* blur helper
+ BlurHelper* _blurHelper = nullptr;
+
//* window manager
WindowManager* _windowManager = nullptr;
diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -30,6 +30,7 @@
#include "breezestyleconfigdata.h"
#include "breezewidgetexplorer.h"
#include "breezewindowmanager.h"
+#include "breezeblurhelper.h"
#include
@@ -152,6 +153,7 @@
, _helper( new Helper( "breeze" ) )
#else
, _helper( new Helper( StyleConfigData::self()->sharedConfig() ) )
+ , _blurHelper( new BlurHelper( this ) )
#endif
, _shadowHelper( new ShadowHelper( this, *_helper ) )
@@ -317,6 +319,12 @@
setTranslucentBackground( widget );
+ #if !BREEZE_USE_KDE4
+ if ( _helper->hasAlphaChannel( widget ) && StyleConfigData::menuOpacity() < 100 ) {
+ _blurHelper->registerWidget( widget->window() );
+ }
+ #endif
+
#if QT_VERSION >= 0x050000
} else if( qobject_cast( widget ) ) {
@@ -439,6 +447,10 @@
_windowManager->unregisterWidget( widget );
_splitterFactory->unregisterWidget( widget );
+ #if !BREEZE_USE_KDE4
+ _blurHelper->unregisterWidget( widget );
+ #endif
+
// remove event filter
if( qobject_cast( widget ) ||
qobject_cast( widget ) ||
@@ -3609,18 +3621,23 @@
//___________________________________________________________________________________
bool Style::drawPanelMenuPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const
{
-
/*
* do nothing if menu is embedded in another widget
* this corresponds to having a transparent background
*/
if( widget && !widget->isWindow() ) return true;
const auto& palette( option->palette );
- const auto background( _helper->frameBackgroundColor( palette ) );
const auto outline( _helper->frameOutlineColor( palette ) );
-
const bool hasAlpha( _helper->hasAlphaChannel( widget ) );
+ auto background( _helper->frameBackgroundColor( palette ) );
+
+ #if !BREEZE_USE_KDE4
+ if ( hasAlpha ) {
+ background.setAlphaF(StyleConfigData::menuOpacity() / 100.0);
+ }
+ #endif
+
_helper->renderMenuFrame( painter, option->rect, background, outline, hasAlpha );
return true;
diff --git a/kstyle/config/breezestyleconfig.cpp b/kstyle/config/breezestyleconfig.cpp
--- a/kstyle/config/breezestyleconfig.cpp
+++ b/kstyle/config/breezestyleconfig.cpp
@@ -64,6 +64,7 @@
connect( _scrollBarAddLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( _scrollBarSubLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
+ connect( _menuOpacity, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
}
@@ -84,7 +85,8 @@
StyleConfigData::setScrollBarSubLineButtons( _scrollBarSubLineButtons->currentIndex() );
StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() );
StyleConfigData::setAnimationsDuration( _animationsDuration->value() );
- StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex() );
+ StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex() );
+ StyleConfigData::setMenuOpacity( _menuOpacity->value() );
#if BREEZE_USE_KDE4
StyleConfigData::self()->writeConfig();
@@ -147,6 +149,7 @@
else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true;
else if( _animationsDuration->value() != StyleConfigData::animationsDuration() ) modified = true;
else if( _windowDragMode->currentIndex() != StyleConfigData::windowDragMode() ) modified = true;
+ else if( _menuOpacity->value() != StyleConfigData::menuOpacity() ) modified = true;
emit changed(modified);
@@ -171,6 +174,7 @@
_animationsEnabled->setChecked( StyleConfigData::animationsEnabled() );
_animationsDuration->setValue( StyleConfigData::animationsDuration() );
_windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() );
+ _menuOpacity->setValue( StyleConfigData::menuOpacity() );
}
diff --git a/kstyle/config/ui/breezestyleconfig.ui b/kstyle/config/ui/breezestyleconfig.ui
--- a/kstyle/config/ui/breezestyleconfig.ui
+++ b/kstyle/config/ui/breezestyleconfig.ui
@@ -6,10 +6,16 @@
0
0
- 522
- 257
+ 562
+ 264
+
+
+ 0
+ 0
+
+
0
@@ -177,7 +183,7 @@
false
- Anima&tions duration:
+ A&nimations duration:
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
@@ -380,6 +386,140 @@
+
+
+ Transparency
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
-
+
+
+ Transparent
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Opaque
+
+
+
+
+
+ -
+
+
-
+
+
+ Menu:
+
+
+
+ -
+
+
+ 0
+
+
+ 100
+
+
+ 1
+
+
+ 10
+
+
+ 100
+
+
+ Qt::Horizontal
+
+
+ false
+
+
+ false
+
+
+ QSlider::TicksBelow
+
+
+ 10
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Preferred
+
+
+
+ 542
+ 20
+
+
+
+
+
+