dotherside/D/test.d

71 lines
1.3 KiB
D
Raw Normal View History

2014-07-19 16:26:08 +00:00
import std.stdio;
import std.string;
import std.traits;
import std.conv;
import std.functional;
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);
nameChanged = registerSignal!(string)("nameChanged");
2014-08-30 16:46:34 +00:00
tor = registerSlot("tor", &_tor);
2014-07-19 16:26:08 +00:00
}
DSlot!(void delegate(int)) foo;
void _foo(int fooValue)
2014-07-19 16:26:08 +00:00
{
writeln("D: Called foo slot with argument ", fooValue , "!!");
2014-07-19 16:26:08 +00:00
}
DSlot!(int delegate(int)) bar;
int _bar(int barValue)
2014-07-19 16:26:08 +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
{}
}