1
FalkonTutorials/qml/extensions/qml_tutorial_4/main.qml
Juraj Oravec bb26607c5b
Add Qml web page context menu example
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
2022-03-29 00:58:20 +02:00

69 lines
1.9 KiB
QML

import org.kde.falkon 1.0 as Falkon
import QtQuick 2.3
Falkon.PluginInterface {
QtObject {
id: tutorial3Object
property int clickCount
}
init: function(state, settingsPath){
console.log(i18n('"Tutorial4" plugin loaded'))
tutorial3Object.clickCount = 0;
}
testPlugin: function() {
return true
}
unload: function() {
console.log(i18n('"Tutorial4" plugin unloaded'))
}
function buttonClicked() {
tutorial3Object.clickCount++;
console.log(i18n('"Tutorial4" clickCount increased to ' + tutorial3Object.clickCount))
}
Falkon.BrowserAction {
name: 'QML Tutorial 3'
identity: 'qml-tutorial-3-id'
title: i18n('Qml Tutorial 3')
toolTip: i18n('My little button')
icon: 'falkon'
badgeText: tutorial3Object.clickCount
location: Falkon.BrowserAction.NavigationToolBar | Falkon.BrowserAction.StatusBar
popup: Rectangle {
width: 100;
height: 100;
}
}
populateWebViewMenu: function(menu, webHitTestResult) {
var action_always = menu.addAction({
text: 'Increment counter by one',
icon: 'falkon'
})
action_always.triggered.connect(function() {
tutorial3Object.clickCount++;
console.log(i18n('"Tutorial4" clickCount increased to ' + tutorial3Object.clickCount))
})
if (webHitTestResult.isImage()) {
var action_image = menu.addAction({
text: 'Image, increment by two',
icon: 'falkon'
})
action_image.triggered.connect(function() {
tutorial3Object.clickCount += 2;
console.log(i18n('"Tutorial4" Surprise, this is an image with url: ' + webHitTestResult.imageUrl))
console.log(i18n('"Tutorial4" clickCount increased to ' + tutorial3Object.clickCount))
})
}
}
}