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)
 
static Q_INVOKABLE bool isValidColor (const QString &colorName)
 

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 23 of file globalfunctions.cpp.

24 : QObject(parent)
25{
26}

Member Function Documentation

◆ isValidColor()

bool GlobalFunctions::isValidColor ( const QString &  colorName)
static

Definition at line 61 of file globalfunctions.cpp.

62{
63 return QColor::isValidColor(colorName);
64}

◆ itemAt()

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

Definition at line 28 of file globalfunctions.cpp.

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

◆ itemUnderMouse()

bool GlobalFunctions::itemUnderMouse ( QQuickItem *  item)
static

Definition at line 56 of file globalfunctions.cpp.

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

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