Skip to content

Commit

Permalink
[qt5] turn off qtquick2 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jan 21, 2014
1 parent 8bdfdb7 commit 6e87ae1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
6 changes: 5 additions & 1 deletion qt5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
4 changes: 4 additions & 0 deletions qt5/style/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
79 changes: 47 additions & 32 deletions qt5/style/qtcurve_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,21 @@
# include <QX11Info>
#endif

#include <QQuickWindow>
#include <QQuickItem>
#ifdef QTC_QT5_ENABLE_QTQUICK2
# include <QQuickWindow>
# include <QQuickItem>
#endif
#include <QDebug>

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<QDynamicPropertyChangeEvent*>(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<QQuickWindow*>(receiver)) {
#ifdef QTC_QT5_ENABLE_QTQUICK2
if (QQuickWindow *window = qobject_cast<QQuickWindow*>(obj)) {
// QtQuickControl support
// This is still VERY experimental.
// Need a lot more testing and refactoring.
Expand All @@ -87,14 +71,43 @@ qtcEventCallback(void **cbdata)
}
}
}
} else if (QQuickItem *item = qobject_cast<QQuickItem*>(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<QQuickItem*>(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<QDynamicPropertyChangeEvent*>(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;
}
Expand All @@ -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
Expand All @@ -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());
Expand Down

0 comments on commit 6e87ae1

Please sign in to comment.