Debian Codegraph @

src/scripts/senddelay.js

raw symbols SCIP
1 QTerm.loadScript("utils.js");
2
3 var SendDelay = SendDelay ? SendDelay : new Object;
4 SendDelay.stringQueue = new Array;
5
6 SendDelay.t = new QTimer;
7
8 SendDelay.q = new QEventLoop;
9
10 SendDelay.text = "";
11 SendDelay.times = 0;
12 SendDelay.delay = 0;
13
14 SendDelay.send = function(text, times, delay)
15 {
16 SendDelay.text = text;
17 SendDelay.times = times;
18 SendDelay.delay = delay;
19 for (var i = 0; i < times; i++) {
20 this.addSendString(text);
21 }
22 this.t.start(delay);
23 this.t.timeout.connect(this,this.sendOneChar);
24 QTerm.eventFinished.connect(this,this.q.quit);
25 this.q.exec();
26 QTerm.showMessage("QTerm","Send String Finished");
27 this.t.timeout.disconnect(this,this.sendOneChar);
28 QTerm.eventFinished.disconnect(this,this.q.quit);
29 }
30
31 SendDelay.addSendString = function(str)
32 {
33 this.stringQueue[this.stringQueue.length] = str;
34 }
35
36 SendDelay.sendOneChar = function()
37 {
38 var text = this.stringQueue.shift();
39 QTerm.sendParsedString(text);
40 if (this.stringQueue.length == 0) {
41 this.t.stop();
42 QTerm.eventFinished();
43 return;
44 }
45 }
46
47 QTerm.SendDelay = SendDelay;
48
49 QTerm.onSendDelay = function()
50 {
51 var UIloader = new QUiLoader(this);
52 var uifile = new QFile(QTerm.findFile("ui/senddelay.ui"));
53 uifile.open(QIODevice.ReadOnly);
54 var dialog = UIloader.load(uifile, this);
55 uifile.close();
56
57 dialog.stringLineEdit.text = QTerm.SendDelay.text;
58 dialog.repeatingSpinBox.value = QTerm.SendDelay.times;
59 dialog.delaySpinBox.value = QTerm.SendDelay.delay/1000;
60
61 if ( dialog.exec() == 0 )
62 return;
63
64 var text = dialog.stringLineEdit.text;
65 var times = dialog.repeatingSpinBox.value;
66 var delay = dialog.delaySpinBox.value*1000;
67
68 if (text.length != 0 && times != 0) {
69 QTerm.osdMessage("send \""+text+"\" "+times+" times with "+delay+" ms delay", QTerm.OSDType.Info, 2000);
70 QTerm.SendDelay.send(text,times,delay);
71 }
72 }
73
74 if (QTerm.addPopupMenu( "sendDelay", qsTr("Send String With Delay...") ) ) {
75 QTerm.sendDelay.triggered.connect(QTerm.onSendDelay);
76 }
77
78