summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/systemtray/systemtray.js
blob: 1f87998ca2cfa0443b318c9073662d09b71939d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env kjscmd

//
// Example that uses KSystemTray
//

// Create the main window
mainwin = new TQTextEdit(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 TQDir()).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();