Lomiri
Loading...
Searching...
No Matches
GlobalFunctions Class Reference

The GlobalFunctions class. More...

#include <plugins/Utils/globalfunctions.h>

Inherits QObject.

Public Member Functions

 GlobalFunctions (QObject *parent=0)
 

Static Public Member Functions

static Q_INVOKABLE QQuickItem * itemAt (QQuickItem *parent, int x, int y, QJSValue matcher)
 
static Q_INVOKABLE bool itemUnderMouse (QQuickItem *item)
 

Detailed Description

The GlobalFunctions class.

This singleton class exposes utility functions to QML

Definition at line 30 of file globalfunctions.h.

Constructor & Destructor Documentation

◆ GlobalFunctions()

GlobalFunctions::GlobalFunctions ( QObject *  parent = 0)
explicit

Definition at line 22 of file globalfunctions.cpp.

23 : QObject(parent)
24{
25}

Member Function Documentation

◆ itemAt()

QQuickItem * GlobalFunctions::itemAt ( QQuickItem *  parent,
int  x,
int  y,
QJSValue  matcher 
)
static

Definition at line 27 of file globalfunctions.cpp.

28{
29 if (!parent) return nullptr;
30 QList<QQuickItem *> children = QQuickItemPrivate::get(parent)->paintOrderChildItems();
31
32 for (int i = children.count() - 1; i >= 0; --i) {
33 QQuickItem *child = children.at(i);
34
35 // Map coordinates to the child element's coordinate space
36 QPointF point = parent->mapToItem(child, QPointF(x, y));
37 if (child->isVisible() && point.x() >= 0
38 && child->width() >= point.x()
39 && point.y() >= 0
40 && child->height() >= point.y()) {
41 if (!matcher.isCallable()) return child;
42
43 QQmlEngine* engine = qmlEngine(child);
44 if (!engine) return child;
45
46 QJSValue newObj = engine->newQObject(child);
47 if (matcher.call(QJSValueList() << newObj).toBool()) {
48 return child;
49 }
50 }
51 }
52 return nullptr;
53}

◆ itemUnderMouse()

bool GlobalFunctions::itemUnderMouse ( QQuickItem *  item)
static

Definition at line 55 of file globalfunctions.cpp.

56{
57 return item && item->isUnderMouse();
58}

The documentation for this class was generated from the following files: