Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
mock_qobject.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <QObject>
7
8// Mock QObject for testing
9class MockQObject : public QObject
10{
11 Q_OBJECT
12 Q_PROPERTY (
13 int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
14 Q_PROPERTY (
15 QString stringValue READ stringValue WRITE setStringValue NOTIFY
16 stringValueChanged)
17 Q_PROPERTY (
18 double doubleValue READ doubleValue WRITE setDoubleValue NOTIFY
19 doubleValueChanged)
20
21public:
22 MockQObject (QObject * parent = nullptr) : QObject (parent) { }
23
24 int intValue () const { return int_value_; }
25 void setIntValue (int value)
26 {
27 if (int_value_ != value)
28 {
29 int_value_ = value;
30 Q_EMIT intValueChanged (value);
31 }
32 }
33
34 QString stringValue () const { return string_value_; }
35 void setStringValue (const QString &value)
36 {
37 if (string_value_ != value)
38 {
39 string_value_ = value;
40 Q_EMIT stringValueChanged (value);
41 }
42 }
43
44 double doubleValue () const { return double_value_; }
45 void setDoubleValue (double value)
46 {
47 if (double_value_ != value)
48 {
49 double_value_ = value;
50 Q_EMIT doubleValueChanged (value);
51 }
52 }
53
54Q_SIGNALS:
55 void intValueChanged (int value);
56 void stringValueChanged (const QString &value);
57 void doubleValueChanged (double value);
58
59private:
60 int int_value_ = 42;
61 QString string_value_ = QStringLiteral ("initial");
62 double double_value_ = 3.14;
63};