summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/imagetweak/imagetweak.js
blob: ea1d094412b5bb08a1267720e2655e276c51f775 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env kjscmd

if ( application.args.length == 0 ) {
    throw 'Usage:\n\timagetweak imgfile ...';
}

//
// Setup main window
//
var mw = new KMainWindow();
var view = new TQScrollView( mw, 'view' );
mw.setCentralWidget( view );

var lbl = new TQLabel( view, 'view' );
view.addChild( lbl );

//
// Load image
//
var loc = application.args[0];
var img = new Image();

img.load( loc );
if ( !img.isOk() ) {
   throw 'Failed to load image ' + loc;
}

lbl.pixmap=img.pixmap();

//
// Actions
//
var ac = mw.actionCollection();

//
// Create the quit action and connect it to a C++ slot
//
StdAction.quit( application, 'quit()', ac );

//
// We'll wire the file open action up to a JS function
//

mw.openFile = function() {
   var filename = StdDialog.getOpenFileName( '.', '*' );
   if ( filename.length > 0 ) {
      view.text = System.readFile( filename );
   }
}

var open_action = StdAction.open( null, '', ac );
open_action.connect( open_action, 'activated()', mw, 'openFile' );

//
// We'll just accept the default for the rest of the actions
//

StdAction.aboutApp( null, '', ac );
StdAction.aboutKDE( null, '', ac );
StdAction.help( null, '', ac );
StdAction.helpContents( null, '', ac );
StdAction.openRecent( null, '', ac );
StdAction.save( null, '', ac );
StdAction.saveAs( null, '', ac );
StdAction.showMenubar( null, '', ac );
StdAction.showStatusbar( null, '', ac );
StdAction.showToolbar( null, '', ac );

//
// Activate XMLGUI and show the window
//
mw.createGUI( 'stdactionsui.rc' );
mw.resize( 500, 350 );
mw.show();

application.exec();