Adding support for auto generating notify signals.

This commit is contained in:
Paul Knopf 2020-10-21 10:23:02 -04:00
parent b4becbea92
commit 3672c7bf00
2 changed files with 15 additions and 0 deletions

View file

@ -146,6 +146,19 @@ namespace Qml.Net.Internal
NetSignalInfo notifySignal = null;
var notifySignalAttribute = propertyInfo.GetCustomAttribute<NotifySignalAttribute>();
// All properties have a default notify signal.
// This is so that when we read properties in QML,
// we don't get errors with "NON-NOTIFY PROPERTY BOUND
if (notifySignalAttribute == null && QmlNetConfig.AutoGenerateNotifySignals)
{
var dynamicName = $"dynamic__{propertyInfo.Name}Changed";
notifySignalAttribute = new NotifySignalAttribute
{
Name = dynamicName
};
}
if (notifySignalAttribute != null)
{
var name = notifySignalAttribute.Name;

View file

@ -18,6 +18,8 @@ namespace Qml.Net
public static bool ShouldEnsureUIThread { get; set; } = true;
public static bool AutoGenerateNotifySignals { get; set; } = false;
public static Action EnsureUIThreadDelegate = () =>
{
if (!QCoreApplication.IsMainThread)