Added option to set transparency and blur behind menu frames such as right click context menu, toolbar menu, etc.

Transparency and blur is disabled by default.
Submitted on behalf of Alex Nemeth

Differential Revision: https://phabricator.kde.org/D10170
wilder-pre-rebase
Hugo Pereira Da Costa 8 years ago
parent 4bad99624b
commit 336cf7b63a
  1. 1
      kstyle/CMakeLists.txt
  2. 5
      kstyle/breeze.kcfg
  3. 23
      kstyle/breezestyle.cpp
  4. 4
      kstyle/breezestyle.h
  5. 4
      kstyle/config/breezestyleconfig.cpp
  6. 146
      kstyle/config/ui/breezestyleconfig.ui

@ -128,6 +128,7 @@ set(breeze_PART_SRCS
animations/breezewidgetstateengine.cpp animations/breezewidgetstateengine.cpp
animations/breezewidgetstatedata.cpp animations/breezewidgetstatedata.cpp
debug/breezewidgetexplorer.cpp debug/breezewidgetexplorer.cpp
breezeblurhelper.cpp
breezeaddeventfilter.cpp breezeaddeventfilter.cpp
breezeframeshadow.cpp breezeframeshadow.cpp
breezehelper.cpp breezehelper.cpp

@ -185,6 +185,11 @@
<default>false</default> <default>false</default>
</entry> </entry>
<!-- transparency -->
<entry name="MenuOpacity" type="Int">
<default>100</default>
</entry>
</group> </group>
</kcfg> </kcfg>

@ -30,6 +30,7 @@
#include "breezestyleconfigdata.h" #include "breezestyleconfigdata.h"
#include "breezewidgetexplorer.h" #include "breezewidgetexplorer.h"
#include "breezewindowmanager.h" #include "breezewindowmanager.h"
#include "breezeblurhelper.h"
#include <KColorUtils> #include <KColorUtils>
@ -152,6 +153,7 @@ namespace Breeze
, _helper( new Helper( "breeze" ) ) , _helper( new Helper( "breeze" ) )
#else #else
, _helper( new Helper( StyleConfigData::self()->sharedConfig() ) ) , _helper( new Helper( StyleConfigData::self()->sharedConfig() ) )
, _blurHelper( new BlurHelper( this ) )
#endif #endif
, _shadowHelper( new ShadowHelper( this, *_helper ) ) , _shadowHelper( new ShadowHelper( this, *_helper ) )
@ -317,6 +319,12 @@ namespace Breeze
setTranslucentBackground( widget ); setTranslucentBackground( widget );
#if !BREEZE_USE_KDE4
if ( _helper->hasAlphaChannel( widget ) && StyleConfigData::menuOpacity() < 100 ) {
_blurHelper->registerWidget( widget->window() );
}
#endif
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
} else if( qobject_cast<QCommandLinkButton*>( widget ) ) { } else if( qobject_cast<QCommandLinkButton*>( widget ) ) {
@ -439,6 +447,10 @@ namespace Breeze
_windowManager->unregisterWidget( widget ); _windowManager->unregisterWidget( widget );
_splitterFactory->unregisterWidget( widget ); _splitterFactory->unregisterWidget( widget );
#if !BREEZE_USE_KDE4
_blurHelper->unregisterWidget( widget );
#endif
// remove event filter // remove event filter
if( qobject_cast<QAbstractScrollArea*>( widget ) || if( qobject_cast<QAbstractScrollArea*>( widget ) ||
qobject_cast<QDockWidget*>( widget ) || qobject_cast<QDockWidget*>( widget ) ||
@ -3609,7 +3621,6 @@ namespace Breeze
//___________________________________________________________________________________ //___________________________________________________________________________________
bool Style::drawPanelMenuPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const bool Style::drawPanelMenuPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const
{ {
/* /*
* do nothing if menu is embedded in another widget * do nothing if menu is embedded in another widget
* this corresponds to having a transparent background * this corresponds to having a transparent background
@ -3617,10 +3628,16 @@ namespace Breeze
if( widget && !widget->isWindow() ) return true; if( widget && !widget->isWindow() ) return true;
const auto& palette( option->palette ); const auto& palette( option->palette );
const auto background( _helper->frameBackgroundColor( palette ) );
const auto outline( _helper->frameOutlineColor( palette ) ); const auto outline( _helper->frameOutlineColor( palette ) );
const bool hasAlpha( _helper->hasAlphaChannel( widget ) ); 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 ); _helper->renderMenuFrame( painter, option->rect, background, outline, hasAlpha );
return true; return true;

@ -66,6 +66,7 @@ namespace Breeze
class SplitterFactory; class SplitterFactory;
class WidgetExplorer; class WidgetExplorer;
class WindowManager; class WindowManager;
class BlurHelper;
//* convenience typedef for base class //* convenience typedef for base class
#if BREEZE_USE_KDE4 #if BREEZE_USE_KDE4
@ -497,6 +498,9 @@ namespace Breeze
//* keyboard accelerators //* keyboard accelerators
Mnemonics* _mnemonics = nullptr; Mnemonics* _mnemonics = nullptr;
//* blur helper
BlurHelper* _blurHelper = nullptr;
//* window manager //* window manager
WindowManager* _windowManager = nullptr; WindowManager* _windowManager = nullptr;

@ -64,6 +64,7 @@ namespace Breeze
connect( _scrollBarAddLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( _scrollBarAddLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( _scrollBarSubLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( _scrollBarSubLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( _menuOpacity, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
} }
@ -85,6 +86,7 @@ namespace Breeze
StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() ); StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() );
StyleConfigData::setAnimationsDuration( _animationsDuration->value() ); StyleConfigData::setAnimationsDuration( _animationsDuration->value() );
StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex() ); StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex() );
StyleConfigData::setMenuOpacity( _menuOpacity->value() );
#if BREEZE_USE_KDE4 #if BREEZE_USE_KDE4
StyleConfigData::self()->writeConfig(); StyleConfigData::self()->writeConfig();
@ -147,6 +149,7 @@ namespace Breeze
else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true; else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true;
else if( _animationsDuration->value() != StyleConfigData::animationsDuration() ) modified = true; else if( _animationsDuration->value() != StyleConfigData::animationsDuration() ) modified = true;
else if( _windowDragMode->currentIndex() != StyleConfigData::windowDragMode() ) modified = true; else if( _windowDragMode->currentIndex() != StyleConfigData::windowDragMode() ) modified = true;
else if( _menuOpacity->value() != StyleConfigData::menuOpacity() ) modified = true;
emit changed(modified); emit changed(modified);
@ -171,6 +174,7 @@ namespace Breeze
_animationsEnabled->setChecked( StyleConfigData::animationsEnabled() ); _animationsEnabled->setChecked( StyleConfigData::animationsEnabled() );
_animationsDuration->setValue( StyleConfigData::animationsDuration() ); _animationsDuration->setValue( StyleConfigData::animationsDuration() );
_windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() ); _windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() );
_menuOpacity->setValue( StyleConfigData::menuOpacity() );
} }

@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>522</width> <width>562</width>
<height>257</height> <height>264</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -177,7 +183,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Anima&amp;tions duration:</string> <string>A&amp;nimations duration:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -380,6 +386,140 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Transparency</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="10" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="_menuOpacityTransparentLabel">
<property name="text">
<string>Transparent</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="_menuOpacityOpaqueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Opaque</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="_menuGroupDescription">
<property name="text">
<string>Menu:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="_menuOpacity">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>10</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0" colspan="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>542</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

Loading…
Cancel
Save