104 lines
3.1 KiB
QML
104 lines
3.1 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 4'
|
|
identity: 'qml-tutorial-4-id'
|
|
title: i18n('Qml Tutorial 4')
|
|
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) {
|
|
/* Directly add actions to the menu */
|
|
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))
|
|
})
|
|
}
|
|
|
|
/* Add a separator between these 2 examples */
|
|
menu.addSeparator()
|
|
|
|
/* Create a submenu */
|
|
var subMenu = menu.addMenu({
|
|
title: 'Example submenu',
|
|
icon: 'falkon'
|
|
})
|
|
|
|
/* Copy the actions from before */
|
|
var sm_action_always = subMenu.addAction({
|
|
text: 'Increment counter by one',
|
|
icon: 'falkon'
|
|
})
|
|
|
|
sm_action_always.triggered.connect(function() {
|
|
tutorial3Object.clickCount++;
|
|
console.log(i18n('"Tutorial4" clickCount increased to ' + tutorial3Object.clickCount))
|
|
})
|
|
|
|
if (webHitTestResult.isImage()) {
|
|
var sm_action_image = subMenu.addAction({
|
|
text: 'Image, increment by two',
|
|
icon: 'falkon'
|
|
})
|
|
|
|
sm_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))
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
}
|