Skip to content

Commit

Permalink
initial commit - v0.4
Browse files Browse the repository at this point in the history
* Ported Andreas Loos's version to Plasma 6.
* Incorporated some improvements from Mircea Kitsune.
* Fixed wrapping of titles.
* Improved theme support.
* Enriched the context menu.
  • Loading branch information
liujed committed Mar 30, 2024
0 parents commit 16abff7
Show file tree
Hide file tree
Showing 10 changed files with 704 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
v0.4
* Ported Andreas Loos's version to Plasma 6.
* Incorporated some improvements from Mircea Kitsune.
* Fixed wrapping of titles.
* Improved theme support.
* Enriched the context menu.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @liujed
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# RSS feed widget for KDE Plasma 6

A barebones widget for displaying an RSS feed. Shows the title, timestamp, and
description (without images) of each feed item. Clicking on a feed item opens
its link in the default browser.

Rescued and adapted for Plasma 6. This was originally written by Andreas Loos,
2015, and includes selected contributions from Mircea Kitsune, 2017-2018.
10 changes: 10 additions & 0 deletions package/contents/config/config.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import QtQuick 2.15
import org.kde.plasma.configuration

ConfigModel {
ConfigCategory {
name: i18n("General")
icon: 'preferences-system-windows'
source: 'config/ConfigGeneral.qml'
}
}
23 changes: 23 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>

<group name="General">
<entry name="refresh" type="Int">
<default>300</default>
</entry>
<entry name="url" type="String">
<default>https://dot.kde.org/rss.xml</default>
</entry>
<entry name="headerColor" type="String">
<default>#4682b4</default>
</entry>
<entry name="listOpacity" type="Int">
<default>80</default>
</entry>
</group>

</kcfg>
189 changes: 189 additions & 0 deletions package/contents/ui/FullRepresentation.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import QtQuick 2.15
import QtQml.XmlListModel
import QtQuick.Controls

import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid

Item {
id: window
width: 300
height: 500

property var url: plasmoid.configuration.url
property int refresh: 1000 * plasmoid.configuration.refresh
property var headerColor: plasmoid.configuration.headerColor
property var listOpacity: plasmoid.configuration.listOpacity

function stripString (str) {
var regex = /(<img.*?>)/gi;
str = str.replace(regex, "");
regex = /&#228;/gi;
str = str.replace(regex, "ä");
regex = /&#246;/gi;
str = str.replace(regex, "ö");
regex = /&#252;/gi;
str = str.replace(regex, "ü");
regex = /&#196;/gi;
str = str.replace(regex, "Ä");
regex = /&#214;/gi;
str = str.replace(regex, "Ö");
regex = /&#220;/gi;
str = str.replace(regex, "Ü");
regex = /&#223;/gi;
str = str.replace(regex, "ß");

return str;
}

XmlListModel {
id: xmlModel
source: url
query: "/rss/channel/item"

XmlListModelRole { name: "title"; elementName: "title" }
XmlListModelRole { name: "pubDate"; elementName: "pubDate" }
XmlListModelRole { name: "description"; elementName: "description" }
XmlListModelRole { name: "link"; elementName: "link" }

onStatusChanged: busyIndicator.running = true
}

Component {
id: feedDelegate
Rectangle {
height: layout.height
width: thefeed.width
color: PlasmaCore.Theme.viewBackgroundColor
Component.onCompleted: busyIndicator.running = false

Item {
height: layout.height
width: thefeed.width

Column {
id: layout
Row {
Text {
width: thefeed.width
wrapMode: Text.WordWrap
font.pixelSize: 12
color: PlasmaCore.Theme.textColor
font.bold: true
text: title
}
}
Row {
Text {
width: thefeed.width
wrapMode: Text.WordWrap
font.pixelSize: 9
color: headerColor
font.bold: false
text: pubDate
}
}
Row {
Text {
width: thefeed.width
wrapMode: Text.WordWrap
font.pixelSize: 12
color: PlasmaCore.Theme.textColor
font.bold: false
text: stripString(description)
}
}
Row {
Rectangle {
width: thefeed.width
color: PlasmaCore.Theme.textColor
height: 1
}
}
}

MouseArea {
acceptedButtons: Qt.LeftButton
anchors.fill: parent
onClicked: {
Qt.openUrlExternally(link)
}
}
}
}
}

Component {
id: header
Rectangle {
width: thefeed.width
height: 19
color: PlasmaCore.Theme.viewBackgroundColor
Item {
width: thefeed.width
height: 19
Text {
horizontalAlignment: Text.AlignRight
width: thefeed.width
height: 8
font.pixelSize: 9
text: url
color: headerColor
}

Rectangle {
y: 11
width: thefeed.width
height: 8
color: headerColor
}
}
}
}

Component {
id: footer
Rectangle {
width: thefeed.width
height: 8
color: headerColor
}
}

ListView {
id: thefeed
opacity: listOpacity / 100
maximumFlickVelocity: 2500
clip: true
width: parent.width-20
anchors.fill: parent
spacing: 2
model: xmlModel
delegate: feedDelegate
header: header
footer: footer
snapMode: ListView.SnapToItem
}

BusyIndicator {
id: busyIndicator
running: true
anchors.centerIn: parent
}

Timer {
id: refreshTimer
interval: refresh
running: true
repeat: true
onTriggered: { xmlModel.reload() }
}

Plasmoid.contextualActions: [
PlasmaCore.Action {
text: i18n("Refresh")
icon.name: "view-refresh"
onTriggered: xmlModel.reload()
}
]
}
95 changes: 95 additions & 0 deletions package/contents/ui/config/ConfigGeneral.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import QtQuick 2.15
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs

