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
52 Q_INVOKABLE static QColor getTrackBackground (
53 const QColor &baseColor,
54 const QColor &trackColor,
55 const QColor &windowTextColor,
56 bool isSelected,
57 bool isHovered,
58 bool tint = true);
59
60 Q_INVOKABLE static QVector<float>
61 getAutomationRegionValues (QObject * automationRegion, int pixelWidth);
62
63 Q_INVOKABLE static bool rectanglesIntersect (QRectF a, QRectF b);
64 Q_INVOKABLE static bool rectanglesIntersect (QRect a, QRect b);
65
69 Q_INVOKABLE static QItemSelection createRowSelection (
70 QAbstractItemModel * model,
71 const QList<int> &rows,
72 int column = 0);
73
77 Q_INVOKABLE static QItemSelection createRangeSelection (
78 QAbstractItemModel * model,
79 int startRow,
80 int endRow,
81 int startCol = 0,
82 int endCol = 0);
83};
84}
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.
static Q_INVOKABLE QColor getTrackBackground(const QColor &baseColor, const QColor &trackColor, const QColor &windowTextColor, bool isSelected, bool isHovered, bool tint=true)
Computes a track background color with optional track-color tinting.