10#include "qml_material/util/corner.hpp"
11#include "qml_material/core/enum.hpp"
12#include "qml_material/token/token.hpp"
13#include "qml_material/core.hpp"
14#include "qml_material/export.hpp"
15#include "qml_material/control/icon_spec.hpp"
20struct QML_MATERIAL_API ComponentSource {
21 QPointer<QQmlComponent> component;
22 std::unique_ptr<QQmlComponent> ownedComponent;
25 explicit operator bool()
const {
return component !=
nullptr; }
28class Util :
public QObject {
30 QML_NAMED_ELEMENT(UtilCpp)
32 Util(QObject* parent =
nullptr);
42 Q_INVOKABLE
void track(QVariant, Track);
48 Q_INVOKABLE
void openUrlExternally(
const QString& url);
49 Q_INVOKABLE
void openFolderExternally(
const QString& url);
51 Q_INVOKABLE
bool hasIcon(ActionIcon* icon)
const;
53 Q_INVOKABLE
static void closePopup(QObject* obj);
55 Q_INVOKABLE
static QColor transparent(QColor in,
float alpha)
noexcept;
56 Q_INVOKABLE
static QColor hoverColor(QColor in)
noexcept;
57 Q_INVOKABLE
static QColor pressColor(QColor in)
noexcept;
59 Q_INVOKABLE
static QML_MATERIAL_API QColor mixColorOklab(QColor from, QColor to,
60 qreal progress)
noexcept;
62 Q_INVOKABLE
static qreal devicePixelRatio(QQuickItem* in);
64 Q_INVOKABLE
static CornersGroup listCorners(qint32 idx, qint32 count, qint32 radius)
noexcept;
65 Q_INVOKABLE
static CornersGroup tableCorners(qint32 row, qint32 column, qint32 rows,
66 qint32 columns, qint32 radius)
noexcept;
67 Q_INVOKABLE
static CornersGroup tableWithHeaderCorners(qint32 row, qint32 column, qint32 rows,
68 qint32 columns, qint32 radius)
noexcept;
70 Q_INVOKABLE
static CornersGroup cornerArray(QVariant in)
noexcept;
71 Q_INVOKABLE
static CornersGroup corners(qreal in)
noexcept;
72 Q_INVOKABLE
static CornersGroup corners(qreal, qreal)
noexcept;
73 Q_INVOKABLE
static CornersGroup corners(qreal tl, qreal tr, qreal bl, qreal br)
noexcept;
75 QString type_str(
const QJSValue&);
77 Q_INVOKABLE
void print_parents(
const QJSValue&);
79 Q_INVOKABLE
static qreal lightness(QColor color)
noexcept;
81 Q_INVOKABLE
static token::Elevation tokenElevation() noexcept;
82 Q_INVOKABLE static token::Shape tokenShape() noexcept;
83 Q_INVOKABLE static token::State tokenState() noexcept;
85 Q_INVOKABLE QObject* createItem(const QJSValue& url_or_comp, const QVariantMap& props,
86 QObject* parent =
nullptr);
88 Q_INVOKABLE QObject* showPopup(const QJSValue& url_or_comp, const QVariantMap& props,
89 QObject* parent =
nullptr,
bool open_and_destry = true);
91 Q_INVOKABLE static QString paramsString(const QVariantMap& props);
92 Q_INVOKABLE static
void setCursor(QQuickItem* item, Qt::CursorShape shape);
94 Q_INVOKABLE static
double clamp(
double t,
double low,
double high);
95 Q_INVOKABLE static
double teleportCurve(
double t,
double left,
double right);
100 Q_INVOKABLE static
double bezierY(
double t,
double p1x,
double p1y,
double p2x,
101 double p2y) noexcept;
104 Q_INVOKABLE static
double segFrac(
double playtime,
double delay,
double duration,
double p1x,
105 double p1y,
double p2x,
double p2y) noexcept;
107 Q_INVOKABLE static QString stateText(
bool enabled,
bool pressed,
bool hovered,
108 bool focused) noexcept;
110 Q_INVOKABLE static
void forceSetImplicitHeight(QQuickItem* item, qreal height);
111 Q_INVOKABLE static
void forceSetImplicitWidth(QQuickItem* item, qreal width);
113 Q_INVOKABLE static
void cellHoveredOn(QQuickItem* item,
bool hovered, qint32 row,
115 Q_INVOKABLE static QObject* getParent(QObject* obj);
116 Q_INVOKABLE static QQuickItem* controlAncestor(QQuickItem* item);
117 Q_INVOKABLE static
bool disconnectAll(QObject* obj, const QString&);
119 Q_INVOKABLE static quint32 poolObjectCount() noexcept;
120 Q_INVOKABLE static qint32 i32Max() noexcept;
123 Q_SLOT
void onPopupFinished();
126 usize m_tracked { 0 };
129QML_MATERIAL_API
auto resolveComponentSource(
const QVariant& source, QQmlEngine* engine,
130 QQmlContext* context,
131 QQmlComponent::CompilationMode mode)
137void sysOpenUrl(
const QString& url);
138void sysOpenFolder(
const QString& url);
143auto qml_dyn_count() -> std::atomic<i32>&;
144auto createItem(QQmlEngine* engine,
const QJSValue& url_or_comp,
const QVariantMap& props,
145 QObject* parent, QQmlContext* context) -> QObject*;