Item {
property alias cfg_refresh: refresh.value
property alias cfg_url: url.text
property alias cfg_headerColor: headerColorDialog.selectedColor
property alias cfg_listOpacity: listOpacity.value

GridLayout {
id: generalConfig
Layout.fillWidth: true
rowSpacing: 10
columnSpacing: 10
columns: 2

Text {
text: "Reload time (seconds)"
}
SpinBox {
id: refresh
from: 1
to: 1800
}
Text {
text: "URL"
}
TextField {
id: url
Layout.fillWidth: true
Layout.minimumWidth: 400
placeholderText: "http://www.faz.net/rss/aktuell/"
}

Text {
text: "Header Color"
}
Rectangle {
id: headerColor
width: 50
height: 17
color: headerColorDialog.selectedColor
border.color: "black"
border.width: 1
radius: 0
MouseArea{
anchors.fill: parent
onClicked: { headerColorDialog.open() }
}
}

Text {
text: "Opacity"
}
SpinBox {
id: listOpacity
from: decimalToInt(0)
to: decimalToInt(1)
value: decimalToInt(0.85)
stepSize: decimalToInt(0.05)

property int decimals: 2
property real realValue: value / decimalFactor
readonly property int decimalFactor: Math.pow(10, decimals)

function decimalToInt(decimal) {
return decimal * decimalFactor
}

validator: DoubleValidator {
bottom: listOpacity.from
top: listOpacity.to
decimals: listOpacity.decimals
notation: DoubleValidator.StandardNotation
}

textFromValue: function(value, locale) {
return Number(value / decimalFactor).toLocaleString(locale, 'f', decimals)
}

valueFromText: function(value, locale) {
return Math.round(Number.fromLocaleString(locale, text) * decimalFactor)
}
}
}

ColorDialog {
id: headerColorDialog
title: "Please choose a header color"
selectedColor: "Steel Blue"
onAccepted: headerColor.color = selectedColor
}
}
8 changes: 8 additions & 0 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import QtQuick 2.15
import org.kde.plasma.plasmoid

PlasmoidItem {
id: main
fullRepresentation: FullRepresentation {
}
}
25 changes: 25 additions & 0 deletions package/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"KPackageStructure": "Plasma/Applet",
"KPlugin": {
"Authors": [
{
"Name": "Jed Liu"
},
{
"Name": "Mircea Kitsune"
},
{
"Name": "Andreas Loos"
}
],
"Category": "Online Services",
"Description": "RSS feed reader",
"Icon": "rss",
"Id": "com.github.liujed.rssfeeds",
"Name": "RSS feeds",
"Version": "0.4",
"License": "GPL2",
"Website": "https://github.com/liujed/plasma-applet-rss-feeds"
},
"X-Plasma-API-Minimum-Version": "6.0"
}

0 comments on commit 16abff7

Please sign in to comment.