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

The GlobalFunctions class. More...

`#include <plugins/Utils/globalfunctions.h>`

## 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.

: QObject(parent)
{
}

## Member Function Documentation

## isValidColor()

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

static

Definition at line 61 of file globalfunctions.cpp.

{
return QColor::isValidColor(colorName);
}

## itemAt()

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

static

Definition at line 28 of file globalfunctions.cpp.

{
if (!parent) return nullptr;
QList<QQuickItem *> children = QQuickItemPrivate::get(parent)->paintOrderChildItems();
for (int i = children.count() - 1; i >= 0; --i) {
QQuickItem *child = children.at(i);
// Map coordinates to the child element's coordinate space
QPointF point = parent->mapToItem(child, QPointF(x, y));
if (child->isVisible() && point.x() >= 0
&& child->width() >= point.x()
&& point.y() >= 0
&& child->height() >= point.y()) {
if (!matcher.isCallable()) return child;
QQmlEngine* engine = qmlEngine(child);
if (!engine) return child;
QJSValue newObj = engine->newQObject(child);
if (matcher.call(QJSValueList() << newObj).toBool()) {
return child;
}
}
}
return nullptr;
}

## itemUnderMouse()

bool GlobalFunctions::itemUnderMouse | ( | QQuickItem * | item | ) |

static

Definition at line 56 of file globalfunctions.cpp.

{
return item && item->isUnderMouse();
}

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

- plugins/Utils/globalfunctions.h
- plugins/Utils/globalfunctions.cpp