Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
qml_utils.h
1// SPDX-FileCopyrightText: © 2025-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <QItemSelectionModel>
7#include <QObject>
8#include <QtQmlIntegration/qqmlintegration.h>
9
10namespace zrythm::gui::qquick
11{
12
13class QmlUtils : public QObject
14{
15 Q_OBJECT
16 QML_ELEMENT
17 QML_SINGLETON
18
19public:
20 Q_INVOKABLE static QString toPathString (const QUrl &url);
21 Q_INVOKABLE static QUrl localFileToQUrl (const QString &path);
22 Q_INVOKABLE static QString pathBasename (const QString &path);
23
24 Q_INVOKABLE static float amplitudeToDbfs (float amplitude);
25 Q_INVOKABLE static QStringList splitTextLines (const QString &text);
26 Q_INVOKABLE static QStringList removeDuplicates (const QStringList &list);
27 Q_INVOKABLE static QString readTextFileContent (const QString &filePath);
28
29 Q_INVOKABLE static QColor saturate (const QColor &color, float perc);
30 Q_INVOKABLE static QColor makeBrighter (const QColor &color, float perc);
31 Q_INVOKABLE static QColor
32 adjustOpacity (const QColor &color, float newOpacity);
33
34 Q_INVOKABLE static QVector<float>
35 getAutomationRegionValues (QObject * automationRegion, int pixelWidth);
36
37 Q_INVOKABLE static bool rectanglesIntersect (QRectF a, QRectF b);
38 Q_INVOKABLE static bool rectanglesIntersect (QRect a, QRect b);
39
43 Q_INVOKABLE static QItemSelection createRowSelection (
44 QAbstractItemModel * model,
45 const QList<int> &rows,
46 int column = 0);
47
51 Q_INVOKABLE static QItemSelection createRangeSelection (
52 QAbstractItemModel * model,
53 int startRow,
54 int endRow,
55 int startCol = 0,
56 int endCol = 0);
57};
58}
static Q_INVOKABLE QItemSelection createRangeSelection(QAbstractItemModel *model, int startRow, int endRow, int startCol=0, int endCol=0)
Helper to create a contiguous block/range selection.
static Q_INVOKABLE QItemSelection createRowSelection(QAbstractItemModel *model, const QList< int > &rows, int column=0)
Helper to create a selection from a list of rows in a single column.