Commit 336cf7b6 authored by Hugo Pereira Da Costa's avatar Hugo Pereira Da Costa
Browse files

Added option to set transparency and blur behind menu frames such as right...

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
parent 4bad9962
......@@ -128,6 +128,7 @@ set(breeze_PART_SRCS
animations/breezewidgetstateengine.cpp
animations/breezewidgetstatedata.cpp
debug/breezewidgetexplorer.cpp
breezeblurhelper.cpp
breezeaddeventfilter.cpp
breezeframeshadow.cpp
breezehelper.cpp
......
......@@ -40,7 +40,7 @@
<!-- widget style -->
<group name="Style">
<!-- animations -->
<entry name="AnimationsEnabled" type="Bool">
<default>true</default>
......@@ -97,7 +97,7 @@
<entry name="ViewDrawFocusIndicator" type="Bool">
<default>true</default>
</entry>
<!-- sliders -->
<entry name="SliderDrawTickMarks" type="Bool">
<default>true</default>
......@@ -185,6 +185,11 @@
<default>false</default>
</entry>
<!-- transparency -->
<entry name="MenuOpacity" type="Int">
<default>100</default>
</entry>
</group>
</kcfg>
......@@ -30,6 +30,7 @@
#include "breezestyleconfigdata.h"
#include "breezewidgetexplorer.h"
#include "breezewindowmanager.h"
#include "breezeblurhelper.h"
#include <KColorUtils>
......@@ -152,6 +153,7 @@ namespace Breeze
, _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 @@ namespace Breeze
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<QCommandLinkButton*>( widget ) ) {
......@@ -439,6 +447,10 @@ namespace Breeze
_windowManager->unregisterWidget( widget );
_splitterFactory->unregisterWidget( widget );
#if !BREEZE_USE_KDE4
_blurHelper->unregisterWidget( widget );
#endif
// remove event filter
if( qobject_cast<QAbstractScrollArea*>( widget ) ||
qobject_cast<QDockWidget*>( widget ) ||
......@@ -3609,7 +3621,6 @@ namespace Breeze
//___________________________________________________________________________________
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
......@@ -3617,10 +3628,16 @@ namespace Breeze
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;
......
......@@ -66,6 +66,7 @@ namespace Breeze
class SplitterFactory;
class WidgetExplorer;
class WindowManager;
class BlurHelper;
//* convenience typedef for base class
#if BREEZE_USE_KDE4
......@@ -497,6 +498,9 @@ namespace Breeze
//* keyboard accelerators
Mnemonics* _mnemonics = nullptr;
//* blur helper
BlurHelper* _blurHelper = nullptr;
//* window manager
WindowManager* _windowManager = nullptr;
......
......@@ -64,6 +64,7 @@ namespace Breeze
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 @@ namespace Breeze
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 @@ namespace Breeze
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 @@ namespace Breeze
_animationsEnabled->setChecked( StyleConfigData::animationsEnabled() );
_animationsDuration->setValue( StyleConfigData::animationsDuration() );
_windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() );
_menuOpacity->setValue( StyleConfigData::menuOpacity() );
}
......
......@@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>522</width>
<height>257</height>
<width>562</width>
<height>264</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
......@@ -177,7 +183,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Anima&amp;tions duration:</string>
<string>A&amp;nimations duration:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
......@@ -380,6 +386,140 @@
</item>
</layout>
</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>
</item>
</layout>
......
Supports Markdown
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