diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) include_directories(${KDE4_INCLUDES}) - add_subdirectory(libbreezecommon) add_subdirectory(kstyle) else() find_package(ECM 0.0.9 REQUIRED NO_MODULE) diff --git a/kstyle/CMakeLists.txt b/kstyle/CMakeLists.txt --- a/kstyle/CMakeLists.txt +++ b/kstyle/CMakeLists.txt @@ -123,10 +123,8 @@ breezeaddeventfilter.cpp breezeframeshadow.cpp breezehelper.cpp - breezemdiwindowshadow.cpp breezemnemonics.cpp breezepropertynames.cpp - breezeshadowhelper.cpp breezesplitterproxy.cpp breezestyle.cpp breezestyleplugin.cpp @@ -138,15 +136,16 @@ set(breeze_PART_SRCS ${breeze_PART_SRCS} breezeblurhelper.cpp + breezemdiwindowshadow.cpp + breezeshadowhelper.cpp ) endif() if(BREEZE_USE_KDE4) kde4_add_kcfg_files(breeze_PART_SRCS breezestyleconfigdata.kcfgc) kde4_add_plugin(breeze ${breeze_PART_SRCS} kstylekde4compat.cpp) target_link_libraries(breeze ${KDE4_KDEUI_LIBS}) - target_link_libraries(breeze breezecommon4) if(BREEZE_HAVE_X11) target_link_libraries(breeze ${X11_XCB_LIBRARIES}) diff --git a/kstyle/breezeshadowhelper.cpp b/kstyle/breezeshadowhelper.cpp --- a/kstyle/breezeshadowhelper.cpp +++ b/kstyle/breezeshadowhelper.cpp @@ -267,11 +267,7 @@ painter.setBrush(Qt::black); painter.setCompositionMode(QPainter::CompositionMode_DestinationOut); painter.drawRoundedRect( -#if BREEZE_USE_KDE4 - outerRect.adjusted(margins.left(), margins.top(), -margins.right(), -margins.bottom()), -#else outerRect - margins, -#endif frameRadius, frameRadius); @@ -406,14 +402,7 @@ int bottom = widget->contentsMargins().bottom(); // Need to decrement default size further due to extra hard coded round corner. -#if BREEZE_USE_KDE4 - margins.setLeft(margins.left() - 1); - margins.setTop(margins.top() - 1); - margins.setRight(margins.right() - 1); - margins.setBottom(margins.bottom() - 1); -#else margins -= 1; -#endif // Arrow can be either to the top or the bottom. Adjust margins accordingly. const int diff = qAbs(top - bottom); @@ -424,15 +413,7 @@ } } -#if BREEZE_USE_KDE4 - const qreal dpr = _helper.devicePixelRatio(_shadowTiles.pixmap(0)); - margins.setLeft(margins.left() * dpr); - margins.setTop(margins.top() * dpr); - margins.setRight(margins.right() * dpr); - margins.setBottom(margins.bottom() * dpr); -#else margins *= _helper.devicePixelRatio(_shadowTiles.pixmap(0)); -#endif return margins; } diff --git a/kstyle/breezestyle.h b/kstyle/breezestyle.h --- a/kstyle/breezestyle.h +++ b/kstyle/breezestyle.h @@ -148,7 +148,9 @@ bool eventFilterScrollArea( QWidget*, QEvent* ); bool eventFilterComboBoxContainer( QWidget*, QEvent* ); bool eventFilterDockWidget( QDockWidget*, QEvent* ); + #if !BREEZE_USE_KDE4 bool eventFilterMdiSubWindow( QMdiSubWindow*, QEvent* ); + #endif #if QT_VERSION >= 0x050000 bool eventFilterCommandLinkButton( QCommandLinkButton*, QEvent* ); @@ -492,8 +494,10 @@ //* helper Helper* _helper = nullptr; + #if !BREEZE_USE_KDE4 //* shadow helper ShadowHelper* _shadowHelper = nullptr; + #endif //* animations Animations* _animations = nullptr; @@ -512,8 +516,10 @@ //* frame shadows FrameShadowFactory* _frameShadowFactory = nullptr; + #if !BREEZE_USE_KDE4 //* mdi window shadows MdiWindowShadowFactory* _mdiWindowShadowFactory = nullptr; + #endif //* splitter Factory, to extend splitters hit area SplitterFactory* _splitterFactory = nullptr; diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -22,10 +22,14 @@ #include "breeze.h" #include "breezeanimations.h" #include "breezeframeshadow.h" +#if !BREEZE_USE_KDE4 #include "breezemdiwindowshadow.h" +#endif #include "breezemnemonics.h" #include "breezepropertynames.h" +#if !BREEZE_USE_KDE4 #include "breezeshadowhelper.h" +#endif #include "breezesplitterproxy.h" #include "breezestyleconfigdata.h" #include "breezewidgetexplorer.h" @@ -161,9 +165,9 @@ _helper( new Helper( "breeze" ) ) #else _helper( new Helper( StyleConfigData::self()->sharedConfig() ) ) - #endif , _shadowHelper( new ShadowHelper( this, *_helper ) ) + #endif , _animations( new Animations( this ) ) , _mnemonics( new Mnemonics( this ) ) @@ -173,7 +177,9 @@ , _windowManager( new WindowManager( this ) ) , _frameShadowFactory( new FrameShadowFactory( this ) ) + #if !BREEZE_USE_KDE4 , _mdiWindowShadowFactory( new MdiWindowShadowFactory( this ) ) + #endif , _splitterFactory( new SplitterFactory( this ) ) , _widgetExplorer( new WidgetExplorer( this ) ) , _tabBarData( new BreezePrivate::TabBarData( this ) ) @@ -210,7 +216,9 @@ //______________________________________________________________ Style::~Style() { + #if !BREEZE_USE_KDE4 delete _shadowHelper; + #endif delete _helper; } @@ -223,8 +231,10 @@ _animations->registerWidget( widget ); _windowManager->registerWidget( widget ); _frameShadowFactory->registerWidget( widget, *_helper ); + #if !BREEZE_USE_KDE4 _mdiWindowShadowFactory->registerWidget( widget ); _shadowHelper->registerWidget( widget ); + #endif _splitterFactory->registerWidget( widget ); // enable mouse over effects for all necessary widgets @@ -317,11 +327,13 @@ widget->setContentsMargins( Metrics::Frame_FrameWidth, Metrics::Frame_FrameWidth, Metrics::Frame_FrameWidth, Metrics::Frame_FrameWidth ); addEventFilter( widget ); + #if !BREEZE_USE_KDE4 } else if( qobject_cast( widget ) ) { widget->setAutoFillBackground( false ); addEventFilter( widget ); + #endif } else if( qobject_cast( widget ) ) { widget->setBackgroundRole( QPalette::NoRole ); @@ -450,19 +462,21 @@ // register widget to animations _animations->unregisterWidget( widget ); _frameShadowFactory->unregisterWidget( widget ); - _mdiWindowShadowFactory->unregisterWidget( widget ); - _shadowHelper->unregisterWidget( widget ); _windowManager->unregisterWidget( widget ); _splitterFactory->unregisterWidget( widget ); #if !BREEZE_USE_KDE4 + _shadowHelper->unregisterWidget( widget ); + _mdiWindowShadowFactory->unregisterWidget( widget ); _blurHelper->unregisterWidget( widget ); #endif // remove event filter if( qobject_cast( widget ) || qobject_cast( widget ) || + #if !BREEZE_USE_KDE4 qobject_cast( widget ) || + #endif widget->inherits( "QComboBoxPrivateContainer" ) ) { widget->removeEventFilter( this ); } @@ -1024,8 +1038,8 @@ { if( auto dockWidget = qobject_cast( object ) ) { return eventFilterDockWidget( dockWidget, event ); } - else if( auto subWindow = qobject_cast( object ) ) { return eventFilterMdiSubWindow( subWindow, event ); } #if QT_VERSION >= 0x050000 + else if( auto subWindow = qobject_cast( object ) ) { return eventFilterMdiSubWindow( subWindow, event ); } else if( auto commandLinkButton = qobject_cast( object ) ) { return eventFilterCommandLinkButton( commandLinkButton, event ); } #endif #if QT_VERSION < 0x050D00 // Check if Qt version < 5.13 @@ -1223,6 +1237,7 @@ } //____________________________________________________________________________ + #if !BREEZE_USE_KDE4 bool Style::eventFilterMdiSubWindow( QMdiSubWindow* subWindow, QEvent* event ) { @@ -1256,6 +1271,7 @@ return false; } + #endif //____________________________________________________________________________ #if QT_VERSION >= 0x050000 @@ -1430,10 +1446,12 @@ _splitterFactory->setEnabled( StyleConfigData::splitterProxyEnabled() ); // reset shadow tiles + #if !BREEZE_USE_KDE4 _shadowHelper->loadConfig(); // set mdiwindow factory shadow tiles _mdiWindowShadowFactory->setShadowHelper( _shadowHelper ); + #endif // clear icon cache _iconCache.clear(); @@ -3719,9 +3737,11 @@ bool Style::drawPanelTipLabelPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const { + #if !BREEZE_USE_KDE4 // force registration of widget if( widget && widget->window() ) { _shadowHelper->registerWidget( widget->window(), true ); } + #endif const auto& palette( option->palette ); const auto &background = palette.color( QPalette::ToolTipBase ); diff --git a/libbreezecommon/CMakeLists.txt b/libbreezecommon/CMakeLists.txt --- a/libbreezecommon/CMakeLists.txt +++ b/libbreezecommon/CMakeLists.txt @@ -1,58 +1,25 @@ -set(BREEZE_COMMON_USE_KDE4 ${USE_KDE4}) - -if (BREEZE_COMMON_USE_KDE4) - ############ Language and toolchain features - ############ copied from ECM - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND NOT WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - endif () -endif () - ################# dependencies ################# ### Qt/KDE -if (NOT BREEZE_COMMON_USE_KDE4) - find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets) -endif () - -################# configuration ################# -configure_file(config-breezecommon.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-breezecommon.h ) +find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets) ################# breezestyle target ################# set(breezecommon_LIB_SRCS breezeboxshadowrenderer.cpp ) -if (BREEZE_COMMON_USE_KDE4) - kde4_add_library(breezecommon4 SHARED ${breezecommon_LIB_SRCS}) - - generate_export_header(breezecommon4 - BASE_NAME breezecommon - EXPORT_FILE_NAME breezecommon_export.h) - - target_link_libraries(breezecommon4 ${KDE4_KDEUI_LIBS}) - - set_target_properties(breezecommon4 PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}) - - install(TARGETS breezecommon4 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) -else () - add_library(breezecommon5 ${breezecommon_LIB_SRCS}) +add_library(breezecommon5 ${breezecommon_LIB_SRCS}) - generate_export_header(breezecommon5 - BASE_NAME breezecommon - EXPORT_FILE_NAME breezecommon_export.h) +generate_export_header(breezecommon5 + BASE_NAME breezecommon + EXPORT_FILE_NAME breezecommon_export.h) - target_link_libraries(breezecommon5 - PUBLIC - Qt5::Core - Qt5::Gui) +target_link_libraries(breezecommon5 + PUBLIC + Qt5::Core + Qt5::Gui) - set_target_properties(breezecommon5 PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}) +set_target_properties(breezecommon5 PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}) - install(TARGETS breezecommon5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) -endif () +install(TARGETS breezecommon5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) diff --git a/libbreezecommon/breezeboxshadowrenderer.cpp b/libbreezecommon/breezeboxshadowrenderer.cpp --- a/libbreezecommon/breezeboxshadowrenderer.cpp +++ b/libbreezecommon/breezeboxshadowrenderer.cpp @@ -21,17 +21,9 @@ // own #include "breezeboxshadowrenderer.h" -// auto-generated -#include "config-breezecommon.h" - // Qt #include - -#ifdef BREEZE_COMMON_USE_KDE4 -#include -#else #include -#endif namespace Breeze { @@ -96,10 +88,7 @@ break; default: -#if !BREEZE_COMMON_USE_KDE4 Q_UNREACHABLE(); -#endif - break; } Q_ASSERT(major + minor + final == blurRadius); @@ -258,16 +247,10 @@ const QSize inflation = calculateBlurExtent(radius); const QSize size = rect.size() + 2 * inflation; -#if BREEZE_COMMON_USE_KDE4 - const qreal dpr = 1.0; -#else const qreal dpr = painter->device()->devicePixelRatioF(); -#endif QImage shadow(size * dpr, QImage::Format_ARGB32_Premultiplied); -#if !BREEZE_COMMON_USE_KDE4 shadow.setDevicePixelRatio(dpr); -#endif shadow.fill(Qt::transparent); QRect boxRect(QPoint(0, 0), rect.size()); @@ -335,30 +318,20 @@ } QSize canvasSize; -#if BREEZE_COMMON_USE_KDE4 - foreach (const Shadow &shadow, m_shadows) { -#else for (const Shadow &shadow : qAsConst(m_shadows)) { -#endif canvasSize = canvasSize.expandedTo( calculateMinimumShadowTextureSize(m_boxSize, shadow.radius, shadow.offset)); } QImage canvas(canvasSize * m_dpr, QImage::Format_ARGB32_Premultiplied); -#if !BREEZE_COMMON_USE_KDE4 canvas.setDevicePixelRatio(m_dpr); -#endif canvas.fill(Qt::transparent); QRect boxRect(QPoint(0, 0), m_boxSize); boxRect.moveCenter(QRect(QPoint(0, 0), canvasSize).center()); QPainter painter(&canvas); -#if BREEZE_COMMON_USE_KDE4 - foreach (const Shadow &shadow, m_shadows) { -#else for (const Shadow &shadow : qAsConst(m_shadows)) { -#endif renderShadow(&painter, boxRect, m_borderRadius, shadow.offset, shadow.radius, shadow.color); } painter.end(); diff --git a/libbreezecommon/config-breezecommon.h.cmake b/libbreezecommon/config-breezecommon.h.cmake deleted file mode 100644 --- a/libbreezecommon/config-breezecommon.h.cmake +++ /dev/null @@ -1,28 +0,0 @@ -/* config-breezecommon.h. Generated by cmake from config-breezecommon.h.cmake */ - -/************************************************************************* - * Copyright (C) 2014 by Hugo Pereira Da Costa * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - *************************************************************************/ - -#ifndef config_breeze_common_h -#define config_breeze_common_h - -/* Define to 1 if breeze is compiled against KDE4 */ -#cmakedefine01 BREEZE_COMMON_USE_KDE4 - -#endif