Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0836ae7

Browse filesBrowse files
devmilpauldotknopf
andauthored
QQuickPaintedItem support (#219)
* First support for QQuickPaintedItem Implements some basic drawing functionalities * Less string passing during drawing Colors get registered and are referenced via id Font parameters can be set separately * Color string to id conversion is now an implementation detail of QmlNetPaintedItem * Adds Font metrics functionality * Adds DrawText overload with bounding rectangle * Dont copy the actions on each draw but lock the vector * Optional Text support for QmlNetPaintedItem (including preedit) * Adds Flags to the DrawText (Rect) method * Adds an interface to interact with a QPainter This interface can be implemented by a QPainter abstraction in the future For now QmlNetPaintedItem implements INetQPainter * Native submodule: Adds QMutex include * Native submodule: Adds missing include * Adds a lot of the QPainter interface * Fixes Polygon point handling Adds new QPainter API to QmlNetPaintedItem * Renames QmlNetPaintedItem to QmlNetRecordingPaintedItem * Deactivates painthandler reset in destructor of RecordingPaintedItem * Registering a QuickPaintedItem * Hide QmlNetQuickPaintedItem from QML * First theoretically working PaintedItem implementation * getStringSize is now static * new native submodule version * new native submodule (build error fix) * Cleanup Removes RecordingPaintedItem Removes INetQPainter (functionality moved to NetQPainter) * references native that fixes type registration * Draw Image file * Adds testing infrastructure for QmlNetQuickPaintedItem * DrawArc test * DrawConvexPolygon test * Fixes GCHandle handling in QmlNetQuickPaintedItem * Adds setWindowIcon support to QGuiApplication * Adds DrawEllipse and DrawLine test * Adds DrawPoint test * Adds DrawPolygon test * Adds DrawRoundedRect test * Draw Pie Unit Test * Test source formatting * DrawPolyline Unit test * Erase Rect Unit Test * Unit Tests for ClipRect and Opacity * Disables transformations Real world use cases would want to use the QTransform functionality instead of passing the raw transformation matrix * Unit Test for Sheer * Adds Unit test for Translate * Cleanup * Link to native/origin/master * Re-Trigger CI Co-authored-by: Paul Knopf <pauldotknopf@gmail.com>
1 parent 4e54f97 commit 0836ae7
Copy full SHA for 0836ae7

15 files changed

+1824
-17
lines changed

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ output/
33
samples/PhotoFrame/\.vscode/
44
samples/PhotoFrame/\.idea/
55
build/Qt/
6-
build/qtci/
6+
build/qtci/
7+
src/native/.DS_Store
8+
.DS_Store

‎src/net/Qml.Net.Tests/Qml.Net.Tests.csproj

Copy file name to clipboardExpand all lines: src/net/Qml.Net.Tests/Qml.Net.Tests.csproj
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
1010
<PackageReference Include="Moq" Version="4.10.1" />
1111
<PackageReference Include="SharpCompress" Version="0.23.0" />
12+
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.1" />
1213
<PackageReference Include="xunit" Version="2.4.1" />
1314
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
1415
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

‎src/net/Qml.Net.Tests/Qml/BaseQmlTests.cs

Copy file name to clipboardExpand all lines: src/net/Qml.Net.Tests/Qml/BaseQmlTests.cs
+68-12Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,61 @@ protected virtual void RegisterType<T>()
3232
_registeredTypes.Add(typeof(T));
3333
Net.Qml.RegisterType<T>("tests");
3434
}
35+
36+
protected virtual void RegisterPaintedQuickItemType<T>()
37+
where T : QmlNetQuickPaintedItem
38+
{
39+
if (_registeredTypes.Contains(typeof(T))) return;
40+
_registeredTypes.Add(typeof(T));
41+
Net.Qml.RegisterPaintedQuickItemType<T>("tests");
42+
}
3543

36-
protected void RunQmlTest(string instanceId, string componentOnCompletedCode, bool runEvents = false, bool failOnQmlWarnings = true)
44+
protected void RunQmlTest(string instanceId, string componentOnCompletedCode, bool runEvents = false, bool failOnQmlWarnings = true, string additionalProperties = "")
3745
{
38-
var result = NetTestHelper.RunQml(
39-
qmlApplicationEngine,
40-
string.Format(
41-
@"
46+
var qml = string.Format(
47+
@"
4248
import QtQuick 2.0
4349
import tests 1.0
4450
{0} {{
4551
id: {1}
52+
{2}
4653
property var testQObject: null
4754
function runTest() {{
48-
{2}
55+
{3}
4956
}}
5057
}}
5158
",
52-
typeof(TTypeToRegister).Name,
53-
instanceId,
54-
componentOnCompletedCode),
55-
runEvents,
56-
failOnQmlWarnings);
59+
typeof(TTypeToRegister).Name,
60+
instanceId,
61+
additionalProperties,
62+
componentOnCompletedCode);
63+
var result = true;
64+
Exception exception= null;
65+
try
66+
{
67+
result = NetTestHelper.RunQml(
68+
qmlApplicationEngine,
69+
qml,
70+
runEvents,
71+
failOnQmlWarnings);
72+
}
73+
catch (Exception ex)
74+
{
75+
exception = ex;
76+
result = false;
77+
}
78+
5779
if (result == false)
5880
{
59-
throw new Exception($"Couldn't execute qml: {componentOnCompletedCode}");
81+
var msg = $"Couldn't execute qml: {Environment.NewLine}{qml}";
82+
if (exception != null)
83+
{
84+
throw new Exception(msg, exception);
85+
}
86+
else
87+
{
88+
throw new Exception(msg);
89+
}
6090
}
6191
}
6292

@@ -84,6 +114,32 @@ protected BaseQmlTests(bool enableAutoSignals = false)
84114
TypeCreator.SetInstance(typeof(T), Mock.Object);
85115
}
86116
}
117+
118+
public abstract class BaseQmlQuickPaintedItemTests<T> : AbstractBaseQmlTests<T>
119+
where T : QmlNetQuickPaintedItem
120+
{
121+
protected readonly Mock<T> Mock;
122+
123+
protected BaseQmlQuickPaintedItemTests()
124+
{
125+
RegisterPaintedQuickItemType<T>();
126+
Mock = new Mock<T>();
127+
TypeCreator.SetInstance(typeof(T), Mock.Object);
128+
}
129+
}
130+
131+
public abstract class BaseQmlQuickPaintedItemTestsWithInstance<T> : AbstractBaseQmlTests<T>
132+
where T : QmlNetQuickPaintedItem, new()
133+
{
134+
protected readonly T Instance;
135+
136+
protected BaseQmlQuickPaintedItemTestsWithInstance()
137+
{
138+
RegisterPaintedQuickItemType<T>();
139+
Instance = new T();
140+
TypeCreator.SetInstance(typeof(T), Instance);
141+
}
142+
}
87143

88144
public abstract class BaseQmlTestsWithInstance<T> : AbstractBaseQmlTests<T>
89145
where T : class, new()

‎src/net/Qml.Net.Tests/Qml/MvvmInteropBehaviorTests.cs

Copy file name to clipboardExpand all lines: src/net/Qml.Net.Tests/Qml/MvvmInteropBehaviorTests.cs
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ public void Does_register_property_changed_signal()
180180
})
181181
viewModelContainer.changeStringPropertyTo('new value')
182182
");
183-
184183
Instance.TestResult.Should().Be(true);
185184
}
186185

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.