diff --git a/qt5/CMakeLists.txt b/qt5/CMakeLists.txt index c32a39b2..1d0359e5 100644 --- a/qt5/CMakeLists.txt +++ b/qt5/CMakeLists.txt @@ -2,7 +2,11 @@ if(ENABLE_QT5) set(QTC_QT5_LINK_LIBS) set(QTC_QT5_DEFS) set(QTC_QT5_INCLUDES) - set(QTC_QT5_MODULES Qt5Core Qt5Gui Qt5Widgets Qt5Svg Qt5Quick Qt5DBus) + if(QTC_QT5_ENABLE_QTQUICK2) + set(QTC_QT5_MODULES Qt5Core Qt5Gui Qt5Widgets Qt5Svg Qt5Quick Qt5DBus) + else() + set(QTC_QT5_MODULES Qt5Core Qt5Gui Qt5Widgets Qt5Svg Qt5DBus) + endif() foreach(QtModule ${QTC_QT5_MODULES}) find_package(${QtModule} REQUIRED) set(QTC_QT5_LINK_LIBS ${QTC_QT5_LINK_LIBS} ${${QtModule}_LIBRARIES}) diff --git a/qt5/style/CMakeLists.txt b/qt5/style/CMakeLists.txt index bd0c642f..b6cb222a 100644 --- a/qt5/style/CMakeLists.txt +++ b/qt5/style/CMakeLists.txt @@ -27,6 +27,10 @@ if(NOT ENABLE_QT5) return() endif() +if(QTC_QT5_ENABLE_QTQUICK2) + add_definitions(-DQTC_QT5_ENABLE_QTQUICK2=1) +endif() + set(qtcurve_style_common_SRCS ../common/common.cpp ../common/config_file.cpp) diff --git a/qt5/style/qtcurve_plugin.cpp b/qt5/style/qtcurve_plugin.cpp index cf405736..1420a03e 100644 --- a/qt5/style/qtcurve_plugin.cpp +++ b/qt5/style/qtcurve_plugin.cpp @@ -34,37 +34,21 @@ # include #endif -#include -#include +#ifdef QTC_QT5_ENABLE_QTQUICK2 +# include +# include +#endif #include namespace QtCurve { static bool inited = false; -__attribute__((hot)) static bool -qtcEventCallback(void **cbdata) +__attribute__((hot)) static void +qtcPolishQuickControl(QObject *obj) { - QObject *receiver = (QObject*)cbdata[0]; - QTC_RET_IF_FAIL(receiver, false); - QEvent *event = (QEvent*)cbdata[1]; - if (qtcUnlikely(event->type() == QEvent::DynamicPropertyChange)) { - QDynamicPropertyChangeEvent *prop_event = - static_cast(event); - // eat the property change events from ourselves - if (prop_event->propertyName() == QTC_PROP_NAME) { - return true; - } - } - QWidget *widget = qtcToWidget(receiver); - if (qtcUnlikely(widget && !qtcGetWid(widget))) { - if (Style *style = qtcGetStyle(widget)) { - style->prePolish(widget); - } - } else if (widget && event->type() == QEvent::UpdateRequest) { - QtcQWidgetProps props(widget); - props->opacity = 100; - } else if (QQuickWindow *window = qobject_cast(receiver)) { +#ifdef QTC_QT5_ENABLE_QTQUICK2 + if (QQuickWindow *window = qobject_cast(obj)) { // QtQuickControl support // This is still VERY experimental. // Need a lot more testing and refactoring. @@ -87,14 +71,43 @@ qtcEventCallback(void **cbdata) } } } - } else if (QQuickItem *item = qobject_cast(receiver)) { - QQuickWindow *window = item->window(); - if (!window) - return false; - if (qtcGetStyle(qApp)) { - window->setColor(QColor(0, 0, 0, 0)); - qtcX11BlurTrigger(window->winId(), true, 0, NULL); + } else if (QQuickItem *item = qobject_cast(obj)) { + if (QQuickWindow *window = item->window()) { + if (qtcGetStyle(qApp)) { + window->setColor(QColor(0, 0, 0, 0)); + qtcX11BlurTrigger(window->winId(), true, 0, NULL); + } + } + } +#else + QTC_UNUSED(obj); +#endif +} + +__attribute__((hot)) static bool +qtcEventCallback(void **cbdata) +{ + QObject *receiver = (QObject*)cbdata[0]; + QTC_RET_IF_FAIL(receiver, false); + QEvent *event = (QEvent*)cbdata[1]; + if (qtcUnlikely(event->type() == QEvent::DynamicPropertyChange)) { + QDynamicPropertyChangeEvent *prop_event = + static_cast(event); + // eat the property change events from ourselves + if (prop_event->propertyName() == QTC_PROP_NAME) { + return true; + } + } + QWidget *widget = qtcToWidget(receiver); + if (qtcUnlikely(widget && !qtcGetWid(widget))) { + if (Style *style = qtcGetStyle(widget)) { + style->prePolish(widget); } + } else if (widget && event->type() == QEvent::UpdateRequest) { + QtcQWidgetProps props(widget); + props->opacity = 100; + } else { + qtcPolishQuickControl(receiver); } return false; } @@ -103,7 +116,7 @@ QStyle* StylePlugin::create(const QString &key) { init(); - return "qtcurve" == key.toLower() ? new Style : 0; + return key.toLower() == "qtcurve" ? new Style : 0; } void @@ -114,7 +127,9 @@ StylePlugin::init() inited = true; QInternal::registerCallback(QInternal::EventNotifyCallback, qtcEventCallback); +#ifdef QTC_QT5_ENABLE_QTQUICK2 QQuickWindow::setDefaultAlphaBuffer(true); +#endif #ifdef Qt5X11Extras_FOUND if (qApp->platformName() == "xcb") { qtcX11InitXcb(QX11Info::connection(), QX11Info::appScreen());