summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/systemtray
diff options
context:
space:
mode:
Diffstat (limited to 'kjsembed/docs/examples/systemtray')
-rw-r--r--kjsembed/docs/examples/systemtray/kjstray.pngbin0 -> 259 bytes
-rwxr-xr-xkjsembed/docs/examples/systemtray/systemtray.js30
2 files changed, 30 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/systemtray/kjstray.png b/kjsembed/docs/examples/systemtray/kjstray.png
new file mode 100644
index 00000000..f77ae150
--- /dev/null
+++ b/kjsembed/docs/examples/systemtray/kjstray.png
Binary files differ
diff --git a/kjsembed/docs/examples/systemtray/systemtray.js b/kjsembed/docs/examples/systemtray/systemtray.js
new file mode 100755
index 00000000..5ecc55f0
--- /dev/null
+++ b/kjsembed/docs/examples/systemtray/systemtray.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env kjscmd
+
+//
+// Example that uses KSystemTray
+//
+
+// Create the main window
+mainwin = new QTextEdit(this);
+mainwin.text = '<qt>This is the main window for a script that illustrates '
+ + 'the use of the <i>System Tray</i>.';
+
+// Create the tray icon
+trayicon = new KSystemTray( mainwin );
+
+// Set the pixmap of the tray icon (we force it to be loaded from the cwd here)
+cwd = (new QDir()).absPath();
+trayicon.pixmap = trayicon.loadIcon( cwd + '/kjstray.png' );
+
+// Ensure we quit when you choose the option from the tray item's menu
+application.connect( trayicon, 'quitSelected()', 'quit()' );
+
+// Get the context menu
+var menu = trayicon.contextMenu();
+menu.insertItem("My Item");
+
+// Show both the main window and the icon
+trayicon.show();
+mainwin.show();
+
+application.exec();