/usr/share/qterm/scripts/websnap.js is in qterm 1:0.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | QTerm.loadExtension("qt.core");
QTerm.loadExtension("qt.network");
QTerm.loadExtension("qt.gui");
QTerm.loadExtension("qt.webkit");
var WebSnap = WebSnap ? WebSnap : new Object;
WebSnap.webPage = new QWebPage;
WebSnap.label = new QLabel;
//WebSnap.label = new QLabel(QTerm.window());
WebSnap.loading = false;
WebSnap.showSnap = function(ok)
{
if (!ok) {
QTerm.osdMessage("cannot download the webpage");
return;
}
this.loading = false;
var target = new QSize(400, 300);
var size = this.webPage.mainFrame().contentsSize;
size.setHeight(size.width() * target.height() / target.width());
// create the target surface
var image = new QPixmap(size);
image.fill(Qt.transparent);
// render and rescale
var p = new QPainter;
p.begin(image);
this.webPage.viewportSize = this.webPage.mainFrame().contentsSize;
this.webPage.mainFrame().render(p);
p.end();
image = image.scaled(target, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation);
// QTerm.osdMessage("generating finished", 1, 0);
this.label.size = target;
this.label.pixmap = image;
}
WebSnap.getWebsnap = function( urlStr )
{
// QTerm.osdMessage("generating websnap", 1, 0);
var url = new QUrl(urlStr, QUrl.TolerantMode);
// this.webPage = new QWebPage;
// this.label = new QLabel;
this.webPage.loadFinished.connect(this,this.showSnap);
this.webPage.mainFrame().load(url);
this.loading = true;
var image = new QPixmap;
image.load(QTerm.localPath()+"pic/loading.png");
this.label.pixmap = image;
// this.label.setWindowFlags(Qt.FramelessWindowHint)
this.label.move(QTerm.posX(),QTerm.posY());
this.label.show();
}
QTerm.WebSnap = WebSnap;
QTerm.onWebsnap = function()
{
QTerm.WebSnap.getWebsnap(QTerm.getUrl());
}
if (QTerm.addUrlMenu( "snapshot", "Web Snapshot" ) ) {
QTerm.snapshot.triggered.connect(QTerm.onWebsnap);
}
|