Commit 1cdf2ab8 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Cursor KCM] Restore live preview on hover

When hovering a cursor in the delegate, it changes the mouse cursor to it.
While at it, modernize, i.e. nullptr, range-for, KWindowSystem::isPlatformX11(), coding style

Differential Revision: https://phabricator.kde.org/D24157
parent 90715d69
......@@ -18,8 +18,11 @@
#include <QPainter>
#include <QMouseEvent>
#include <QQuickRenderControl>
#include <QQuickWindow>
#include <KWindowSystem>
#include "previewwidget.h"
#include <QX11Info>
......@@ -274,19 +277,18 @@ void PreviewWidget::hoverMoveEvent(QHoverEvent *e)
{
if (needLayout)
layoutItems();
//FIXME: we can't find an handle to the actual window
//in the case we are in a QQuickWidget, so we can't do the live preview
/*
foreach (const PreviewCursor *c, list)
{
if (c->rect().contains(e->pos()))
{
if (c != current)
{
for (const PreviewCursor *c : qAsConst(list)) {
if (c->rect().contains(e->pos())) {
if (c != current) {
const uint32_t cursor = *c;
if (QX11Info::isPlatformX11() && (cursor != XCB_CURSOR_NONE) && window()) {
xcb_change_window_attributes(QX11Info::connection(), window()->winId(), XCB_CW_CURSOR, &cursor);
if (QWindow *actualWindow = QQuickRenderControl::renderWindowFor(window())) {
if (KWindowSystem::isPlatformX11() && cursor != XCB_CURSOR_NONE) {
xcb_change_window_attributes(QX11Info::connection(), actualWindow->winId(), XCB_CW_CURSOR, &cursor);
}
}
current = c;
}
return;
......@@ -294,14 +296,13 @@ void PreviewWidget::hoverMoveEvent(QHoverEvent *e)
}
setCursor(Qt::ArrowCursor);
current = NULL;
*/
current = nullptr;
}
void PreviewWidget::hoverLeaveEvent(QHoverEvent *e)
{
if (window()) {
window()->unsetCursor();
if (QWindow *actualWindow = QQuickRenderControl::renderWindowFor(window())) {
actualWindow->unsetCursor();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment