summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/connect
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/docs/examples/connect
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/docs/examples/connect')
-rw-r--r--kjsembed/docs/examples/connect/connect.js45
-rw-r--r--kjsembed/docs/examples/connect/connect.ui160
2 files changed, 205 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/connect/connect.js b/kjsembed/docs/examples/connect/connect.js
new file mode 100644
index 00000000..aa56a366
--- /dev/null
+++ b/kjsembed/docs/examples/connect/connect.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env kjscmd
+
+//
+// Demo that connects C++ signals to JS slots of various types.
+//
+
+// Load the demo gui
+var top = Factory.loadui( 'connect.ui' );
+
+// Util func to print a msg
+function msg(s)
+{
+ top.child('output').append(s);
+}
+
+// JS object we connect to
+function DemoObj()
+{
+ this.func_void = function() { msg('void'); }
+ this.func_bool = function(b) { msg(b); }
+ this.func_int = function(i) { msg(i); }
+ this.func_string = function(s) { msg(s); }
+ this.func_double = function(d) { msg(d); }
+}
+
+//
+// Main
+//
+
+var obj = new DemoObj();
+
+var ve = top.child('v');
+var be = top.child('b');
+var ie = top.child('i');
+var se = top.child('s');
+var de = top.child('d');
+
+top.connect( ve, 'clicked()', obj, 'func_void' );
+top.connect( be, 'toggled(bool)', obj, 'func_bool' );
+top.connect( ie, 'valueChanged(int)', obj, 'func_int' );
+top.connect( se, 'textChanged(const QString&)', obj, 'func_string' );
+top.connect( de, 'valueChanged(double)', obj, 'func_double' );
+
+top.show();
+application.exec();
diff --git a/kjsembed/docs/examples/connect/connect.ui b/kjsembed/docs/examples/connect/connect.ui
new file mode 100644
index 00000000..5b172a8d
--- /dev/null
+++ b/kjsembed/docs/examples/connect/connect.ui
@@ -0,0 +1,160 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>demo</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>demo</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>434</width>
+ <height>348</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Connect Demo</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>s</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>160</red>
+ <green>239</green>
+ <blue>139</blue>
+ </color>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="text">
+ <string>Slot Output</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="5" column="1">
+ <property name="name">
+ <cstring>d</cstring>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="4" column="1">
+ <property name="name">
+ <cstring>i</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>160</red>
+ <green>239</green>
+ <blue>139</blue>
+ </color>
+ </property>
+ <property name="frameShape">
+ <enum>Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string>Signal Source</string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>b</cstring>
+ </property>
+ <property name="text">
+ <string>Bool</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>v</cstring>
+ </property>
+ <property name="text">
+ <string>Void</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="5" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Double:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Int:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>String:</string>
+ </property>
+ </widget>
+ <widget class="KTextBrowser" row="1" column="2" rowspan="6" colspan="1">
+ <property name="name">
+ <cstring>output</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <spacer row="6" column="1">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>ktextbrowser.h</includehint>
+</includehints>
+</UI>