This is a draft. Do not read it.

Signals and slots in QtD

Declaring signals

Signals are declared using the following syntax:

class Sender : QObject
{
    mixin Signal!("private clicked", bool);
}

The protection attribute may be omitted. Signals are declared protected by default:

class Sender : QObject
{
    mixin Signal!("clicked"); // declares a protected clicked() signal
}

Signal parameter types can be specified either in parentheses right after the name or as separate template arguments:

mixin Signal!("clicked(bool)");

is equivalent to

mixin Signal!("clicked", bool);

If you have more than 6-8 signals in a class, it is recommended to declare them with a single mixin, in order to reduce compilation times:

class Sender : QObject
{
    mixin Signals!(
        "clicked(bool)",
        "pressed"
        );
}

Declaring slots

Slots are declared by instantiating the Slot mixin template with the name (and slot parameter types, if any) of the slot function:

class Receiver : QObject
{
    mixin Slot!("clickHandler(bool)");
    void clickHandler(bool arg)
    {
    }
}

You don't need to statically declare slots if it is acceptable for your application to use delegates as slots, in which case the slot is registered dynamically, implying extra processing at run time.

Like signals, slots can be declared with a single mixin:

class Receiver : QObject
{
    mixin Slots!(
        "clickHandler", bool,
        "clickHandler");

    void clickHandler()
    {
    }

    void clickHandler(bool arg)
    {
    }
}

The above example statically registers two slot overloads.

(Dis)connecting signals and slots

There are two major kinds of connections in QtD: static and dynamic. For static connections, concrete types of objects being connected and names of the signal and slot must be known at compile time. An example of such a connection:

auto sender = new Sender;
auto receiver = new Receiver;
connect!("clicked()", "clickHandler()")(sender, receiver);

Dynamic connections do not require concrete types, and names of members being connected may be unavailable at compile time.

connect(sender, "clicked()", receiver, "clickHandler()");

Both dynamic and static connections can be established using slot delegates, in which case the slot is resolved dynamically at run time.

connect!("clicked()")(sender, &receiver.clickHandler);
connect(sender, "clicked()", &receiver.clickHandler);

A partial name may be supplied for a member being connected. Then, the first member matching the partial name will be connected.

connect!("clicked")(sender, &receiver.clickHandler);

Disconnection of signals and slots is performed similarly using the disconnect function. Most of the time, manual disconnection is unnecessary because connections are removed automatically when the sender or receiver is destroyed.

Emitting signals

Signals in QtD are proper final methods, which means you emit them with a standard method call:

class Sender : QObject
{
    ...
    void click()
    {
        clicked(); // emitting signal clicked()
    }
}

Queued and blocking queued connections

Not implemented