diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,97 +7,58 @@ include(WriteBasicConfigVersionFile) include(FeatureSummary) -set(OXYGEN_USE_KDE4 ${USE_KDE4}) -if(OXYGEN_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() - ################# Qt/KDE ################# -if(OXYGEN_USE_KDE4) - - find_package(KDE4 REQUIRED) - include(KDE4Defaults) - include(MacroLibrary) - - add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) - include_directories(${KDE4_INCLUDES}) - - ### XCB - find_package(PkgConfig) - pkg_check_modules(XCB xcb x11-xcb) - add_feature_info("x11-xcb" XCB_FOUND "Required to pass style properties to native Windows on X11 Platform") - set_feature_info("x11-xcb" "Required to pass style properties to native Windows on X11 Platform" "http://xcb.freedesktop.org") - set(OXYGEN_HAVE_X11 ${XCB_FOUND}) - set(OXYGEN_HAVE_KWAYLAND FALSE) - - add_subdirectory(liboxygen) - add_subdirectory(kstyle) - -else() - - find_package(ECM 0.0.9 REQUIRED NO_MODULE) - set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) - - find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets DBus Quick) - find_package(KF5 REQUIRED COMPONENTS - I18n - Config - GuiAddons - WidgetsAddons - Service - Completion - FrameworkIntegration - WindowSystem) - - find_package(XCB COMPONENTS XCB) - set_package_properties(XCB PROPERTIES - DESCRIPTION "X protocol C-language Binding" - URL "http://xcb.freedesktop.org" - TYPE OPTIONAL - PURPOSE "Required to pass style properties to native Windows on X11 Platform" - ) - - find_package(KF5Wayland CONFIG) - set(OXYGEN_HAVE_KWAYLAND ${KF5Wayland_FOUND}) - - if(NOT APPLE) - +find_package(ECM 0.0.9 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) + +find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets DBus Quick) +find_package(KF5 REQUIRED COMPONENTS + I18n + Config + GuiAddons + WidgetsAddons + Service + Completion + FrameworkIntegration + WindowSystem) + +find_package(XCB COMPONENTS XCB) +set_package_properties(XCB PROPERTIES + DESCRIPTION "X protocol C-language Binding" + URL "http://xcb.freedesktop.org" + TYPE OPTIONAL + PURPOSE "Required to pass style properties to native Windows on X11 Platform" +) + +find_package(KF5Wayland CONFIG) +set(OXYGEN_HAVE_KWAYLAND ${KF5Wayland_FOUND}) + +if(NOT APPLE) set(OXYGEN_HAVE_X11 ${XCB_XCB_FOUND}) if (XCB_XCB_FOUND) - find_package(Qt5 REQUIRED CONFIG COMPONENTS X11Extras) + find_package(Qt5 REQUIRED CONFIG COMPONENTS X11Extras) endif() +endif() - endif() - - include(ECMInstallIcons) - include(KDEInstallDirs) - include(KDECMakeSettings) - include(KDECompilerSettings NO_POLICY_SCOPE) +include(ECMInstallIcons) +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) - add_subdirectory(liboxygen) - add_subdirectory(kstyle) - add_subdirectory(color-schemes) - add_subdirectory(cursors) - add_subdirectory(sounds) - add_subdirectory(kdecoration) +add_subdirectory(liboxygen) +add_subdirectory(kstyle) +add_subdirectory(color-schemes) +add_subdirectory(cursors) +add_subdirectory(sounds) +add_subdirectory(kdecoration) - install(DIRECTORY lookandfeel/ DESTINATION ${KDE_INSTALL_DATADIR}/plasma/look-and-feel/org.kde.oxygen - PATTERN "Messages.sh" EXCLUDE PATTERN "CMakeLists.txt" EXCLUDE) +install(DIRECTORY lookandfeel/ DESTINATION ${KDE_INSTALL_DATADIR}/plasma/look-and-feel/org.kde.oxygen + PATTERN "Messages.sh" EXCLUDE PATTERN "CMakeLists.txt" EXCLUDE) - # po/ dir added by packaging scripts - if(EXISTS ${CMAKE_SOURCE_DIR}/po AND IS_DIRECTORY ${CMAKE_SOURCE_DIR}/po) +# po/ dir added by packaging scripts +if(EXISTS ${CMAKE_SOURCE_DIR}/po AND IS_DIRECTORY ${CMAKE_SOURCE_DIR}/po) find_package(KF5I18n CONFIG REQUIRED) ki18n_install(po) - endif() - endif() feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/kstyle/CMakeLists.txt b/kstyle/CMakeLists.txt --- a/kstyle/CMakeLists.txt +++ b/kstyle/CMakeLists.txt @@ -66,42 +66,24 @@ oxygenwindowmanager.cpp ) -if(OXYGEN_USE_KDE4) +kconfig_add_kcfg_files(oxygen_PART_SRCS oxygenstyleconfigdata.kcfgc) +add_library(oxygen MODULE ${oxygen_PART_SRCS}) - kde4_add_kcfg_files(oxygen_PART_SRCS oxygenstyleconfigdata.kcfgc) - kde4_add_plugin(oxygen ${oxygen_PART_SRCS} kstylekde4compat.cpp) - target_link_libraries(oxygen ${KDE4_KDEUI_LIBS}) - target_link_libraries(oxygen oxygenstyle) +target_link_libraries(oxygen Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus Qt5::Quick) +target_link_libraries(oxygen KF5::GuiAddons KF5::Style KF5::WindowSystem) +target_link_libraries(oxygen oxygenstyle5) - if(OXYGEN_HAVE_X11) - target_link_libraries(oxygen ${X11_XCB_LIBRARIES}) - target_link_libraries(oxygen ${XCB_LIBRARIES}) - endif() - - install(TARGETS oxygen DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/styles/) - -else() - - kconfig_add_kcfg_files(oxygen_PART_SRCS oxygenstyleconfigdata.kcfgc) - add_library(oxygen MODULE ${oxygen_PART_SRCS}) - - target_link_libraries(oxygen Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus Qt5::Quick) - target_link_libraries(oxygen KF5::GuiAddons KF5::Style KF5::WindowSystem) - target_link_libraries(oxygen oxygenstyle5) - - if(OXYGEN_HAVE_X11) +if(OXYGEN_HAVE_X11) target_link_libraries(oxygen XCB::XCB) target_link_libraries(oxygen Qt5::X11Extras) - endif() +endif() - if(OXYGEN_HAVE_KWAYLAND) +if(OXYGEN_HAVE_KWAYLAND) target_link_libraries(oxygen KF5::WaylandClient) - endif() - - install(TARGETS oxygen DESTINATION ${QT_PLUGIN_INSTALL_DIR}/styles/) - endif() +install(TARGETS oxygen DESTINATION ${QT_PLUGIN_INSTALL_DIR}/styles/) + if(WIN32) # As stated in http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx M_PI only gets defined # when using MSVC if _USE_MATH_DEFINES is defined (this is needed for angle.cpp) diff --git a/kstyle/config/CMakeLists.txt b/kstyle/config/CMakeLists.txt --- a/kstyle/config/CMakeLists.txt +++ b/kstyle/config/CMakeLists.txt @@ -11,70 +11,47 @@ ui/oxygenstyleconfig.ui ) -if(OXYGEN_USE_KDE4) +set(kstyle_oxygen_config_PART_SRCS ${kstyle_oxygen_config_PART_SRCS} oxygenstyleconfigmodule.cpp) - kde4_add_kcfg_files(kstyle_oxygen_config_PART_SRCS ../oxygenstyleconfigdata.kcfgc) +kconfig_add_kcfg_files(kstyle_oxygen_config_PART_SRCS ../oxygenstyleconfigdata.kcfgc) - kde4_add_ui_files(kstyle_oxygen_config_PART_FORMS_HEADERS ${kstyle_oxygen_config_PART_FORMS}) - - kde4_add_plugin(kstyle_oxygen_config - ${kstyle_oxygen_config_PART_SRCS} - ${kstyle_oxygen_config_PART_FORMS_HEADERS} - ) - - target_link_libraries(kstyle_oxygen_config ${KDE4_KDEUI_LIBS}) - target_link_libraries(kstyle_oxygen_config oxygenstyleconfig) - install(TARGETS kstyle_oxygen_config DESTINATION ${PLUGIN_INSTALL_DIR}/) - -else() - - set(kstyle_oxygen_config_PART_SRCS ${kstyle_oxygen_config_PART_SRCS} oxygenstyleconfigmodule.cpp) - - kconfig_add_kcfg_files(kstyle_oxygen_config_PART_SRCS ../oxygenstyleconfigdata.kcfgc) - - set(kstyle_oxygen_config_PART_FORMS +set(kstyle_oxygen_config_PART_FORMS ui/oxygenfollowmouseanimationconfigbox.ui ui/oxygenstyleconfig.ui - ) - - ki18n_wrap_ui(kstyle_oxygen_config_PART_FORMS_HEADERS ${kstyle_oxygen_config_PART_FORMS}) +) - add_library(kstyle_oxygen_config MODULE - ${kstyle_oxygen_config_PART_SRCS} - ${kstyle_oxygen_config_PART_FORMS_HEADERS} - ) +ki18n_wrap_ui(kstyle_oxygen_config_PART_FORMS_HEADERS ${kstyle_oxygen_config_PART_FORMS}) - target_link_libraries(kstyle_oxygen_config Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus) - target_link_libraries(kstyle_oxygen_config KF5::Completion KF5::I18n) - target_link_libraries(kstyle_oxygen_config oxygenstyleconfig5) +add_library(kstyle_oxygen_config MODULE + ${kstyle_oxygen_config_PART_SRCS} + ${kstyle_oxygen_config_PART_FORMS_HEADERS} +) - install(TARGETS kstyle_oxygen_config DESTINATION ${QT_PLUGIN_INSTALL_DIR}) - install(FILES oxygenstyleconfig.desktop DESTINATION ${SERVICES_INSTALL_DIR}) +target_link_libraries(kstyle_oxygen_config Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus) +target_link_libraries(kstyle_oxygen_config KF5::Completion KF5::I18n) +target_link_libraries(kstyle_oxygen_config oxygenstyleconfig5) -endif() +install(TARGETS kstyle_oxygen_config DESTINATION ${QT_PLUGIN_INSTALL_DIR}) +install(FILES oxygenstyleconfig.desktop DESTINATION ${SERVICES_INSTALL_DIR}) ########### next target ############### -if(NOT OXYGEN_USE_KDE4) - - find_package(KF5KCMUtils CONFIG) - set_package_properties(KF5KCMUtils PROPERTIES - DESCRIPTION "KF5 KCM utils Framework" - URL "https://projects.kde.org/projects/frameworks/kcmutils" - TYPE OPTIONAL - PURPOSE "Required for oxygen-settings5 application to build") - - if( KF5KCMUtils_FOUND ) - - set(oxygen_settings_SOURCES main.cpp) - add_executable(oxygen-settings5 ${oxygen_settings_SOURCES} ) - target_link_libraries(oxygen-settings5 Qt5::Core Qt5::Gui Qt5::Widgets ) - target_link_libraries(oxygen-settings5 KF5::I18n KF5::KCMUtils) - - install(TARGETS oxygen-settings5 ${INSTALL_TARGETS_DEFAULT_ARGS}) - - # icon - ecm_install_icons(ICONS 256-apps-oxygen-settings.png - DESTINATION ${ICON_INSTALL_DIR} - THEME hicolor ) - endif() +find_package(KF5KCMUtils CONFIG) +set_package_properties(KF5KCMUtils PROPERTIES + DESCRIPTION "KF5 KCM utils Framework" + URL "https://projects.kde.org/projects/frameworks/kcmutils" + TYPE OPTIONAL + PURPOSE "Required for oxygen-settings5 application to build") + +if( KF5KCMUtils_FOUND ) + set(oxygen_settings_SOURCES main.cpp) + add_executable(oxygen-settings5 ${oxygen_settings_SOURCES} ) + target_link_libraries(oxygen-settings5 Qt5::Core Qt5::Gui Qt5::Widgets ) + target_link_libraries(oxygen-settings5 KF5::I18n KF5::KCMUtils) + + install(TARGETS oxygen-settings5 ${INSTALL_TARGETS_DEFAULT_ARGS}) + + # icon + ecm_install_icons(ICONS 256-apps-oxygen-settings.png + DESTINATION ${ICON_INSTALL_DIR} + THEME hicolor ) endif() diff --git a/kstyle/config/oxygenstyleconfig.cpp b/kstyle/config/oxygenstyleconfig.cpp --- a/kstyle/config/oxygenstyleconfig.cpp +++ b/kstyle/config/oxygenstyleconfig.cpp @@ -40,9 +40,6 @@ #include #include #include -#if !OXYGEN_USE_KDE4 -#include -#endif #define SCROLLBAR_DEFAULT_WIDTH 15 #define SCROLLBAR_MINIMUM_WIDTH 10 @@ -105,21 +102,8 @@ _animationConfigWidget->save(); - #if OXYGEN_USE_KDE4 - StyleConfigData::self()->writeConfig(); - #else StyleConfigData::self()->save(); - //update the KDE4 config to match - Kdelibs4Migration migration; - const QString kde4ConfigDirPath = migration.saveLocation("config"); - - QScopedPointer kde4Config(new KConfig); - StyleConfigData::self()->config()->copyTo(kde4ConfigDirPath+"/oxygenrc", kde4Config.data()); - kde4Config->sync(); - - #endif - // emit dbus signal QDBusMessage message( QDBusMessage::createSignal( QStringLiteral( "/OxygenStyle" ), QStringLiteral( "org.kde.Oxygen.Style" ), QStringLiteral( "reparseConfiguration" ) ) ); QDBusConnection::sessionBus().send(message); @@ -137,11 +121,7 @@ void StyleConfig::reset( void ) { // reparse configuration - #if OXYGEN_USE_KDE4 - StyleConfigData::self()->readConfig(); - #else StyleConfigData::self()->load(); - #endif load(); } diff --git a/kstyle/demo/CMakeLists.txt b/kstyle/demo/CMakeLists.txt --- a/kstyle/demo/CMakeLists.txt +++ b/kstyle/demo/CMakeLists.txt @@ -29,42 +29,24 @@ ui/oxygentabdemowidget.ui ) -if(OXYGEN_USE_KDE4) - - kde4_add_ui_files(oxygen_demo_FORMS_HEADERS ${oxygen_demo_FORMS}) - - kde4_add_executable(oxygen-demo - ${oxygen_demo_SOURCES} - ${oxygen_demo_FORMS_HEADERS} - ) - - target_link_libraries(oxygen-demo ${KDE4_KDEUI_LIBS}) - - ########### install files ############### - install(TARGETS oxygen-demo ${INSTALL_TARGETS_DEFAULT_ARGS}) - -else() - - find_package(KF5ConfigWidgets CONFIG) - if(KF5ConfigWidgets_FOUND) +find_package(KF5ConfigWidgets CONFIG) +if(KF5ConfigWidgets_FOUND) set(oxygen_demo_SOURCES ${oxygen_demo_SOURCES} oxygenschemechooser.cpp oxygenstylechooser.cpp) add_definitions(-DHAVE_SCHEME_CHOOSER) - endif() +endif() - ki18n_wrap_ui(oxygen_demo_FORMS_HEADERS ${oxygen_demo_FORMS}) +ki18n_wrap_ui(oxygen_demo_FORMS_HEADERS ${oxygen_demo_FORMS}) - add_executable(oxygen-demo5 - ${oxygen_demo_SOURCES} - ${oxygen_demo_FORMS_HEADERS} - ) +add_executable(oxygen-demo5 + ${oxygen_demo_SOURCES} + ${oxygen_demo_FORMS_HEADERS} +) - target_link_libraries(oxygen-demo5 Qt5::Core Qt5::Gui Qt5::Widgets) - target_link_libraries(oxygen-demo5 KF5::Completion KF5::ConfigGui KF5::WidgetsAddons KF5::I18n) - if(KF5ConfigWidgets_FOUND) +target_link_libraries(oxygen-demo5 Qt5::Core Qt5::Gui Qt5::Widgets) +target_link_libraries(oxygen-demo5 KF5::Completion KF5::ConfigGui KF5::WidgetsAddons KF5::I18n) +if(KF5ConfigWidgets_FOUND) target_link_libraries(oxygen-demo5 KF5::ConfigWidgets) - endif() - - ########### install files ############### - install(TARGETS oxygen-demo5 ${INSTALL_TARGETS_DEFAULT_ARGS}) - endif() + +########### install files ############### +install(TARGETS oxygen-demo5 ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/kstyle/demo/main.cpp b/kstyle/demo/main.cpp --- a/kstyle/demo/main.cpp +++ b/kstyle/demo/main.cpp @@ -29,12 +29,8 @@ #include "config-liboxygen.h" #include - -#if QT_VERSION >= 0x050200 #include #include -#endif - #include #include @@ -46,14 +42,12 @@ { QApplication app( argc, argv ); - #if QT_VERSION >= 0x050200 QCommandLineParser commandLine; QCommandLineOption enableHighDpi( "highdpi", "Enable High DPI pixmaps" ); commandLine.addOption( enableHighDpi ); commandLine.process( app ); app.setAttribute( Qt::AA_UseHighDpiPixmaps, commandLine.isSet( enableHighDpi ) ); - #endif app.setApplicationName( i18n( "Oxygen Demo" ) ); app.setWindowIcon( QIcon::fromTheme( QStringLiteral( "oxygen" ) ) ); @@ -68,9 +62,7 @@ //__________________________________________ int main(int argc, char *argv[]) { - #if !OXYGEN_USE_KDE4 KLocalizedString::setApplicationDomain("oxygen_style_demo"); - #endif return Oxygen::run( argc, argv ); diff --git a/kstyle/demo/oxygendemodialog.cpp b/kstyle/demo/oxygendemodialog.cpp --- a/kstyle/demo/oxygendemodialog.cpp +++ b/kstyle/demo/oxygendemodialog.cpp @@ -55,27 +55,16 @@ setWindowTitle( i18n( "Oxygen Demo" ) ); - #if OXYGEN_USE_KDE4 - // install Quit shortcut - connect( new QShortcut( KStandardShortcut::quit().primary(), this ), SIGNAL(activated()), SLOT(close()) ); - connect( new QShortcut( KStandardShortcut::quit().alternate(), this ), SIGNAL(activated()), SLOT(close()) ); - #else // install Quit shortcut foreach( const QKeySequence& sequence, KStandardShortcut::quit() ) { connect( new QShortcut( sequence, this ), SIGNAL(activated()), SLOT(close()) ); } - #endif - #if OXYGEN_USE_KDE4 - setButtons( KDialog::Ok ); - auto buttonBox = findChild(); - #else // button box auto buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok, Qt::Horizontal ); setButtonBox( buttonBox ); // connection connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL(clicked()), SLOT(close()) ); - #endif // customize button box _enableCheckBox = new QCheckBox( i18n( "Enabled" ) ); @@ -102,11 +91,7 @@ auto setPageIcon = []( KPageWidgetItem* page, const QString& iconName ) { - #if OXYGEN_USE_KDE4 - page->setIcon( KIcon( iconName ) ); - #else page->setIcon( QIcon::fromTheme( iconName ) ); - #endif }; KPageWidgetItem* page = nullptr; diff --git a/kstyle/demo/oxygenframedemowidget.cpp b/kstyle/demo/oxygenframedemowidget.cpp --- a/kstyle/demo/oxygenframedemowidget.cpp +++ b/kstyle/demo/oxygenframedemowidget.cpp @@ -31,9 +31,7 @@ #include #include -#if !OXYGEN_USE_KDE4 #include -#endif namespace Oxygen { @@ -61,7 +59,7 @@ connect( ui.flatGroupBoxCheckBox, SIGNAL(toggled(bool)), SLOT(toggleFlatGroupBox(bool)) ); addMessages(); -#if !OXYGEN_USE_KDE4 && KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) +#if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) qApp->installEventFilter(this); #endif } @@ -102,7 +100,7 @@ bool FrameDemoWidget::eventFilter( QObject *obj, QEvent *event ) { -#if !OXYGEN_USE_KDE4 && KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) +#if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) if (event->type() == QEvent::DynamicPropertyChange && obj == qApp) { QDynamicPropertyChangeEvent *e = dynamic_cast(event); if (e->propertyName() == QByteArrayLiteral("KDE_COLOR_SCHEME_PATH")) { diff --git a/kstyle/kstylekde4compat.h b/kstyle/kstylekde4compat.h deleted file mode 100644 --- a/kstyle/kstylekde4compat.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************* - * Copyright (C) 2015 by David Edmundson * - * * - * 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 . * - *************************************************************************/ - -/** - * This class copies the features of KF5's KStyle for use in KDE4 only - * - * kdelibs4 also has a KStyle class but this isn't a 1-1 mapping and - * provides a lot of features we do not want - */ - -#ifndef KSTYLE_KDE4_COMPAT_H -#define KSTYLE_KDE4_COMPAT_H - -#include -#include - -class KStyleKDE4Compat : public QCommonStyle -{ - Q_OBJECT - - public: - - //* constructor - KStyleKDE4Compat(); - - //* style hint - int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *returnData) const override; - - protected: - - StyleHint newStyleHint(const QString &element); - ControlElement newControlElement(const QString &element); - SubElement newSubElement(const QString &element); - - private: - - QHash styleElements; - int hintCounter = 0; - int controlCounter = 0; - int subElementCounter = 0; - -}; - -#endif diff --git a/kstyle/kstylekde4compat.cpp b/kstyle/kstylekde4compat.cpp deleted file mode 100644 --- a/kstyle/kstylekde4compat.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************* - * Copyright (C) 2015 by David Edmundson * - * * - * 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 . * - *************************************************************************/ - -#include "kstylekde4compat.h" - -#include -#include -#include - -static const QStyle::StyleHint SH_KCustomStyleElement = (QStyle::StyleHint)0xff000001; -static const int X_KdeBase = 0xff000000; - -//_____________________________________________________________________ -KStyleKDE4Compat::KStyleKDE4Compat() -{ - controlCounter = subElementCounter = X_KdeBase; - hintCounter = X_KdeBase + 1; //sic! X_KdeBase is covered by SH_KCustomStyleElement -} - -//_____________________________________________________________________ -static inline int newStyleElement(const QString &element, const char *check, int &counter, QHash *elements) -{ - if (!element.contains(check)) return 0; - - int id = elements->value(element, 0); - if (!id) - { - ++counter; - id = counter; - elements->insert(element, id); - } - return id; -} - -//_____________________________________________________________________ -QStyle::StyleHint KStyleKDE4Compat::newStyleHint(const QString &element) -{ return (StyleHint)newStyleElement(element, "SH_", hintCounter, &styleElements); } - -//_____________________________________________________________________ -QStyle::ControlElement KStyleKDE4Compat::newControlElement(const QString &element) -{ return (ControlElement)newStyleElement(element, "CE_", controlCounter, &styleElements); } - -//_____________________________________________________________________ -QStyle::SubElement KStyleKDE4Compat::newSubElement(const QString &element) -{ return (SubElement)newStyleElement(element, "SE_", subElementCounter, &styleElements); } - -//_____________________________________________________________________ -int KStyleKDE4Compat::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const -{ - - if( hint == SH_KCustomStyleElement && widget ) - { return styleElements.value(widget->objectName(), 0); } - - switch (hint) { - case SH_ItemView_ActivateItemOnSingleClick: { - KConfigGroup g(KSharedConfig::openConfig(), "KDE"); - return g.readEntry("SingleClick", true); - } - - case SH_DialogButtonBox_ButtonsHaveIcons: { - // was KGlobalSettings::showIconsOnPushButtons() : - KConfigGroup g(KSharedConfig::openConfig(), "KDE"); - return g.readEntry("ShowIconsOnPushButtons", true); - } - - case SH_ItemView_ArrowKeysNavigateIntoChildren: - return true; - - case SH_ToolButtonStyle: { - KConfigGroup g(KSharedConfig::openConfig(), "Toolbar style"); - - bool useOthertoolbars = false; - const QWidget *parent = widget ? widget->parentWidget() : nullptr; - - //If the widget parent is a QToolBar and the magic property is set - if (parent && qobject_cast< const QToolBar * >(parent)) { - if (parent->property("otherToolbar").isValid()) { - useOthertoolbars = true; - } - } - - QString buttonStyle; - if (useOthertoolbars) { - buttonStyle = g.readEntry("ToolButtonStyleOtherToolbars", "NoText").toLower(); - } else { - buttonStyle = g.readEntry("ToolButtonStyle", "TextBesideIcon").toLower(); - } - - return buttonStyle == QLatin1String("textbesideicon") ? Qt::ToolButtonTextBesideIcon - : buttonStyle == QLatin1String("icontextright") ? Qt::ToolButtonTextBesideIcon - : buttonStyle == QLatin1String("textundericon") ? Qt::ToolButtonTextUnderIcon - : buttonStyle == QLatin1String("icontextbottom") ? Qt::ToolButtonTextUnderIcon - : buttonStyle == QLatin1String("textonly") ? Qt::ToolButtonTextOnly - : Qt::ToolButtonIconOnly; - } - - default: - break; - }; - - return QCommonStyle::styleHint(hint, option, widget, returnData); -} diff --git a/kstyle/oxygen.h b/kstyle/oxygen.h --- a/kstyle/oxygen.h +++ b/kstyle/oxygen.h @@ -31,22 +31,12 @@ //*@name convenience typedef //@{ - #if QT_VERSION >= 0x050000 //* scoped pointer convenience typedef template using WeakPointer = QPointer; - #else - //* scoped pointer convenience typedef - template using WeakPointer = QWeakPointer; - #endif //* scoped pointer convenience typedef template using ScopedPointer = QScopedPointer; - //* disable QStringLiteral for older Qt version - #if QT_VERSION < 0x050000 - using QStringLiteral = QString; - #endif - //@} //* metrics diff --git a/kstyle/oxygenmnemonics.cpp b/kstyle/oxygenmnemonics.cpp --- a/kstyle/oxygenmnemonics.cpp +++ b/kstyle/oxygenmnemonics.cpp @@ -74,11 +74,9 @@ { setEnabled( false ); } break; - #if QT_VERSION >= 0x050000 case QEvent::ApplicationStateChange: { setEnabled( false ); } break; - #endif default: break; diff --git a/kstyle/oxygenshadowhelper.cpp b/kstyle/oxygenshadowhelper.cpp --- a/kstyle/oxygenshadowhelper.cpp +++ b/kstyle/oxygenshadowhelper.cpp @@ -495,11 +495,7 @@ { // const qreal devicePixelRatio( _helper.devicePixelRatio( isDockWidget ? // _dockTiles.pixmap( 0 ):_tiles.pixmap( 0 ) ) ); - #if QT_VERSION >= 0x050300 const qreal devicePixelRatio( qApp->devicePixelRatio() ); - #else - const qreal devicePixelRatio( 1.0 ); - #endif // add padding /* diff --git a/kstyle/oxygenstyle.h b/kstyle/oxygenstyle.h --- a/kstyle/oxygenstyle.h +++ b/kstyle/oxygenstyle.h @@ -51,13 +51,10 @@ #include "oxygentileset.h" #include "config-liboxygen.h" -#if OXYGEN_USE_KDE4 -#include "kstylekde4compat.h" -#else #include -#endif #include +#include #include #include #include @@ -69,10 +66,6 @@ #include -#if QT_VERSION >= 0x050000 -#include -#endif - namespace OxygenPrivate { class TabBarData; @@ -94,16 +87,9 @@ class WidgetExplorer; class BlurHelper; - //* convenience typedef for base class - #if OXYGEN_USE_KDE4 - using ParentStyleClass = KStyleKDE4Compat; - #else - using ParentStyleClass = KStyle; - #endif - //* base class for oxygen style /** it is responsible to draw all the primitives to be displayed on screen, on request from Qt paint engine */ - class Style: public ParentStyleClass + class Style: public KStyle { Q_OBJECT @@ -119,8 +105,8 @@ ~Style( void ) override; //* needed to avoid warnings at compilation time - using ParentStyleClass::polish; - using ParentStyleClass::unpolish; + using KStyle::polish; + using KStyle::unpolish; //* widget polishing void polish( QWidget* ) override; @@ -167,10 +153,7 @@ bool eventFilterComboBoxContainer( QWidget*, QEvent* ); bool eventFilterDockWidget( QDockWidget*, QEvent* ); bool eventFilterMdiSubWindow( QMdiSubWindow*, QEvent* ); - - #if QT_VERSION >= 0x050000 bool eventFilterCommandLinkButton( QCommandLinkButton*, QEvent* ); - #endif bool eventFilterScrollBar( QWidget*, QEvent* ); bool eventFilterTabBar( QWidget*, QEvent* ); @@ -193,13 +176,8 @@ protected: - #if OXYGEN_USE_KDE4 - //* standard icons - QIcon standardIcon( StandardPixmap pixmap, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const - #else //* standard icons QIcon standardIcon( StandardPixmap pixmap, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override - #endif { return standardIconImplementation( pixmap, option, widget ); } private Q_SLOTS: @@ -590,9 +568,9 @@ } //* right to left alignment handling - using ParentStyleClass::visualRect; + using KStyle::visualRect; QRect visualRect(const QStyleOption* opt, const QRect& subRect) const - { return ParentStyleClass::visualRect(opt->direction, opt->rect, subRect); } + { return KStyle::visualRect(opt->direction, opt->rect, subRect); } //* centering QRect centerRect(const QRect &rect, const QSize& size ) const diff --git a/kstyle/oxygenstyle.cpp b/kstyle/oxygenstyle.cpp --- a/kstyle/oxygenstyle.cpp +++ b/kstyle/oxygenstyle.cpp @@ -230,11 +230,7 @@ //______________________________________________________________ Style::Style( void ): - #if OXYGEN_USE_KDE4 - _helper( new StyleHelper( "oxygen" ) ) - #else _helper( new StyleHelper( StyleConfigData::self()->sharedConfig() ) ) - #endif ,_shadowHelper( new ShadowHelper( this, *_helper ) ) ,_animations( new Animations( this ) ) ,_transitions( new Transitions( this ) ) @@ -481,11 +477,10 @@ widget->setWindowFlags( widget->windowFlags() | Qt::FramelessWindowHint ); #endif - #if QT_VERSION >= 0x050000 } else if( qobject_cast( widget ) ) { addEventFilter( widget ); - #endif + } else if( QComboBox *comboBox = qobject_cast( widget ) ) { if( !hasParent( widget, "QWebView" ) ) @@ -512,7 +507,7 @@ } // base class polishing - ParentStyleClass::polish( widget ); + KStyle::polish( widget ); } @@ -622,7 +617,7 @@ } else if( widget->inherits( "QComboBoxPrivateContainer" ) ) widget->removeEventFilter( this ); - ParentStyleClass::unpolish( widget ); + KStyle::unpolish( widget ); } @@ -636,7 +631,6 @@ case PM_DefaultFrameWidth: if( qobject_cast( widget ) ) return Metrics::LineEdit_FrameWidth; - #if QT_VERSION >= 0x050000 else if( isQtQuickControl( option, widget ) ) { const QString &elementType = option->styleObject->property( "elementType" ).toString(); @@ -652,7 +646,6 @@ } } - #endif // fallback return Metrics::Frame_FrameWidth; @@ -778,7 +771,7 @@ } else return -1; // fallback - default: return ParentStyleClass::pixelMetric( metric, option, widget ); + default: return KStyle::pixelMetric( metric, option, widget ); } @@ -852,10 +845,8 @@ case SH_Menu_SloppySubMenus: return true; case SH_ToolBox_SelectedPageTitleBold: return false; - #if QT_VERSION >= 0x050000 case SH_Widget_Animate: return StyleConfigData::animationsEnabled(); case SH_Menu_SupportsSections: return true; - #endif case SH_TitleBar_NoBorder: return false; case SH_GroupBox_TextLabelVerticalAlignment: return Qt::AlignVCenter; @@ -871,7 +862,7 @@ case SH_MessageBox_CenterButtons: return false; - default: return ParentStyleClass::styleHint( hint, option, widget, returnData ); + default: return KStyle::styleHint( hint, option, widget, returnData ); } } @@ -901,7 +892,7 @@ case SE_TabWidgetRightCorner: return tabWidgetCornerRect( SE_TabWidgetRightCorner, option, widget ); case SE_ToolBoxTabContents: return toolBoxTabContentsRect( option, widget ); - default: return ParentStyleClass::subElementRect( element, option, widget ); + default: return KStyle::subElementRect( element, option, widget ); } @@ -922,7 +913,7 @@ case CC_Slider: return sliderSubControlRect( option, subControl, widget ); // fallback - default: return ParentStyleClass::subControlRect( element, option, subControl, widget ); + default: return KStyle::subControlRect( element, option, subControl, widget ); } @@ -950,7 +941,7 @@ case CT_HeaderSection: return headerSectionSizeFromContents( option, size, widget ); case CT_ItemViewItem: return itemViewItemSizeFromContents( option, size, widget ); - default: return ParentStyleClass::sizeFromContents( element, option, size, widget ); + default: return KStyle::sizeFromContents( element, option, size, widget ); } } @@ -998,7 +989,7 @@ } // fallback - default: return ParentStyleClass::hitTestComplexControl( control, option, point, widget ); + default: return KStyle::hitTestComplexControl( control, option, point, widget ); } @@ -1053,7 +1044,7 @@ // call function if implemented if( !( fcn && ( this->*fcn )( option, painter, widget ) ) ) - { ParentStyleClass::drawPrimitive( element, option, painter, widget ); } + { KStyle::drawPrimitive( element, option, painter, widget ); } painter->restore(); @@ -1110,7 +1101,7 @@ // call function if implemented if( !( fcn && ( this->*fcn )( option, painter, widget ) ) ) - { ParentStyleClass::drawControl( element, option, painter, widget ); } + { KStyle::drawControl( element, option, painter, widget ); } painter->restore(); @@ -1140,7 +1131,7 @@ // call function if implemented if( !( fcn && ( this->*fcn )( option, painter, widget ) ) ) - { ParentStyleClass::drawComplexControl( element, option, painter, widget ); } + { KStyle::drawComplexControl( element, option, painter, widget ); } painter->restore(); @@ -1177,14 +1168,14 @@ { const QPalette copy( _helper->disabledPalette( palette, _animations->widgetEnableStateEngine().opacity( widget, AnimationEnable ) ) ); - return ParentStyleClass::drawItemText( painter, rect, flags, copy, enabled, text, textRole ); + return KStyle::drawItemText( painter, rect, flags, copy, enabled, text, textRole ); } } // fallback - return ParentStyleClass::drawItemText( painter, rect, flags, palette, enabled, text, textRole ); + return KStyle::drawItemText( painter, rect, flags, palette, enabled, text, textRole ); } @@ -1199,16 +1190,14 @@ else if( QToolBox* toolBox = qobject_cast( object ) ) { return eventFilterToolBox( toolBox, event ); } else if( QMdiSubWindow* subWindow = qobject_cast( object ) ) { return eventFilterMdiSubWindow( subWindow, event ); } else if( QScrollBar* scrollBar = qobject_cast( object ) ) { return eventFilterScrollBar( scrollBar, event ); } - #if QT_VERSION >= 0x050000 else if( QCommandLinkButton* commandLinkButton = qobject_cast( object ) ) { return eventFilterCommandLinkButton( commandLinkButton, event ); } - #endif // cast to QWidget QWidget *widget = static_cast( object ); if( widget->inherits( "QComboBoxPrivateContainer" ) ) { return eventFilterComboBoxContainer( widget, event ); } // fallback - return ParentStyleClass::eventFilter( object, event ); + return KStyle::eventFilter( object, event ); } @@ -1343,7 +1332,6 @@ } //____________________________________________________________________________ - #if QT_VERSION >= 0x050000 bool Style::eventFilterCommandLinkButton( QCommandLinkButton* button, QEvent* event ) { @@ -1428,7 +1416,6 @@ return false; } - #endif //_________________________________________________________ bool Style::eventFilterScrollBar( QWidget* widget, QEvent* event ) @@ -1571,11 +1558,7 @@ { // reload - #if OXYGEN_USE_KDE4 - StyleConfigData::self()->readConfig(); - #else StyleConfigData::self()->load(); - #endif _shadowHelper->reparseCacheConfig(); @@ -1757,11 +1740,7 @@ default: // do not cache parent style icon, since it may change at runtime - #if QT_VERSION >= 0x050000 - return ParentStyleClass::standardIcon( standardPixmap, option, widget ); - #else - return ParentStyleClass::standardIconImplementation( standardPixmap, option, widget ); - #endif + return KStyle::standardIcon( standardPixmap, option, widget ); } } @@ -1878,11 +1857,7 @@ { const QRect rect( option->rect ); - #if OXYGEN_USE_KDE4 - const auto progressBarOption2( qstyleoption_cast( option ) ); - #else const auto progressBarOption2( qstyleoption_cast( option ) ); - #endif const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); if( horizontal ) return insideMargin( rect, 1, 0 ); else return insideMargin( rect, 0, 1 ); @@ -1897,11 +1872,7 @@ if( !progressBarOption ) return QRect(); // get orientation - #if OXYGEN_USE_KDE4 - const auto progressBarOption2( qstyleoption_cast( option ) ); - #else const auto progressBarOption2( qstyleoption_cast( option ) ); - #endif const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); // check inverted appearance @@ -2011,11 +1982,7 @@ { // cast option and check - #if OXYGEN_USE_KDE4 - const auto tabOptionV3( qstyleoption_cast( option ) ); - #else const auto tabOptionV3( qstyleoption_cast( option ) ); - #endif if( !tabOptionV3 || tabOptionV3->leftButtonSize.isEmpty() ) return QRect(); const QRect rect( option->rect ); @@ -2059,11 +2026,7 @@ { // cast option and check - #if OXYGEN_USE_KDE4 - const auto tabOptionV3( qstyleoption_cast( option ) ); - #else const auto tabOptionV3( qstyleoption_cast( option ) ); - #endif if( !tabOptionV3 || tabOptionV3->rightButtonSize.isEmpty() ) return QRect(); const QRect rect( option->rect ); @@ -2108,7 +2071,7 @@ // cast option and check const QStyleOptionTabWidgetFrame* tabOption = qstyleoption_cast( option ); - if( !tabOption ) return ParentStyleClass::subElementRect( SE_TabWidgetTabBar, option, widget ); + if( !tabOption ) return KStyle::subElementRect( SE_TabWidgetTabBar, option, widget ); // do nothing if tabbar is hidden const QSize tabBarSize( tabOption->tabBarSize ); @@ -2447,16 +2410,16 @@ } - return ParentStyleClass::subControlRect( CC_GroupBox, option, subControl, widget ); + return KStyle::subControlRect( CC_GroupBox, option, subControl, widget ); } //___________________________________________________________________________________________________________________ QRect Style::toolButtonSubControlRect( const QStyleOptionComplex* option, SubControl subControl, const QWidget* widget ) const { // cast option and check const QStyleOptionToolButton* toolButtonOption = qstyleoption_cast( option ); - if( !toolButtonOption ) return ParentStyleClass::subControlRect( CC_ToolButton, option, subControl, widget ); + if( !toolButtonOption ) return KStyle::subControlRect( CC_ToolButton, option, subControl, widget ); const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup ); const bool hasInlineIndicator( @@ -2509,7 +2472,7 @@ { // cast option and check const QStyleOptionComboBox *comboBoxOption( qstyleoption_cast( option ) ); - if( !comboBoxOption ) return ParentStyleClass::subControlRect( CC_ComboBox, option, subControl, widget ); + if( !comboBoxOption ) return KStyle::subControlRect( CC_ComboBox, option, subControl, widget ); const bool editable( comboBoxOption->editable ); const bool flat( editable && !comboBoxOption->frame ); @@ -2561,7 +2524,7 @@ } - return ParentStyleClass::subControlRect( CC_ComboBox, option, subControl, widget ); + return KStyle::subControlRect( CC_ComboBox, option, subControl, widget ); } @@ -2571,7 +2534,7 @@ // cast option and check const QStyleOptionSpinBox *spinBoxOption( qstyleoption_cast( option ) ); - if( !spinBoxOption ) return ParentStyleClass::subControlRect( CC_SpinBox, option, subControl, widget ); + if( !spinBoxOption ) return KStyle::subControlRect( CC_SpinBox, option, subControl, widget ); const bool flat( !spinBoxOption->frame ); // copy rect @@ -2626,7 +2589,7 @@ } - return ParentStyleClass::subControlRect( CC_SpinBox, option, subControl, widget ); + return KStyle::subControlRect( CC_SpinBox, option, subControl, widget ); } @@ -2665,7 +2628,7 @@ { // cast option and check const QStyleOptionSlider* sliderOption( qstyleoption_cast( option ) ); - if( !sliderOption ) return ParentStyleClass::subControlRect( CC_ScrollBar, option, subControl, widget ); + if( !sliderOption ) return KStyle::subControlRect( CC_ScrollBar, option, subControl, widget ); // get relevant state const State& state( option->state ); @@ -2752,7 +2715,7 @@ } - default: return ParentStyleClass::subControlRect( CC_ScrollBar, option, subControl, widget );; + default: return KStyle::subControlRect( CC_ScrollBar, option, subControl, widget );; } } @@ -2763,7 +2726,7 @@ // cast option and check const QStyleOptionSlider* sliderOption( qstyleoption_cast( option ) ); - if( !sliderOption ) return ParentStyleClass::subControlRect( CC_Slider, option, subControl, widget ); + if( !sliderOption ) return KStyle::subControlRect( CC_Slider, option, subControl, widget ); switch( subControl ) { @@ -2774,7 +2737,7 @@ const bool horizontal( sliderOption->orientation == Qt::Horizontal ); // get base class rect - QRect grooveRect( ParentStyleClass::subControlRect( CC_Slider, option, subControl, widget ) ); + QRect grooveRect( KStyle::subControlRect( CC_Slider, option, subControl, widget ) ); grooveRect = insideMargin( grooveRect, pixelMetric( PM_DefaultFrameWidth, option, widget ) ); // centering @@ -2798,13 +2761,13 @@ case SC_SliderHandle: { - QRect handleRect( ParentStyleClass::subControlRect( CC_Slider, option, subControl, widget ) ); + QRect handleRect( KStyle::subControlRect( CC_Slider, option, subControl, widget ) ); handleRect = centerRect( handleRect, Metrics::Slider_ControlThickness, Metrics::Slider_ControlThickness ); return handleRect; } - default: return ParentStyleClass::subControlRect( CC_Slider, option, subControl, widget ); + default: return KStyle::subControlRect( CC_Slider, option, subControl, widget ); } } @@ -3114,11 +3077,7 @@ { const auto tabOption( qstyleoption_cast( option ) ); - #if OXYGEN_USE_KDE4 - const auto tabOptionV3( qstyleoption_cast( option ) ); - #else const auto tabOptionV3( qstyleoption_cast( option ) ); - #endif const bool hasText( tabOption && !tabOption->text.isEmpty() ); const bool hasIcon( tabOption && !tabOption->icon.isNull() ); const bool hasLeftButton( tabOptionV3 && !tabOptionV3->leftButtonSize.isEmpty() ); @@ -3202,7 +3161,7 @@ QSize Style::itemViewItemSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* widget ) const { // call base class - QSize size( ParentStyleClass::sizeFromContents( CT_ItemViewItem, option, contentsSize, widget ) ); + QSize size( KStyle::sizeFromContents( CT_ItemViewItem, option, contentsSize, widget ) ); // add margins return expandSize( size, Metrics::ItemView_ItemMarginWidth ); @@ -3221,12 +3180,8 @@ const State& state( option->state ); const bool enabled( state & State_Enabled ); - #if QT_VERSION >= 0x050000 const bool isInputWidget( ( widget && widget->testAttribute( Qt::WA_Hover ) ) || ( isQtQuickControl( option, widget ) && option->styleObject->property( "elementType" ).toString() == QStringLiteral( "edit") ) ); - #else - const bool isInputWidget( widget && widget->testAttribute( Qt::WA_Hover ) ); - #endif const bool mouseOver( enabled && isInputWidget && ( state & State_MouseOver ) ); const bool hasFocus( enabled && isInputWidget && ( state & State_HasFocus ) ); @@ -3377,12 +3332,7 @@ if( !frameOption ) return true; // no frame for flat groupboxes - #if OXYGEN_USE_KDE4 - QStyleOptionFrameV2 frameOption2( *frameOption ); - if( frameOption2.features & QStyleOptionFrameV2::Flat ) return true; - #else if( frameOption->features & QStyleOptionFrame::Flat ) return true; - #endif // normal frame const QPalette& palette( option->palette ); const QRect& rect( option->rect ); @@ -4184,11 +4134,7 @@ { // cast option and check - #if OXYGEN_USE_KDE4 - const auto viewItemOption = qstyleoption_cast( option ); - #else const auto viewItemOption = qstyleoption_cast( option ); - #endif if( !viewItemOption ) return false; @@ -4251,19 +4197,6 @@ if( viewItemOption ) { - #if OXYGEN_USE_KDE4 - roundedLeft = ( viewItemOption->viewItemPosition == QStyleOptionViewItemV4::Beginning ); - roundedRight = ( viewItemOption->viewItemPosition == QStyleOptionViewItemV4::End ); - - if( viewItemOption->viewItemPosition == QStyleOptionViewItemV4::OnlyOne || - viewItemOption->viewItemPosition == QStyleOptionViewItemV4::Invalid || - ( view && view->selectionBehavior() != QAbstractItemView::SelectRows ) ) - { - roundedLeft = true; - roundedRight = true; - } - - #else roundedLeft = ( viewItemOption->viewItemPosition == QStyleOptionViewItem::Beginning ); roundedRight = ( viewItemOption->viewItemPosition == QStyleOptionViewItem::End ); @@ -4275,8 +4208,6 @@ roundedRight = true; } - #endif - } const bool reverseLayout( option->direction == Qt::RightToLeft ); @@ -4512,11 +4443,7 @@ // in fact with current version of Qt ( 4.6.0 ) the cast fails and document mode is always false // this will hopefully be fixed in later versions - #if OXYGEN_USE_KDE4 - const auto tabOptionV3( qstyleoption_cast( option ) ); - #else const auto tabOptionV3( qstyleoption_cast( option ) ); - #endif bool documentMode( tabOptionV3 ? tabOptionV3->documentMode : false ); const QTabWidget *tabWidget = ( widget && widget->parentWidget() ) ? qobject_cast( widget->parentWidget() ) : nullptr; @@ -5363,30 +5290,20 @@ const QStyleOptionProgressBar* progressBarOption( qstyleoption_cast( option ) ); if( !progressBarOption ) return true; - #if OXYGEN_USE_KDE4 - QStyleOptionProgressBarV2 progressBarOption2 = *progressBarOption; - #else QStyleOptionProgressBar progressBarOption2 = *progressBarOption; - #endif progressBarOption2.rect = subElementRect( SE_ProgressBarGroove, progressBarOption, widget ); drawControl( CE_ProgressBarGroove, &progressBarOption2, painter, widget ); // enable busy animations - #if QT_VERSION >= 0x050000 const QObject* styleObject( widget ? widget:progressBarOption->styleObject ); - #else - const QObject* styleObject( widget ); - #endif if( styleObject && _animations->busyIndicatorEngine().enabled() ) { - #if QT_VERSION >= 0x050000 // register QML object if defined if( !widget && progressBarOption->styleObject ) { _animations->busyIndicatorEngine().registerWidget( progressBarOption->styleObject ); } - #endif _animations->busyIndicatorEngine().setAnimated( styleObject, progressBarOption->maximum == 0 && progressBarOption->minimum == 0 ); @@ -5421,12 +5338,7 @@ if( !progressBarOption ) return true; // get orientation - #if OXYGEN_USE_KDE4 - const auto progressBarOption2 = qstyleoption_cast( option ); - #else const auto progressBarOption2 = qstyleoption_cast( option ); - #endif - const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); // copy rect and palette @@ -5450,11 +5362,7 @@ bool Style::drawProgressBarGrooveControl( const QStyleOption* option, QPainter* painter, const QWidget* ) const { - #if OXYGEN_USE_KDE4 - const auto progressBarOption = qstyleoption_cast( option ); - #else const auto progressBarOption = qstyleoption_cast( option ); - #endif const Qt::Orientation orientation( progressBarOption? progressBarOption->orientation : Qt::Horizontal ); renderScrollBarHole( painter, option->rect, option->palette.color( QPalette::Window ), orientation ); @@ -5479,12 +5387,7 @@ const bool reverseLayout = ( option->direction == Qt::RightToLeft ); // get orientation - #if OXYGEN_USE_KDE4 - const auto progressBarOption2 = qstyleoption_cast( option ); - #else const auto progressBarOption2 = qstyleoption_cast( option ); - #endif - const bool horizontal = !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal; // check inverted appearance @@ -5718,11 +5621,7 @@ { // cast option and check - #if OXYGEN_USE_KDE4 - const auto frameOption = qstyleoption_cast( option ); - #else const auto frameOption = qstyleoption_cast( option ); - #endif if( !frameOption ) return false; switch( frameOption->frameShape ) @@ -5865,7 +5764,7 @@ { // call parent style method - ParentStyleClass::drawControl( CE_TabBarTabLabel, option, painter, widget ); + KStyle::drawControl( CE_TabBarTabLabel, option, painter, widget ); // store rect and palette const QRect& rect( option->rect ); @@ -5985,11 +5884,7 @@ bool isLast( position == QStyleOptionTab::OnlyOneTab || position == QStyleOptionTab::End ); // document mode - #if OXYGEN_USE_KDE4 - const auto tabOptionV3 = qstyleoption_cast( option ); - #else const auto tabOptionV3 = qstyleoption_cast( option ); - #endif bool documentMode = tabOptionV3 ? tabOptionV3->documentMode : false; const QTabWidget *tabWidget = ( widget && widget->parentWidget() ) ? qobject_cast( widget->parentWidget() ) : nullptr; documentMode |= ( tabWidget ? tabWidget->documentMode() : true ); @@ -6370,11 +6265,7 @@ bool isRightOfSelected( tabOption->selectedPosition == QStyleOptionTab::PreviousIsSelected ); // document mode - #if OXYGEN_USE_KDE4 - const auto tabOptV3 = qstyleoption_cast( option ); - #else const auto tabOptV3 = qstyleoption_cast( option ); - #endif bool documentMode = tabOptV3 ? tabOptV3->documentMode : false; const QTabWidget *tabWidget = ( widget && widget->parentWidget() ) ? qobject_cast( widget->parentWidget() ) : nullptr; documentMode |= ( tabWidget ? tabWidget->documentMode() : true ); @@ -6759,13 +6650,8 @@ const bool reverseLayout( option->direction == Qt::RightToLeft ); // cast option and check - #if OXYGEN_USE_KDE4 - const auto v2 = qstyleoption_cast( option ); - if( v2 && v2->position == QStyleOptionToolBoxV2::Beginning && selected ) return true; - #else const auto v2 = qstyleoption_cast( option ); if( v2 && v2->position == QStyleOptionToolBox::Beginning && selected ) return true; - #endif /* the proper widget ( the toolbox tab ) is not passed as argument by Qt. @@ -6872,12 +6758,7 @@ const bool reverseLayout( option->direction == Qt::RightToLeft ); // cast to v2 to check vertical bar - #if OXYGEN_USE_KDE4 - const auto v2 = qstyleoption_cast( option ); - #else const auto v2 = qstyleoption_cast( option ); - #endif - const bool verticalTitleBar( v2 ? v2->verticalTitleBar : false ); const QRect buttonRect( subElementRect( dockWidgetOption->floatable ? SE_DockWidgetFloatButton : SE_DockWidgetCloseButton, option, widget ) ); @@ -7482,7 +7363,7 @@ } // call base class primitive - ParentStyleClass::drawComplexControl( CC_ScrollBar, option, painter, widget ); + KStyle::drawComplexControl( CC_ScrollBar, option, painter, widget ); return true; } @@ -7510,7 +7391,7 @@ { palette = _helper->disabledPalette( palette, _animations->widgetEnableStateEngine().opacity( widget, AnimationEnable ) ); } palette.setCurrentColorGroup( active ? QPalette::Active: QPalette::Disabled ); - ParentStyleClass::drawItemText( painter, textRect, Qt::AlignCenter, palette, active, titleBarOption->text, QPalette::WindowText ); + KStyle::drawItemText( painter, textRect, Qt::AlignCenter, palette, active, titleBarOption->text, QPalette::WindowText ); } @@ -8728,15 +8609,9 @@ //____________________________________________________________________ bool Style::isQtQuickControl( const QStyleOption* option, const QWidget* widget ) const { - #if QT_VERSION >= 0x050000 const bool is = (widget == nullptr) && option && option->styleObject && option->styleObject->inherits( "QQuickItem" ); if ( is ) _windowManager->registerQuickItem( static_cast( option->styleObject ) ); return is; - #else - Q_UNUSED( widget ); - Q_UNUSED( option ); - return false; - #endif } //_____________________________________________________________ @@ -8798,11 +8673,7 @@ const bool reverseLayout( tabOption->direction == Qt::RightToLeft ); // get documentMode flag - #if OXYGEN_USE_KDE4 - const auto tabOptionV3 = qstyleoption_cast( tabOption ); - #else const auto tabOptionV3 = qstyleoption_cast( tabOption ); - #endif bool documentMode = tabOptionV3 ? tabOptionV3->documentMode : false; const QTabWidget *tabWidget = ( widget && widget->parentWidget() ) ? qobject_cast( widget->parentWidget() ) : nullptr; diff --git a/kstyle/oxygenstylehelper.h b/kstyle/oxygenstylehelper.h --- a/kstyle/oxygenstylehelper.h +++ b/kstyle/oxygenstylehelper.h @@ -43,11 +43,6 @@ //* constructor explicit StyleHelper( KSharedConfigPtr config ); - #if OXYGEN_USE_KDE4 - //* constructor - explicit StyleHelper( const QByteArray& ); - #endif - //* destructor //* clear cache void invalidateCaches() override; diff --git a/kstyle/oxygenstylehelper.cpp b/kstyle/oxygenstylehelper.cpp --- a/kstyle/oxygenstylehelper.cpp +++ b/kstyle/oxygenstylehelper.cpp @@ -42,13 +42,6 @@ Helper( config ) { init(); } - //______________________________________________________________________________ - #if OXYGEN_USE_KDE4 - StyleHelper::StyleHelper( const QByteArray& name ): - Helper( name ) - { init(); } - #endif - //______________________________________________________________________________ void StyleHelper::invalidateCaches( void ) { diff --git a/kstyle/oxygenstyleplugin.h b/kstyle/oxygenstyleplugin.h --- a/kstyle/oxygenstyleplugin.h +++ b/kstyle/oxygenstyleplugin.h @@ -30,9 +30,7 @@ Q_OBJECT - #if QT_VERSION >= 0x050000 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "oxygen.json" ) - #endif public: diff --git a/kstyle/oxygenstyleplugin.cpp b/kstyle/oxygenstyleplugin.cpp --- a/kstyle/oxygenstyleplugin.cpp +++ b/kstyle/oxygenstyleplugin.cpp @@ -23,10 +23,6 @@ #include -#if QT_VERSION < 0x050000 -Q_EXPORT_PLUGIN2( oxygen-qt, Oxygen::StylePlugin ) -#endif - namespace Oxygen { diff --git a/kstyle/oxygenwindowmanager.h b/kstyle/oxygenwindowmanager.h --- a/kstyle/oxygenwindowmanager.h +++ b/kstyle/oxygenwindowmanager.h @@ -27,14 +27,11 @@ #include #include +#include #include #include #include -#if !OXYGEN_USE_KDE4 -#include -#endif - #if OXYGEN_HAVE_KWAYLAND namespace KWayland { @@ -66,10 +63,8 @@ //* register widget void registerWidget( QWidget* ); -#if !OXYGEN_USE_KDE4 //* register quick item void registerQuickItem( QQuickItem* ); -#endif //* unregister widget void unregisterWidget( QWidget* ); @@ -170,20 +165,14 @@ //* reset drag void resetDrag( void ); -#if QT_VERSION >= 0x050000 - using Window = QWindow; -#else - using Window = QWidget; -#endif - //* start drag - void startDrag( Window*, const QPoint& ); + void startDrag( QWindow*, const QPoint& ); //* X11 specific implementation for startDrag - void startDragX11( Window*, const QPoint& ); + void startDragX11( QWindow*, const QPoint& ); //* Wayland specific implementation for startDrag - void startDragWayland( Window*, const QPoint& ); + void startDragWayland( QWindow*, const QPoint& ); //* returns true if window manager is used for moving /** right now this is true only for X11 */ @@ -274,9 +263,7 @@ /** Weak pointer is used in case the target gets deleted while drag is in progress */ WeakPointer _target; -#if !OXYGEN_USE_KDE4 WeakPointer _quickTarget; -#endif //* true if drag is about to start bool _dragAboutToStart; diff --git a/kstyle/oxygenwindowmanager.cpp b/kstyle/oxygenwindowmanager.cpp --- a/kstyle/oxygenwindowmanager.cpp +++ b/kstyle/oxygenwindowmanager.cpp @@ -64,6 +64,8 @@ #include #include #include +#include +#include #include #include #include @@ -75,27 +77,15 @@ #include #include - -#if QT_VERSION >= 0x050300 // needed to deal with device pixel ratio #include -#endif #if OXYGEN_HAVE_X11 #include #include -#if OXYGEN_USE_KDE4 -#include -#else #include -#endif - -#endif -#if !OXYGEN_USE_KDE4 -#include -#include #endif #if OXYGEN_HAVE_KWAYLAND @@ -163,36 +153,15 @@ bool appMouseEvent( QObject*, QEvent* event ) { - #if OXYGEN_USE_KDE4 - // store target window (see later) - QWidget* window( _parent->_target.data()->window() ); - #else Q_UNUSED( event ); - #endif /* post some mouseRelease event to the target, in order to counter balance the mouse press that triggered the drag. Note that it triggers a resetDrag */ QMouseEvent mouseEvent( QEvent::MouseButtonRelease, _parent->_dragPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); qApp->sendEvent( _parent->_target.data(), &mouseEvent ); - #if OXYGEN_USE_KDE4 - if( event->type() == QEvent::MouseMove ) - { - /* - HACK: quickly move the main cursor out of the window and back - this is needed to get the focus right for the window children - the origin of this issue is unknown at the moment. - This apparently got fixed with qt5 - */ - const QPoint cursor = QCursor::pos(); - QCursor::setPos(window->mapToGlobal( window->rect().topRight() ) + QPoint(1, 0) ); - QCursor::setPos(cursor); - - } - #endif - return false; } @@ -322,7 +291,6 @@ } -#if !OXYGEN_USE_KDE4 void WindowManager::registerQuickItem( QQuickItem* item ) { if ( !item ) return; @@ -336,7 +304,6 @@ } } -#endif //_____________________________________________________________ void WindowManager::unregisterWidget( QWidget* widget ) @@ -394,17 +361,13 @@ case QEvent::MouseMove: if ( object == _target.data() -#if !OXYGEN_USE_KDE4 || object == _quickTarget.data() -#endif ) return mouseMoveEvent( object, event ); break; case QEvent::MouseButtonRelease: if ( _target -#if !OXYGEN_USE_KDE4 || _quickTarget -#endif ) return mouseReleaseEvent( object, event ); break; @@ -426,15 +389,10 @@ { _dragTimer.stop(); -#if OXYGEN_USE_KDE4 - if( _target ) - { startDrag( _target.data()->window(), _globalDragPoint ); } -#else if( _target ) { startDrag( _target.data()->window()->windowHandle(), _globalDragPoint ); } else if( _quickTarget ) { startDrag( _quickTarget.data()->window(), _globalDragPoint ); } -#endif } else { @@ -453,16 +411,13 @@ QMouseEvent *mouseEvent = static_cast( event ); if( !( mouseEvent->modifiers() == Qt::NoModifier && mouseEvent->button() == Qt::LeftButton ) ) { return false; } -#if !OXYGEN_USE_KDE4 if (mouseEvent->source() != Qt::MouseEventNotSynthesized) { return false; } -#endif // check lock if( isLocked() ) return false; else setLocked( true ); -#if !OXYGEN_USE_KDE4 // check QQuickItem - we can immediately start drag, because QQuickWindow's contentItem // only receives mouse events that weren't handled by children if ( QQuickItem *item = qobject_cast( object ) ) { @@ -475,7 +430,6 @@ return true; } -#endif // cast to widget QWidget *widget = static_cast( object ); @@ -514,10 +468,8 @@ Q_UNUSED( object ); QMouseEvent *mouseEvent = static_cast( event ); -#if !OXYGEN_USE_KDE4 if (mouseEvent->source() != Qt::MouseEventNotSynthesized) { return false; } -#endif // stop timer if( _dragTimer.isActive() ) _dragTimer.stop(); @@ -853,9 +805,7 @@ } _target.clear(); -#if !OXYGEN_USE_KDE4 _quickTarget.clear(); -#endif if( _dragTimer.isActive() ) _dragTimer.stop(); _dragPoint = QPoint(); _globalDragPoint = QPoint(); @@ -865,7 +815,7 @@ } //____________________________________________________________ - void WindowManager::startDrag( Window* window, const QPoint& position ) + void WindowManager::startDrag( QWindow* window, const QPoint& position ) { if( !( enabled() && window ) ) return; @@ -894,26 +844,16 @@ } //_______________________________________________________ - void WindowManager::startDragX11( Window* window, const QPoint& position ) + void WindowManager::startDragX11( QWindow* window, const QPoint& position ) { #if OXYGEN_HAVE_X11 // connection xcb_connection_t* connection( Helper::connection() ); - #if QT_VERSION >= 0x050300 const qreal dpiRatio = qApp->devicePixelRatio(); - #else - const qreal dpiRatio = 1; - #endif - - #if OXYGEN_USE_KDE4 - Display* net_connection = QX11Info::display(); - #else - xcb_connection_t* net_connection = connection; - #endif xcb_ungrab_pointer( connection, XCB_TIME_CURRENT_TIME ); - NETRootInfo( net_connection, NET::WMMoveResize ).moveResizeRequest( + NETRootInfo( connection, NET::WMMoveResize ).moveResizeRequest( window->winId(), position.x() * dpiRatio, position.y() * dpiRatio, NET::Move ); @@ -927,7 +867,7 @@ } //_______________________________________________________ - void WindowManager::startDragWayland( Window* window, const QPoint& ) + void WindowManager::startDragWayland( QWindow* window, const QPoint& ) { #if OXYGEN_HAVE_KWAYLAND if( !_seat ) { diff --git a/kstyle/transitions/oxygentransitionwidget.cpp b/kstyle/transitions/oxygentransitionwidget.cpp --- a/kstyle/transitions/oxygentransitionwidget.cpp +++ b/kstyle/transitions/oxygentransitionwidget.cpp @@ -80,11 +80,7 @@ rect = rect.translated( widget->mapTo( widget->window(), widget->rect().topLeft() ) ); widget = widget->window(); - #if QT_VERSION < 0x050000 - out = QPixmap::grabWidget( widget, rect ); - #else out = widget->grab( rect ); - #endif } else { diff --git a/liboxygen/CMakeLists.txt b/liboxygen/CMakeLists.txt --- a/liboxygen/CMakeLists.txt +++ b/liboxygen/CMakeLists.txt @@ -11,73 +11,42 @@ oxygenshadowcache.cpp oxygentileset.cpp) -if(OXYGEN_USE_KDE4) - - kde4_add_kcfg_files(oxygenstyle_LIB_SRCS +kconfig_add_kcfg_files(oxygenstyle_LIB_SRCS oxygenactiveshadowconfiguration.kcfgc oxygeninactiveshadowconfiguration.kcfgc - ) - - kde4_add_library(oxygenstyle SHARED ${oxygenstyle_LIB_SRCS}) - - generate_export_header(oxygenstyle BASE_NAME oxygen EXPORT_FILE_NAME oxygen_export.h) - - target_link_libraries(oxygenstyle ${KDE4_KDEUI_LIBS}) - - if(OXYGEN_HAVE_X11) - target_link_libraries(oxygenstyle ${X11_XCB_LIBRARIES}) - target_link_libraries(oxygenstyle ${XCB_LIBRARIES}) - endif() - - set_target_properties(oxygenstyle PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) +) - if(WIN32) - # As stated in http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx M_PI only gets defined - # when using MSVC if _USE_MATH_DEFINES is defined (this is needed for angle.cpp) - target_compile_definitions(oxygenstyle PRIVATE _USE_MATH_DEFINES _GNU_SOURCE) - endif() - install(TARGETS oxygenstyle ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) +add_library(oxygenstyle5 ${oxygenstyle_LIB_SRCS}) + +generate_export_header(oxygenstyle5 BASE_NAME oxygen EXPORT_FILE_NAME oxygen_export.h) + +# NB: although we install no headers, we still need to have a link +# interface, since other Oxygen targets link to this library +target_link_libraries(oxygenstyle5 + PUBLIC + Qt5::Core + Qt5::Gui + Qt5::Widgets + KF5::ConfigCore + KF5::ConfigWidgets + KF5::WindowSystem + PRIVATE + KF5::GuiAddons +) -else() +target_include_directories(oxygenstyle5 PUBLIC "$") - kconfig_add_kcfg_files(oxygenstyle_LIB_SRCS - oxygenactiveshadowconfiguration.kcfgc - oxygeninactiveshadowconfiguration.kcfgc - ) - - add_library(oxygenstyle5 ${oxygenstyle_LIB_SRCS}) - - generate_export_header(oxygenstyle5 BASE_NAME oxygen EXPORT_FILE_NAME oxygen_export.h) - - # NB: although we install no headers, we still need to have a link - # interface, since other Oxygen targets link to this library - target_link_libraries(oxygenstyle5 - PUBLIC - Qt5::Core - Qt5::Gui - Qt5::Widgets - KF5::ConfigCore - KF5::ConfigWidgets - KF5::WindowSystem - PRIVATE - KF5::GuiAddons - ) - - target_include_directories(oxygenstyle5 PUBLIC "$") - - if(OXYGEN_HAVE_X11) - target_link_libraries(oxygenstyle5 PRIVATE XCB::XCB Qt5::X11Extras) - endif() - - set_target_properties(oxygenstyle5 PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) - if(WIN32) - # As stated in http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx M_PI only gets defined - # when using MSVC if _USE_MATH_DEFINES is defined (this is needed for angle.cpp) - target_compile_definitions(oxygenstyle5 PRIVATE _USE_MATH_DEFINES _GNU_SOURCE) - endif() - install(TARGETS oxygenstyle5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) +if(OXYGEN_HAVE_X11) + target_link_libraries(oxygenstyle5 PRIVATE XCB::XCB Qt5::X11Extras) +endif() +set_target_properties(oxygenstyle5 PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) +if(WIN32) + # As stated in http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx M_PI only gets defined + # when using MSVC if _USE_MATH_DEFINES is defined (this is needed for angle.cpp) + target_compile_definitions(oxygenstyle5 PRIVATE _USE_MATH_DEFINES _GNU_SOURCE) endif() +install(TARGETS oxygenstyle5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) ################# liboxygenstyleconfig ################# set(oxygenstyleconfig_LIB_SRCS @@ -94,58 +63,31 @@ ui/oxygenshadowconfigurationui.ui ) -if(OXYGEN_USE_KDE4) - - kde4_add_ui_files(oxygenstyleconfig_LIB_FORMS_HEADERS ${oxygenstyleconfig_LIB_FORMS}) - kde4_add_kcfg_files(oxygenstyleconfig_LIB_SRCS - oxygenactiveshadowconfiguration.kcfgc - oxygeninactiveshadowconfiguration.kcfgc - ) - - kde4_add_library(oxygenstyleconfig SHARED - ${oxygenstyleconfig_LIB_SRCS} - ${oxygenstyleconfig_LIB_FORMS_HEADERS}) - - generate_export_header(oxygenstyleconfig BASE_NAME oxygen_config EXPORT_FILE_NAME oxygen_config_export.h) +ki18n_wrap_ui(oxygenstyleconfig_LIB_FORMS_HEADERS ${oxygenstyleconfig_LIB_FORMS}) - target_link_libraries(oxygenstyleconfig ${KDE4_KDEUI_LIBS}) - - set_target_properties(oxygenstyleconfig PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) - install(TARGETS oxygenstyleconfig ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) - - # NB: although we install no headers, we still need to have a link - # interface, since other Oxygen targets link to this library - target_link_libraries(oxygenstyleconfig oxygenstyle) - -else() - - ki18n_wrap_ui(oxygenstyleconfig_LIB_FORMS_HEADERS ${oxygenstyleconfig_LIB_FORMS}) - - kconfig_add_kcfg_files(oxygenstyleconfig_LIB_SRCS - oxygenactiveshadowconfiguration.kcfgc - oxygeninactiveshadowconfiguration.kcfgc - ) - - add_library(oxygenstyleconfig5 SHARED - ${oxygenstyleconfig_LIB_SRCS} - ${oxygenstyleconfig_LIB_FORMS_HEADERS}) - - generate_export_header(oxygenstyleconfig5 BASE_NAME oxygen_config EXPORT_FILE_NAME oxygen_config_export.h) - - # NB: although we install no headers, we still need to have a link - # interface, since other Oxygen targets link to this library - target_link_libraries(oxygenstyleconfig5 - PUBLIC - oxygenstyle5 - Qt5::Core - Qt5::Gui - Qt5::Widgets - PRIVATE - KF5::I18n - ) +kconfig_add_kcfg_files(oxygenstyleconfig_LIB_SRCS + oxygenactiveshadowconfiguration.kcfgc + oxygeninactiveshadowconfiguration.kcfgc +) - set_target_properties(oxygenstyleconfig5 PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) - install(TARGETS oxygenstyleconfig5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) - # Note: no headers installed +add_library(oxygenstyleconfig5 SHARED + ${oxygenstyleconfig_LIB_SRCS} + ${oxygenstyleconfig_LIB_FORMS_HEADERS}) + +generate_export_header(oxygenstyleconfig5 BASE_NAME oxygen_config EXPORT_FILE_NAME oxygen_config_export.h) + +# NB: although we install no headers, we still need to have a link +# interface, since other Oxygen targets link to this library +target_link_libraries(oxygenstyleconfig5 + PUBLIC + oxygenstyle5 + Qt5::Core + Qt5::Gui + Qt5::Widgets + PRIVATE + KF5::I18n +) -endif() +set_target_properties(oxygenstyleconfig5 PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) +install(TARGETS oxygenstyleconfig5 ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) +# Note: no headers installed diff --git a/liboxygen/config-liboxygen.h.cmake b/liboxygen/config-liboxygen.h.cmake --- a/liboxygen/config-liboxygen.h.cmake +++ b/liboxygen/config-liboxygen.h.cmake @@ -22,9 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * *************************************************************************/ -/* Define to 1 if you compile against KDE4*/ -#cmakedefine01 OXYGEN_USE_KDE4 - /* Define to 1 if you have XCB libraries */ #cmakedefine01 OXYGEN_HAVE_X11 diff --git a/liboxygen/liboxygen.h b/liboxygen/liboxygen.h --- a/liboxygen/liboxygen.h +++ b/liboxygen/liboxygen.h @@ -26,18 +26,8 @@ namespace Oxygen { - #if QT_VERSION >= 0x050000 //* scoped pointer convenience typedef template using WeakPointer = QPointer; - #else - //* scoped pointer convenience typedef - template using WeakPointer = QWeakPointer; - #endif - - //* disable QStringLiteral for older Qt version - #if QT_VERSION < 0x050000 - using QStringLiteral = QString; - #endif //* corners enum Corner diff --git a/liboxygen/oxygenhelper.h b/liboxygen/oxygenhelper.h --- a/liboxygen/oxygenhelper.h +++ b/liboxygen/oxygenhelper.h @@ -32,10 +32,6 @@ #include #include -#if OXYGEN_USE_KDE4 -#include -#endif - #include #include #include @@ -229,11 +225,6 @@ //* constructor explicit Helper( KSharedConfig::Ptr config ); - #if OXYGEN_USE_KDE4 - //* constructor - explicit Helper( const QByteArray& ); - #endif - //* destructor virtual ~Helper() {} @@ -473,11 +464,6 @@ //* initialize void init( void ); - #if OXYGEN_USE_KDE4 - //* component data - KComponentData _componentData; - #endif - //* configuration KSharedConfig::Ptr _config; qreal _bgcontrast; diff --git a/liboxygen/oxygenhelper.cpp b/liboxygen/oxygenhelper.cpp --- a/liboxygen/oxygenhelper.cpp +++ b/liboxygen/oxygenhelper.cpp @@ -27,10 +27,6 @@ #include #include -#if OXYGEN_USE_KDE4 -#include -#endif - #include #include #include @@ -41,10 +37,6 @@ #include #endif -#if OXYGEN_HAVE_X11 && QT_VERSION < 0x050000 -#include -#endif - namespace Oxygen { @@ -57,27 +49,15 @@ _config( config ) { init(); } - //____________________________________________________________________ - #if OXYGEN_USE_KDE4 - Helper::Helper( const QByteArray& name ): - _componentData( name, 0, KComponentData::SkipMainComponentRegistration ), - _config( _componentData.config() ) - { init(); } - #endif - //____________________________________________________________________ KSharedConfig::Ptr Helper::config() const { return _config; } //____________________________________________________________________ void Helper::loadConfig() { - #if OXYGEN_USE_KDE4 - _contrast = KGlobalSettings::contrastF( _config ); - #else _contrast = KColorScheme::contrastF( _config ); - #endif _bgcontrast = qMin( 1.0, 0.9*_contrast/0.7 ); @@ -798,70 +778,43 @@ //______________________________________________________________________________________ QPixmap Helper::highDpiPixmap( int width, int height ) const { - #if QT_VERSION >= 0x050300 const qreal dpiRatio( qApp->devicePixelRatio() ); QPixmap pixmap( width*dpiRatio, height*dpiRatio ); pixmap.setDevicePixelRatio( dpiRatio ); return pixmap; - #else - return QPixmap( width, height ); - #endif } //______________________________________________________________________________________ qreal Helper::devicePixelRatio( const QPixmap& pixmap ) const { - #if QT_VERSION >= 0x050300 return pixmap.devicePixelRatio(); - #else - Q_UNUSED(pixmap); - return 1; - #endif } //______________________________________________________________________________ bool Helper::isX11( void ) { #if OXYGEN_HAVE_X11 - #if QT_VERSION >= 0x050000 static const bool s_isX11 = KWindowSystem::isPlatformX11(); return s_isX11; - #else - return true; - #endif #endif return false; } bool Helper::isWayland( void ) { - #if QT_VERSION >= 0x050000 static const bool s_isWayland = KWindowSystem::isPlatformWayland(); return s_isWayland; - #else - return false; - #endif } #if OXYGEN_HAVE_X11 //____________________________________________________________________ xcb_connection_t* Helper::connection( void ) { - #if QT_VERSION >= 0x050000 return QX11Info::connection(); - #else - static xcb_connection_t* connection = nullptr; - if( !connection ) - { - Display* display = QX11Info::display(); - if( display ) connection = XGetXCBConnection( display ); - } - return connection; - #endif } //____________________________________________________________________ @@ -978,11 +931,7 @@ void Helper::init( void ) { - #if OXYGEN_USE_KDE4 - _contrast = KGlobalSettings::contrastF( _config ); - #else _contrast = KColorScheme::contrastF( _config ); - #endif // background contrast is calculated so that it is 0.9 // when KGlobalSettings contrast value of 0.7 diff --git a/liboxygen/oxygenshadowcache.cpp b/liboxygen/oxygenshadowcache.cpp --- a/liboxygen/oxygenshadowcache.cpp +++ b/liboxygen/oxygenshadowcache.cpp @@ -111,13 +111,8 @@ if( !_enabled ) setEnabled( true ); // shadows - #if OXYGEN_USE_KDE4 - ActiveShadowConfiguration::self()->readConfig(); - InactiveShadowConfiguration::self()->readConfig(); - #else ActiveShadowConfiguration::self()->load(); InactiveShadowConfiguration::self()->load(); - #endif // copy sizes to local _activeShadowSize = ActiveShadowConfiguration::shadowSize(); diff --git a/liboxygen/oxygenshadowconfigwidget.cpp b/liboxygen/oxygenshadowconfigwidget.cpp --- a/liboxygen/oxygenshadowconfigwidget.cpp +++ b/liboxygen/oxygenshadowconfigwidget.cpp @@ -74,11 +74,7 @@ ActiveShadowConfiguration::setUseOuterColor( ui->useOuterColor->isChecked() ); ActiveShadowConfiguration::setEnabled( isChecked() ); - #if OXYGEN_USE_KDE4 - ActiveShadowConfiguration::self()->writeConfig(); - #else ActiveShadowConfiguration::self()->save(); - #endif } else if( _group == QPalette::Inactive ) { @@ -89,11 +85,7 @@ InactiveShadowConfiguration::setUseOuterColor( ui->useOuterColor->isChecked() ); InactiveShadowConfiguration::setEnabled( isChecked() ); - #if OXYGEN_USE_KDE4 - InactiveShadowConfiguration::self()->writeConfig(); - #else InactiveShadowConfiguration::self()->save(); - #endif } @@ -136,11 +128,7 @@ if( defaults ) ActiveShadowConfiguration::self()->setDefaults(); else { - #if OXYGEN_USE_KDE4 - ActiveShadowConfiguration::self()->readConfig(); - #else ActiveShadowConfiguration::self()->load(); - #endif } @@ -157,11 +145,7 @@ if( defaults ) InactiveShadowConfiguration::self()->setDefaults(); else { - #if OXYGEN_USE_KDE4 - InactiveShadowConfiguration::self()->readConfig(); - #else InactiveShadowConfiguration::self()->load(); - #endif } diff --git a/liboxygen/oxygentileset.cpp b/liboxygen/oxygentileset.cpp --- a/liboxygen/oxygentileset.cpp +++ b/liboxygen/oxygentileset.cpp @@ -32,23 +32,13 @@ //______________________________________________________________________________________ inline qreal devicePixelRatio( const QPixmap& pixmap ) { - #if QT_VERSION >= 0x050300 return pixmap.devicePixelRatio(); - #else - Q_UNUSED( pixmap ); - return 1; - #endif } //______________________________________________________________________________________ inline void setDevicePixelRatio( QPixmap& pixmap, qreal value ) { - #if QT_VERSION >= 0x050300 return pixmap.setDevicePixelRatio( value ); - #else - Q_UNUSED( pixmap ); - Q_UNUSED( value ); - #endif } //______________________________________________________________