2014-07-19 16:26:08 +00:00
|
|
|
import std.stdio;
|
|
|
|
import std.string;
|
|
|
|
import std.traits;
|
|
|
|
import std.conv;
|
|
|
|
import std.functional;
|
2014-08-30 19:46:15 +00:00
|
|
|
import core.memory;
|
2014-07-19 16:26:08 +00:00
|
|
|
import dotherside;
|
|
|
|
import dobject;
|
|
|
|
import dslot;
|
2014-08-30 16:46:34 +00:00
|
|
|
import dsignal;
|
2014-07-19 16:26:08 +00:00
|
|
|
|
|
|
|
class MyObject : DObject
|
|
|
|
{
|
|
|
|
this()
|
|
|
|
{
|
2014-08-30 16:46:34 +00:00
|
|
|
foo = registerSlot("foo", &_foo);
|
2014-07-19 16:26:08 +00:00
|
|
|
bar = registerSlot("bar", &_bar);
|
2014-08-30 19:46:15 +00:00
|
|
|
nameChanged = registerSignal!(string)("nameChanged");
|
2014-08-30 16:46:34 +00:00
|
|
|
tor = registerSlot("tor", &_tor);
|
2014-07-19 16:26:08 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 15:05:52 +00:00
|
|
|
DSlot!(void delegate(int)) foo;
|
|
|
|
void _foo(int fooValue)
|
2014-07-19 16:26:08 +00:00
|
|
|
{
|
2014-07-20 15:05:52 +00:00
|
|
|
writeln("D: Called foo slot with argument ", fooValue , "!!");
|
2014-07-19 16:26:08 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 15:05:52 +00:00
|
|
|
DSlot!(int delegate(int)) bar;
|
|
|
|
int _bar(int barValue)
|
2014-07-19 16:26:08 +00:00
|
|
|
{
|
2014-07-20 15:05:52 +00:00
|
|
|
writeln("D: Called bar slot with argument " , barValue, "!!");
|
2014-07-19 16:26:08 +00:00
|
|
|
return 666;
|
|
|
|
}
|
2014-08-30 16:46:34 +00:00
|
|
|
|
|
|
|
DSlot!(string delegate(string)) tor;
|
|
|
|
string _tor (string torValue)
|
|
|
|
{
|
|
|
|
writeln("D: Called tor slot with argument ", torValue, "!!");
|
|
|
|
return "2343";
|
|
|
|
}
|
|
|
|
|
|
|
|
DSignal!(string) nameChanged;
|
|
|
|
//DSignal!(string, int, bool) complexChanged;
|
2014-07-19 16:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
auto app = new GuiApplication;
|
|
|
|
scope(exit) clear(app);
|
2014-08-30 16:46:34 +00:00
|
|
|
|
2014-07-19 16:26:08 +00:00
|
|
|
auto view = new QuickView;
|
|
|
|
scope(exit) clear(view);
|
|
|
|
|
|
|
|
auto myObject = new MyObject();
|
|
|
|
|
|
|
|
auto context = view.rootContext();
|
|
|
|
context.setContextProperty("myObject", new QVariant(myObject));
|
|
|
|
|
|
|
|
view.setSource("Test.qml");
|
|
|
|
view.show();
|
2014-08-30 16:46:34 +00:00
|
|
|
|
|
|
|
myObject.nameChanged("prova");
|
|
|
|
|
2014-07-19 16:26:08 +00:00
|
|
|
app.exec();
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{}
|
|
|
|
}
|