2022-01-23 15:57:04 +01:00
|
|
|
import org.kde.falkon 1.0 as Falkon
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.0
|
|
|
|
import QtQuick 2.3
|
|
|
|
|
|
|
|
Falkon.PluginInterface {
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: rssFinderObject
|
|
|
|
property ListModel feeds: ListModel {}
|
2022-03-12 02:15:24 +01:00
|
|
|
property string jsFinder
|
2022-01-23 15:57:04 +01:00
|
|
|
}
|
|
|
|
|
2022-06-19 23:50:43 +02:00
|
|
|
init: function(state, settingsPath) {
|
2022-03-12 02:15:24 +01:00
|
|
|
console.log(i18n('"RSSFinder" plugin is loading'))
|
|
|
|
rssFinderObject.jsFinder = Falkon.FileUtils.readAllFileContents('finder.js')
|
|
|
|
if (rssFinderObject.jsFinder.length == 0) {
|
|
|
|
console.log(i18n('"RSSFinder" Unable to load "finder.js""'))
|
|
|
|
}
|
2022-01-23 15:57:04 +01:00
|
|
|
console.log(i18n('"RSSFinder" plugin loaded'))
|
|
|
|
}
|
|
|
|
|
|
|
|
testPlugin: function() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
unload: function() {
|
|
|
|
console.log(i18n('"RSSFinder" plugin unloaded'))
|
|
|
|
}
|
|
|
|
|
|
|
|
function findCurrentTab(window) {
|
|
|
|
for (var i = 0; i < window.tabs.length; ++i) {
|
|
|
|
if (window.tabs[i].current) {
|
|
|
|
return window.tabs[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function findFeeds() {
|
2022-03-12 02:15:24 +01:00
|
|
|
if (rssFinderObject.jsFinder.length == 0) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-23 15:57:04 +01:00
|
|
|
var window = Falkon.Windows.getCurrent()
|
|
|
|
var currentTab = findCurrentTab(window)
|
2022-03-12 02:15:24 +01:00
|
|
|
var result = currentTab.execJavaScript(rssFinderObject.jsFinder)
|
2022-01-23 15:57:04 +01:00
|
|
|
|
|
|
|
rssFinderObject.feeds.clear()
|
|
|
|
|
|
|
|
for (var link of result.links) {
|
|
|
|
rssFinderObject.feeds.append({
|
|
|
|
"title": link.title,
|
|
|
|
"url": link.url
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Falkon.BrowserAction {
|
|
|
|
name: 'RSS Finder'
|
|
|
|
identity: 'rssfinder-id'
|
|
|
|
title: i18n('RSS Finder')
|
|
|
|
toolTip: i18n('RSS Finder')
|
2022-03-12 23:31:47 +01:00
|
|
|
icon: 'rss.svg'
|
2022-01-23 15:57:04 +01:00
|
|
|
location: Falkon.BrowserAction.NavigationToolBar | Falkon.BrowserAction.StatusBar
|
|
|
|
onClicked: findFeeds()
|
|
|
|
|
2022-06-19 23:50:43 +02:00
|
|
|
popup: Pane {
|
|
|
|
id: mainPane
|
2022-01-23 15:57:04 +01:00
|
|
|
width: 500
|
|
|
|
height: 200
|
|
|
|
|
2022-06-19 23:50:43 +02:00
|
|
|
ScrollView {
|
|
|
|
width: mainPane.width
|
|
|
|
height: mainPane.height
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
Component {
|
|
|
|
id: contactsDelegate
|
|
|
|
|
2023-02-21 23:16:30 +01:00
|
|
|
RowLayout {
|
|
|
|
spacing: 2
|
2022-06-19 23:50:43 +02:00
|
|
|
width: rssList.width
|
|
|
|
|
2023-02-21 23:16:30 +01:00
|
|
|
Button {
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: Falkon.Tabs.addTab({
|
|
|
|
url: url,
|
|
|
|
windowId: Falkon.Windows.getCurrent()
|
|
|
|
})
|
2023-02-21 23:49:42 +01:00
|
|
|
clip: true
|
2023-02-21 23:16:30 +01:00
|
|
|
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: i18n("Open in new tab")
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
Label {
|
|
|
|
font.bold: true
|
|
|
|
topPadding: 5
|
|
|
|
leftPadding: 5
|
|
|
|
text: title
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
leftPadding: 5
|
|
|
|
bottomPadding: 5
|
|
|
|
text: url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-19 23:50:43 +02:00
|
|
|
|
2023-02-21 23:16:30 +01:00
|
|
|
Button {
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: Falkon.Clipboard.copy(url)
|
2022-06-19 23:50:43 +02:00
|
|
|
|
2023-02-21 23:16:30 +01:00
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: i18n("Copy URL")
|
|
|
|
|
|
|
|
contentItem: Image {
|
|
|
|
source: 'clipboard.svg'
|
2023-02-22 11:49:32 +01:00
|
|
|
sourceSize.width: 50
|
|
|
|
sourceSize.height: 50
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2022-06-19 23:50:43 +02:00
|
|
|
}
|
2022-01-23 15:57:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-19 23:50:43 +02:00
|
|
|
id: rssList
|
|
|
|
model: rssFinderObject.feeds
|
|
|
|
delegate: contactsDelegate
|
|
|
|
focus: true
|
|
|
|
spacing: 5
|
|
|
|
}
|
2022-01-23 15:57:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-19 23:50:43 +02:00
|
|
|
|
2022-01-23 15:57:04 +01:00
|
|
|
}
|