add_subdirectory(notes)
add_subdirectory(nowplaying)
add_subdirectory(previewer)
-add_subdirectory(rssnow)
add_subdirectory(spellcheck)
add_subdirectory(timer)
add_subdirectory(eyes)
+++ /dev/null
-project(plasma-rssnow)
-set(news_SRCS
- news.cpp
- header.cpp
- single-feed.cpp
- scroller.cpp
- config.ui
- feedsConfig.ui
-)
-
-kde4_add_plugin(plasma_applet_rssnow ${news_SRCS})
-target_link_libraries(plasma_applet_rssnow ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS})
-
-install(TARGETS plasma_applet_rssnow DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
-install(FILES plasma-applet-rssnow.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
-install(FILES feeds DESTINATION ${KDE4_DATA_INSTALL_DIR}/rssnow)
-install(FILES
- arrows.svgz
- rssnow.svgz
- background.svgz
- DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/rssnow/)
+++ /dev/null
-#! /usr/bin/env bash
-$EXTRACTRC *.ui >> rc.cpp
-$XGETTEXT *.cpp -o $podir/plasma_applet_rssnow.pot
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>config</class>
- <widget class="QWidget" name="config">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>258</width>
- <height>223</height>
- </rect>
- </property>
- <property name="styleSheet">
- <string notr="true"/>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Appearance</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Show drop target:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>showDropTarget</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QCheckBox" name="showDropTarget">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="3" rowspan="7">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>2</width>
- <height>188</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Show logo:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>logo</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QCheckBox" name="logo">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Animations:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>animations</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="QCheckBox" name="animations">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_8">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>News</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Update interval:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>intervalSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="2">
- <widget class="KIntSpinBox" name="intervalSpinBox">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>525600</number>
- </property>
- <property name="value">
- <number>30</number>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Switch interval:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>switchInterval</cstring>
- </property>
- </widget>
- </item>
- <item row="6" column="2">
- <widget class="KIntSpinBox" name="switchInterval">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>525600</number>
- </property>
- <property name="value">
- <number>30</number>
- </property>
- </widget>
- </item>
- <item row="7" column="0" colspan="2">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Maximum age of items:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>maxAge</cstring>
- </property>
- </widget>
- </item>
- <item row="7" column="2">
- <widget class="KIntSpinBox" name="maxAge">
- <property name="specialValueText">
- <string>No limit</string>
- </property>
- <property name="maximum">
- <number>525600</number>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-/*
- * Copyright 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef FEEDDATA_HEADER
-#define FEEDDATA_HEADER
-
-class KIcon;
-#include <QString>
-
-class FeedData
-{
- public:
- FeedData() : icon(0), itemNumber(0) {};
- QString text;
- QString title;
- QString url;
- QString extrainfo;
- KIcon *icon;
- int itemNumber;
- uint time;
-};
-
-#endif
+++ /dev/null
-[feeds]
-Latest KDE News=http://www.kde.org/dotkdeorg.rdf
-Latest KDE Applications=http://www.kde.org/dot/kde-apps-content.rdf
-Planet KDE=http://planetKDE.org/rss20.xml
-KDE-Look.org Content=http://www.kde.org/kde-look-content.rdf
-Slashdot=http://rss.slashdot.org/Slashdot/slashdot
-KernelTrap=http://kerneltrap.org/node/feed
-Linux Today=http://www.linuxtoday.com/biglt.rss
+++ /dev/null
-<ui version="4.0" >
- <class>feedsConfig</class>
- <widget class="QWidget" name="feedsConfig" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>502</width>
- <height>228</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout" >
- <item row="0" column="0" >
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <item>
- <widget class="QLabel" name="label_1" >
- <property name="text" >
- <string>&Add a feed:</string>
- </property>
- <property name="buddy" >
- <cstring>feedComboBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KHistoryComboBox" name="feedComboBox" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="autoCompletion" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" >
- <layout class="QHBoxLayout" >
- <item>
- <widget class="KListWidget" name="feedList" />
- </item>
- <item>
- <layout class="QGridLayout" name="_2" >
- <property name="spacing" >
- <number>1</number>
- </property>
- <item row="0" column="0" >
- <widget class="KPushButton" name="addFeed" >
- <property name="text" >
- <string>Add Feed</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="KPushButton" name="removeFeed" >
- <property name="text" >
- <string>Remove Feed</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>KHistoryComboBox</class>
- <extends>KComboBox</extends>
- <header>khistorycombobox.h</header>
- </customwidget>
- <customwidget>
- <class>KListWidget</class>
- <extends>QListWidget</extends>
- <header>klistwidget.h</header>
- </customwidget>
- <customwidget>
- <class>KPushButton</class>
- <extends>QPushButton</extends>
- <header>kpushbutton.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-#ifndef HEADER_CPP
-#define HEADER_CPP
-/*
- * Copyright 2007, 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "header.h"
-#include <kdebug.h>
-#include <kicon.h>
-#include <QPainter>
-#include <QtGui/qstyleoption.h>
-#include <QGraphicsWidget>
-#include <plasma/svg.h>
-
-using namespace Plasma;
-
-Header::Header(QGraphicsItem *parent) :
- QGraphicsWidget(parent),
- m_icon(0)
-{
- setMaximumSize(QSizeF(600, 48));
- setMinimumSize(QSizeF(100, 48));
-
- m_icon = new Plasma::Svg(this);
- m_icon->setImagePath("rssnow/rssnow");
- m_icon->resize(96, 48);
- m_icon->setContainsMultipleImages(false);
-
- setPreferredSize(QSizeF(300, 48));
- setMinimumSize(QSizeF(96, 48));
- setMaximumSize(QSizeF(1000, 48));
-}
-
-void Header::paint(QPainter *p,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_UNUSED(widget);
- Q_UNUSED(option);
-
- p->setRenderHint(QPainter::SmoothPixmapTransform);
-
- m_icon->paint( p, 0, 0, "RSSNOW" );
-}
-
-#include "moc_header.cpp"
-#endif // HEADER.CPP
-
+++ /dev/null
-/*
- * Copyright (C) 2007 Petri Damsten <damu@iki.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef HEADER_HEADER
-#define HEADER_HEADER
-
-#include <QGraphicsWidget>
-#include <plasma/plasma_export.h>
-
-namespace Plasma
-{
- class Svg;
-} // namespace Plasma
-
-
-class Header : public QGraphicsWidget
-{
- Q_OBJECT
-
-public:
- Header(QGraphicsItem *parent = 0);
-
-
-protected:
- virtual void paint(QPainter *p,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget = 0);
- Plasma::Svg *m_icon;
-};
-
-#endif
+++ /dev/null
-/*
- * Copyright 2007, 2008 Petri Damsten <damu@iki.fi>
- * Copyright 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// This applet is based on the news applet from petri damsten.
-
-//Own
-#include "news.h"
-#include "scroller.h"
-#include "header.h"
-
-//QT
-#include <QtGui/qgraphicssceneevent.h>
-#include <QGraphicsLinearLayout>
-#include <QTimer>
-#include <QtXml/qdom.h>
-#include <QFile>
-#include <QLineEdit>
-
-//KDE
-#include <kdebug.h>
-#include <kglobal.h>
-#include <kicon.h>
-#include <kconfigdialog.h>
-#include <KStandardDirs>
-
-//Plasma
-#include <plasma/containment.h>
-
-News::News(QObject *parent, const QVariantList &args)
- : Plasma::Applet(parent, args),
- m_collapsed(false)
-{
- setHasConfigurationInterface(true);
- setBackgroundHints(DefaultBackground);
- setAcceptDrops(true);
- setAspectRatioMode( Plasma::IgnoreAspectRatio );
-
- resize(300,300);
-}
-
-News::~News()
-{
-}
-
-void News::init()
-{
- m_layout = new QGraphicsLinearLayout(Qt::Vertical, this);
- m_layout->setSpacing(2);
- setLayout(m_layout);
-
- m_header = new Header(this);
- m_timer = new QTimer(this);
-
- setAssociatedApplication("akregator");
-
- configChanged();
-
- connect(m_timer, SIGNAL(timeout()), this, SLOT(switchItems()));
-}
-
-void News::configChanged()
-{
- KConfigGroup cg = config();
-
- m_interval = cg.readEntry("interval", 30);
- m_switchInterval = cg.readEntry("switchInterval", 10);
- m_logo = cg.readEntry("logo", true);
- m_maxAge = cg.readEntry("maxAge", 0);
- m_animations = cg.readEntry("animations", true);
- m_showdroptarget = cg.readEntry("droptarget", true);
- m_feedlist = cg.readEntry("feeds", QStringList("http://dot.kde.org/rss.xml"));
-
- updateScrollers();
-}
-
-void News::switchItems()
-{
- int delay = 1;
- int start = 0;
- if (m_logo) {
- start = 1;
- }
- for (int i = start; i < m_layout->count(); i++ ){
- Scroller * scroller = (Scroller *) m_layout->itemAt(i);
- if (!scroller->hovering()) {
- scroller->delayedMoveNext(delay++ * 100);
- }
- }
-}
-
-void News::connectToEngine()
-{
- int i = 0;
-
- if (!m_feedlist.isEmpty()) {
- Plasma::DataEngine* engine = dataEngine("rss");
-
- int maxScroller = m_scrollerList.size();
- if (m_showdroptarget) {
- maxScroller--;
- }
- foreach (Scroller * scroller, m_scrollerList) {
- if (i < maxScroller) {
- kDebug() << "Connect to source: " << m_feedlist.at(i);
- engine->connectSource(m_feedlist.at(i++), scroller,
- m_interval * 60 * 1000);
- }
- }
- }
-}
-
-void News::createConfigurationInterface(KConfigDialog *parent)
-{
- //TODO: we probably want to disable the add button until there's actually
- //an url in the combobox.
- QWidget *widget = new QWidget(0);
- ui.setupUi(widget);
- QWidget *fWidget = new QWidget(0);
- feedsUi.setupUi(fWidget);
- connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
- connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
- connect(feedsUi.addFeed, SIGNAL(clicked()), this, SLOT(addFeed()));
- connect(feedsUi.removeFeed, SIGNAL(clicked()), this, SLOT(removeFeed()));
- connect(feedsUi.feedList, SIGNAL(itemSelectionChanged()), this, SLOT(slotItemChanged()));
- connect(feedsUi.feedComboBox->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(slotChangeText(QString)) );
- feedsUi.removeFeed->setEnabled( false );
- KConfig feedsFile(QString("news/feeds"), KConfig::FullConfig, "data");
- m_defaultFeeds = feedsFile.group("feeds").entryMap();
- feedsUi.addFeed->setEnabled( false );
- feedsUi.feedComboBox->clear();
- feedsUi.feedList->clear();
- foreach (const QString& name, m_defaultFeeds.keys()) {
- feedsUi.feedComboBox->addItem(name);
- }
-
- foreach (const QString& name, akregatorFeeds()) {
- feedsUi.feedComboBox->addItem(name);
- }
-
- ui.intervalSpinBox->setValue(m_interval);
- ui.intervalSpinBox->setSuffix(ki18np(" minute", " minutes"));
- ui.switchInterval->setValue(m_switchInterval);
- ui.switchInterval->setSuffix(ki18np(" second", " seconds"));
- ui.maxAge->setValue(m_maxAge);
- ui.maxAge->setSuffix(ki18np(" hour", " hours"));
- if (m_logo) {
- ui.logo->setCheckState(Qt::Checked);
- } else {
- ui.logo->setCheckState(Qt::Unchecked);
- }
- if (m_animations) {
- ui.animations->setCheckState(Qt::Checked);
- } else {
- ui.animations->setCheckState(Qt::Unchecked);
- }
- if (m_showdroptarget) {
- ui.showDropTarget->setCheckState(Qt::Checked);
- } else {
- ui.showDropTarget->setCheckState(Qt::Unchecked);
- }
-
- feedsUi.feedList->addItems(m_feedlist);
- parent->addPage(widget, i18n("General"), icon());
- parent->addPage(fWidget, i18n("Feeds"), icon());
-
- connect(ui.showDropTarget, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
- connect(ui.logo, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
- connect(ui.animations, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
- connect(ui.intervalSpinBox, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
- connect(ui.switchInterval, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
- connect(ui.maxAge, SIGNAL(valueChanged(QString)), parent, SLOT(settingsModified()));
- connect(feedsUi.feedComboBox, SIGNAL(editTextChanged(QString)), parent, SLOT(settingsModified()));
- connect(feedsUi.addFeed, SIGNAL(released()), parent, SLOT(settingsModified()));
- connect(feedsUi.removeFeed, SIGNAL(released()), parent, SLOT(settingsModified()));
- connect(feedsUi.feedList, SIGNAL(itemSelectionChanged()), parent, SLOT(settingsModified()));
-}
-
-void News::slotChangeText( const QString& text )
-{
- feedsUi.addFeed->setEnabled( !text.isEmpty() );
-}
-
-void News::slotItemChanged()
-{
- feedsUi.removeFeed->setEnabled( ( !feedsUi.feedList->selectedItems ().isEmpty() ) );
-}
-
-void News::addFeed()
-{
- if (!feedsUi.feedComboBox->currentText().isEmpty()) {
- QString url = feedsUi.feedComboBox->currentText();
- if (m_defaultFeeds.keys().contains(url)) {
- url = m_defaultFeeds[url];
- }
- bool found = false;
- for (int i = 0; i < feedsUi.feedList->count(); i++) {
- QString feed = feedsUi.feedList->item(i)->text();
- if (feed == url) {
- found = true;
- }
- }
- if (!found) {
- feedsUi.feedList->addItem(url);
- }
- }
-}
-
-void News::removeFeed()
-{
- int row = feedsUi.feedList->currentRow();
- if (row != -1) {
- feedsUi.feedList->takeItem(row);
- if (feedsUi.feedList->count() == 0) {
- feedsUi.removeFeed->setEnabled(false);
- }
- }
-}
-
-void News::configAccepted()
-{
- m_interval = ui.intervalSpinBox->value();
- m_switchInterval = ui.switchInterval->value();
- m_maxAge = ui.maxAge->value();
- m_logo = ui.logo->isChecked();
- m_animations = ui.animations->isChecked();
- m_showdroptarget = ui.showDropTarget->isChecked();
-
- m_feedlist.clear();
- QString feed;
- for (int i = 0; i < feedsUi.feedList->count(); i++) {
- feed = feedsUi.feedList->item(i)->text();
- if (m_defaultFeeds.keys().contains(feed)) {
- feed = m_defaultFeeds[feed];
- }
- m_feedlist.append(feed);
- }
-
- KConfigGroup cg = config();
- cg.writeEntry("feeds", m_feedlist);
- cg.writeEntry("interval", m_interval);
- cg.writeEntry("switchInterval", m_switchInterval);
- cg.writeEntry("animations", m_animations);
- cg.writeEntry("logo", m_logo);
- cg.writeEntry("droptarget", m_showdroptarget);
- cg.writeEntry("maxAge", m_maxAge);
-
- emit configNeedsSaving();
-
- // updateScrollers() is already called from configChanged(), which will
- // always be called after this method when the config dialog is applied
-}
-
-void News::updateScrollers()
-{
- m_timer->stop();
- m_timer->setInterval(m_switchInterval * 1000);
-
- m_layout = new QGraphicsLinearLayout(Qt::Vertical, this);
- m_layout->setSpacing(2);
- setLayout(m_layout);
-
- if (m_logo) {
- m_layout->addItem(m_header);
- m_header->show();
- } else {
- m_header->hide();
- }
-
- qDeleteAll(m_scrollerList);
- m_scrollerList.clear();
- for (int i = 0; i < m_feedlist.size(); i++ ) {
- Scroller * scroller = new Scroller(this);
- m_layout->addItem(scroller);
- m_scrollerList.append(scroller);
- scroller->setAnimations(m_animations);
- scroller->setMaxAge(m_maxAge);
- scroller->listUpdated();
- }
-
- if (m_showdroptarget) {
- Scroller * scroller = new Scroller(this);
- m_scrollerList.append(scroller);
- m_layout->addItem(scroller);
- scroller->setAnimations(m_animations);
- scroller->setDropTarget(true);
- scroller->setMaxAge(m_maxAge);
- scroller->listUpdated();
- }
-
-
- foreach (Scroller *scroller, m_scrollerList) {
- m_layout->addItem(scroller);
- }
-
- m_timer->start();
- connectToEngine();
-}
-
-//TODO: move to scroller to make adding to existing groups by dropping
-//possible.
-void News::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
- kDebug() << "dropEvent()";
- if (KUrl::List::canDecode(event->mimeData())) {
- KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
-
- if (urls.count() > 0) {
- event->accept();
-
- //FIXME: yeah, using strings her is ugly, but nested lists give
- //issues with KConfigGroup. This could be done better though.
- // it causes bugs, too! see the spiegel.de rss which url contains ","
- // i have fixed the rss dataengine as well so now " " is standard
- QString feeds;
- foreach (const KUrl& feed, urls){
- feeds.append(QString(feed.prettyUrl()));
- feeds.append(" ");
- }
-
- int start = 0;
- if (m_logo) {
- start = 1;
- }
-
- //ok, let's just temporarily disable this, since this has to be
- //ported to WoC, and is less trivial at a glance.
- for (int i = start; i < (m_layout->count()); i++ ) {
- QGraphicsLayoutItem * item = m_layout->itemAt(i);
- QRectF rect = item->geometry();
- if (rect.contains(event->pos())) {
- if (m_showdroptarget && (i == (m_layout->count() - 1))) {
- m_feedlist.append(feeds);
- } else {
- if (!m_feedlist[i-start].endsWith(' ')) {
- m_feedlist[i-start].append(" ");
- }
- m_feedlist[i-start].append(feeds);
- }
- }
- }
-
- KConfigGroup cg = config();
- cg.writeEntry("feeds", m_feedlist);
- emit configNeedsSaving();
-
- updateScrollers();
- }
- }
-}
-
-void News::constraintsEvent(Plasma::Constraints constraints)
-{
- //kDebug() << "constrainsUpdated : " << constraints;
- if (constraints & Plasma::FormFactorConstraint || constraints & Plasma::SizeConstraint ) {
- if (formFactor() == Plasma::Horizontal) {
- int minSize = (m_feedlist.size() * m_scrollerList.first()->minimumSize().height()) + m_header->size().height();
- //kDebug() << "minimum size to contain all scrollers: " << minSize << m_feedlist;
- if (contentsRect().height() < minSize) {
- //group all feeds together so it can fit (only a single time):
- QString allfeeds;
- foreach (const QString &feed, m_feedlist) {
- allfeeds.append(feed);
- if (!feed.endsWith(' ')) {
- allfeeds.append(" ");
- }
- }
- kDebug() << "allfeeds = " << allfeeds;
- m_feedlist.clear();
- m_feedlist.append(allfeeds);
- m_showdroptarget = false;
- m_logo = false;
- m_collapsed = true;
- updateScrollers();
- } else {
- m_collapsed = false;
- updateScrollers();
- }
- }
- }
-}
-
-QMap<QString, QString> News::akregatorFeeds()
-{
- QMap<QString, QString> result;
- QString file = KStandardDirs::locate("data", "akregator/data/feeds.opml");
- kDebug() << file;
- if (!file.isEmpty()) {
- QFile f(file);
- if (f.open(QIODevice::ReadOnly)) {
- QDomDocument doc;
- if (doc.setContent(&f)) {
- QDomNodeList nodes = doc.elementsByTagName("outline");
- for (int i = 0; i < nodes.count(); ++i) {
- QDomElement element = nodes.item(i).toElement();
- QString title = element.attribute("title");
- if (!title.isEmpty()) {
- result[title] = element.attribute("xmlUrl");
- }
- }
- }
- f.close();
- }
- }
- return result;
-}
-
-#include "moc_news.cpp"
+++ /dev/null
-/*
- * Copyright 2007, 2008 Petri Damsten <damu@iki.fi>
- * Copyright 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NEWS_HEADER
-#define NEWS_HEADER
-
-//Plasma
-#include <Plasma/Applet>
-#include <Plasma/DataEngine>
-
-#include <QTimer>
-
-//Own
-#include "ui_config.h"
-#include "ui_feedsConfig.h"
-#include "header.h"
-#include "feeddata.h"
-
-
-class Scroller;
-#include <QGraphicsLinearLayout>
-
-class News : public Plasma::Applet
-{
- Q_OBJECT
- public:
- News(QObject *parent, const QVariantList &args);
- ~News();
-
- void init();
-
- public slots:
- void configChanged();
- void createConfigurationInterface(KConfigDialog *parent);
- void switchItems();
-
- protected:
- void constraintsEvent(Plasma::Constraints constraints);
-
- protected Q_SLOTS:
- void dropEvent(QGraphicsSceneDragDropEvent *event);
-
- private slots:
- void configAccepted();
- void addFeed();
- void removeFeed();
- void slotItemChanged();
- void slotChangeText( const QString& text );
-
- private:
- QStringList m_feedlist;
- QList<Scroller *> m_scrollerList;
- QTimer *m_timer;
-
- uint m_interval;
- uint m_switchInterval;
-
- bool m_animations;
- bool m_logo;
- bool m_showdroptarget;
- bool m_collapsed;
-
- int m_maxAge;
-
- QGraphicsLinearLayout *m_layout;
- Header *m_header;
- Ui::config ui;
- Ui::feedsConfig feedsUi;
-
- QMap<QString, QString> m_defaultFeeds;
- QMap<QString, QString> akregatorFeeds();
-
- void connectToEngine();
- void updateScrollers();
- QString fuzzyDate(const QDateTime& date);
-};
-
-K_EXPORT_PLASMA_APPLET(rssnow, News)
-
-#endif
+++ /dev/null
-[Desktop Entry]
-Name=RSSNOW
-Name[ar]=RSSNOW
-Name[ast]=RSSNOW
-Name[bs]=RSSNOW
-Name[ca]=RSSNOW
-Name[ca@valencia]=RSSNOW
-Name[cs]=RSSNOW
-Name[da]=RSSNOW
-Name[de]=RSSNOW
-Name[el]=RSSNOW
-Name[en_GB]=RSSNOW
-Name[eo]=RSSNOW
-Name[es]=RSSNOW
-Name[et]=RSSNOW
-Name[eu]=RSSNOW
-Name[fi]=RSSNOW
-Name[fr]=RSSNOW
-Name[ga]=RSSNOW
-Name[gl]=RSSNOW
-Name[he]=RSSNOW
-Name[hr]=RSSNOW
-Name[hu]=RSSNOW
-Name[is]=RSSNOW
-Name[it]=RSSNOW
-Name[ja]=RSSNOW
-Name[kk]=RSSNOW
-Name[km]=RSSNOW
-Name[ko]=RSSNOW
-Name[ku]=RSSNOW
-Name[lt]=RSSNOW
-Name[lv]=RSSNOW
-Name[mr]=RSSNOW
-Name[nb]=RSSNOW
-Name[nds]=RSSNOW
-Name[nl]=RSSNOW
-Name[nn]=RSSNOW
-Name[pa]=RSSNOW
-Name[pl]=RSSNOW
-Name[pt]=RSSNOW
-Name[pt_BR]=RSSNOW
-Name[ro]=RSSNOW
-Name[ru]=RSSNOW
-Name[sk]=RSSNOW
-Name[sl]=RSSNOW
-Name[sq]=RSSNOW
-Name[sr]=РСС‑одмах
-Name[sr@ijekavian]=РСС‑одмах
-Name[sr@ijekavianlatin]=RSS‑odmah
-Name[sr@latin]=RSS‑odmah
-Name[sv]=RSSNOW
-Name[tr]=RSSNOW
-Name[uk]=RSSNOW
-Name[wa]=RSSNOW
-Name[x-test]=xxRSSNOWxx
-Name[zh_CN]=RSSNOW
-Name[zh_TW]=RSSNOW
-Comment=Show news from various sources
-Comment[ar]=أظهر الأخبار من مصادر متعددة
-Comment[ast]=Amuesa noticies de delles fontes
-Comment[bs]=Prikazuje vijesti iz različitih izvora
-Comment[ca]=Mostra les notícies de diverses fonts
-Comment[ca@valencia]=Mostra les notícies de diverses fonts
-Comment[cs]=Zobrazit novinky z různých zdrojů
-Comment[da]=Viser nyheder fra forskellige kilder.
-Comment[de]=Neuigkeiten aus verschiedenen Quellen anzeigen
-Comment[el]=Εμφάνιση ειδήσεων από διάφορες πηγές
-Comment[en_GB]=Show news from various sources
-Comment[es]=Muestra noticias de varias fuentes
-Comment[et]=Mitmest allikast uudiste näitamine
-Comment[eu]=Erakutsi iturburu desberdinetako berriak
-Comment[fi]=Näyttää uutisia useista eri lähteistä
-Comment[fr]=Affiche des nouvelles depuis diverses sources
-Comment[ga]=Taispeáin nuacht ó fhoinsí éagsúla
-Comment[gl]=Mostra as novas de varias fontes.
-Comment[he]=מציג חדשות ממקורות שונים
-Comment[hr]=Prikaži vijesti iz raznih izvora
-Comment[hu]=Különböző forrásból származó hírek megjelenítése
-Comment[is]=Sýna fréttir frá mismunandi uppruna
-Comment[it]=Mostra notizie da varie fonti
-Comment[ja]=さまざまなソースからニュースを表示します
-Comment[kk]=Түрлі көздерден келген жаңалықтарды көрсету
-Comment[km]=បង្ហាញព័ត៌មានពីប្រភពផ្សេងៗ
-Comment[ko]=다양한 뉴스 보여주기
-Comment[ku]=Jê çavkaniyên cur bi cur nûçe yan nîşan bide
-Comment[lt]=Rodo naujienas iš įvairių šaltinių
-Comment[lv]=Rāda ziņas no dažādiem avotiem
-Comment[mr]=विविध स्रोतातून बातम्या दर्शवा
-Comment[nb]=Vis nyheter fra ymse kilder
-Comment[nds]=Narichten vun verscheden Borns wiesen
-Comment[nl]=Toont nieuws van verschillende bronnen
-Comment[nn]=Vis nyheiter frå ulike kjelder
-Comment[pa]=ਕਈ ਸਰੋਤਾਂ ਤੋਂ ਖ਼ਬਰਾਂ ਵੇਖੋ
-Comment[pl]=Wyświetlanie nowości z różnych źródeł
-Comment[pt]=Mostra as notícias de várias fontes
-Comment[pt_BR]=Mostra notícias de várias fontes
-Comment[ro]=Afișează noutăți din diverse surse
-Comment[ru]=Показывает новости из различных источников
-Comment[sk]=Zobrazenie noviniek z rôznych zdrojov
-Comment[sl]=Prikaže novice iz različnih virov
-Comment[sr]=Приказује вести из различитих извора
-Comment[sr@ijekavian]=Приказује вијести из различитих извора
-Comment[sr@ijekavianlatin]=Prikazuje vijesti iz različitih izvora
-Comment[sr@latin]=Prikazuje vesti iz različitih izvora
-Comment[sv]=Visa nyheter från olika källor
-Comment[th]=แสดงข่าวต่าง ๆ จากแหล่งข่าวหลาย ๆ ที่
-Comment[tr]=Çeşitli kaynaklardan haberleri göster
-Comment[uk]=Показати новини від різноманітних джерел
-Comment[wa]=Mostrer des noveles a pårti d' sacwants sourdants
-Comment[x-test]=xxShow news from various sourcesxx
-Comment[zh_CN]=从多个来源显示新闻
-Comment[zh_TW]=顯示不同的來源的新聞
-Type=Service
-Icon=application-rss+xml
-ServiceTypes=Plasma/Applet
-
-X-KDE-Library=plasma_applet_rssnow
-X-KDE-PluginInfo-Author=Rob Scheepmaker
-X-KDE-PluginInfo-Email=r.scheepmaker@student.utwente.nl
-X-KDE-PluginInfo-Name=rssnow
-X-KDE-PluginInfo-Version=1.0
-X-KDE-PluginInfo-Website=http://plasma.kde.org/
-X-KDE-PluginInfo-Category=Online Services
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=true
-
+++ /dev/null
-#ifndef SCROLLER_CPP
-#define SCROLLER_CPP
-/*
- * Copyright 2007, 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "scroller.h"
-#include "single-feed.h"
-#include "feeddata.h"
-
-#include <kdebug.h>
-#include <kicon.h>
-#include <ktoolinvocation.h>
-#include <QGraphicsItem>
-#include <QDateTime>
-#include <QTimer>
-#include <QList>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/qgraphicssceneevent.h>
-#include <QPropertyAnimation>
-#include <plasma/widgets/iconwidget.h>
-#define BTN_SIZE 20
-
-using namespace Plasma;
-
-Scroller::Scroller(QGraphicsItem *parent) :
- QGraphicsWidget(parent),
- m_current(0),
- m_animations(true),
- m_delayedNext(0),
- m_delayedPrev(0),
- m_maxAge(0),
- m_droptarget(false),
- m_left(new Plasma::IconWidget(this)),
- m_right(new Plasma::IconWidget(this)),
- m_isAnimating(false)
-{
-
- setAcceptedMouseButtons(Qt::LeftButton);
- setAcceptHoverEvents(true);
- setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
-
- m_hovered = false;
-
- m_left->setSvg("rssnow/arrows", "left");
- m_left->setZValue(1000);
- m_left->resize(m_left->sizeFromIconSize(10));
- m_left->hide();
-
- m_right->setSvg("rssnow/arrows", "right");
- m_right->setZValue(1000);
- m_right->resize(m_right->sizeFromIconSize(10));
- m_right->hide();
-
- m_feedIcons["generic"] = new KIcon("application-rss+xml");
-
- connect(m_left, SIGNAL(clicked()), this, SLOT(leftClicked()));
- connect(m_right, SIGNAL(clicked()), this, SLOT(rightClicked()));
-}
-
-Scroller::~Scroller()
-{
- qDeleteAll(m_feedIcons);
-}
-
-QList<FeedData> Scroller::list()
-{
- return m_list;
-}
-
-bool Scroller::hovering() const
-{
- return m_hovered;
-}
-
-bool Scroller::dropTarget() const
-{
- return m_droptarget;
-}
-
-void Scroller::setDropTarget(bool droptarget)
-{
- m_droptarget = droptarget;
- updateGeometry();
-}
-
-void Scroller::listUpdated()
-{
- if (m_droptarget && m_list.isEmpty()) {
- FeedData data;
- data.title = i18n("Drop a feed here...");
- data.extrainfo = i18n("Drop a feed here...");
- //TODO: the wording of this phrase could be better:
- data.text = i18n("...to start a new group or drop a feed on an existing group to add the feed there");
- data.icon = m_feedIcons["generic"];
- m_list.append(data);
- }
-
- if (m_list.isEmpty()) { //the item is fetching feeds atm
- FeedData data;
- data.title = i18n("Fetching feeds");
- data.extrainfo = i18n("Fetching feeds");
- data.icon = m_feedIcons["generic"];
- m_list.append(data);
- }
-
- if (m_current > (m_list.size() - 1) && !m_list.isEmpty()) {
- //feed has grown smaller, just display the first item.
- //kDebug() << "feed has grown smaller";
- m_current = 0;
- }
-
- //TODO: it would be neat if the actual contents of the feeditems
- //was checked so after an update the same item is displayed.
- if (m_itemlist.size() < 1) {
- SingleFeedItem * item = new SingleFeedItem(this);
- item->setFeedData(m_list.at(m_current));
- item->setZValue(0);
- item->setPos(0, 0);
- item->show();
- m_itemlist.append(item);
- m_activeitemlist.append(item);
- } else {
- m_itemlist.at(m_itemlist.size() - 1)->setFeedData(m_list.at(m_current));
- }
-
- if (m_droptarget) {
- updateGeometry();
- }
-}
-
-void Scroller::delayedMoveNext(int delay)
-{
- QTimer::singleShot(delay, this, SLOT(moveNext()));
-}
-
-void Scroller::movePrev()
-{
- if (m_isAnimating) {
- m_delayedPrev++;
- } else {
- if (m_current > 0) {
- m_current--;
- } else {
- m_current = m_list.size() - 1;
- }
- doAnimation(QAbstractAnimation::Backward);
- }
-}
-
-void Scroller::moveNext()
-{
- if (m_isAnimating) {
- m_delayedNext++;
- } else {
- if (m_current < (m_list.size()-1)) {
- m_current++;
- } else {
- m_current = 0;
- }
- doAnimation(QAbstractAnimation::Forward);
- }
-}
-
-QSizeF Scroller::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
-{
- if (which == Qt::MinimumSize) {
- return QSizeF(100, 32);
- } else if (which == Qt::PreferredSize) {
- if (m_droptarget && !m_itemlist.isEmpty()) {
- SingleFeedItem *item = m_itemlist.at(0);
- const int w = constraint.width() < 1 ? (size().width() > 0 ? size().width() : 300) : constraint.width();
- QSizeF s(w, item->preferredHeight(w));
- return s;
- } else {
- return QSizeF(300, 56);
- }
- } else if (which == Qt::MaximumSize) {
- if (m_droptarget) {
- return QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
- } else {
- return QSizeF(600, 64);
- }
-
- }
-
- return QGraphicsWidget::sizeHint(which, constraint);
-}
-
-void Scroller::doAnimation(QAbstractAnimation::Direction direction)
-{
- if (m_list.size() > 1) {
- if (m_animations && !m_isAnimating) {
- SingleFeedItem * item = new SingleFeedItem(this);
- item->setFeedData(m_list.at(m_current));
- item->setDisplayExtra(m_hovered);
- item->setZValue(m_itemlist.size() + 1);
- item->show();
- item->setPos((direction == QAbstractAnimation::Forward? 1 : -1) * size().width(), 0);
- item->setRect(QRect(0, 0, size().width(), size().height()));
- if (!m_itemlist.contains(item)) {
- m_itemlist.append(item);
- m_activeitemlist.append(item);
- }
- //acellerate while scrolling:
- int frames, time, queuelength;
- if (m_delayedNext > 0) {
- queuelength = m_delayedNext + 1;
- } else {
- queuelength = m_delayedPrev + 1;
- }
- time = 400 / queuelength;
- frames = time / 40;
-
- QPropertyAnimation *animation = m_animation.data();
- if (!animation) {
- animation = new QPropertyAnimation(this, "animate");
- animation->setStartValue(0.0);
- animation->setEndValue(1.0);
- animation->setEasingCurve(QEasingCurve::InOutQuad);
- m_animation = animation;
- connect(animation, SIGNAL(finished()), this, SLOT(animationComplete()));
- } else if (animation->state() == QAbstractAnimation::Running) {
- animation->pause();
- }
-
- animation->setDuration(time);
- animation->setDirection(direction);
- if (m_delayedNext > 0 || m_delayedPrev > 0) {
- animation->start(QAbstractAnimation::KeepWhenStopped);
- } else {
- animation->start(QAbstractAnimation::DeleteWhenStopped);
- }
- m_isAnimating = true;
- } else {
- m_itemlist.at(m_itemlist.size() - 1)->setFeedData(m_list.at(m_current));
- }
- }
-}
-
-void Scroller::animationComplete()
-{
- m_isAnimating = false;
-
- m_activeitemlist.takeFirst(); //remove the first item.
- if (m_delayedNext > 0) {
- m_delayedPrev = 0;
- m_delayedNext--;
- QTimer::singleShot(50, this, SLOT(moveNext()));
- } else if (m_delayedPrev > 0) {
- m_delayedNext = 0;
- m_delayedPrev--;
- QTimer::singleShot(50, this, SLOT(movePrev()));
- } else if (m_itemlist.size() > 2) {
- QTimer::singleShot(0, this, SLOT(clearUnusedItems()));
- }
-}
-
-qreal Scroller::animValue() const
-{
- qreal xPosition = 0.0;
-
- foreach (SingleFeedItem *item, m_activeitemlist) {
- if (m_current == item->itemNumber()) {
- xPosition = item->pos().x();
- break;
- }
- }
-
- return xPosition;
-}
-
-void Scroller::animate(qreal value)
-{
- if (m_animation.isNull()) {
- return;
- }
-
- const int width = size().width();
- const bool isForward = m_animation.data()->direction() == QAbstractAnimation::Forward;
- int xPosition;
-
- foreach (SingleFeedItem * item, m_activeitemlist) {
- if (m_current == item->itemNumber()) {
- xPosition = (isForward ? 1 * (1-value) : -1 * value) * width;
- } else {
- xPosition = (1-value) * width + (isForward ? -1 * width : 0);
- }
- item->setX(xPosition);
- }
-}
-
-void Scroller::clearUnusedItems()
-{
- //Why is this so heavy on the resources? It makes all animations stutter.
- //So let's make sure we don't this this while animations are happening.
- foreach (SingleFeedItem * item, m_itemlist) {
- if (!m_activeitemlist.contains(item)) {
- m_itemlist.removeAll(item);
- delete item;
- }
- }
- m_itemlist.last()->setZValue(0);
-}
-
-void Scroller::setGeometry(const QRectF &geometry)
-{
- QGraphicsWidget::setGeometry(geometry);
- updateSize();
-}
-
-void Scroller::updateSize()
-{
- qreal width = geometry().width();
- qreal height = geometry().height();
- QRect rect(0, 0, width, height);
-
- if (!m_isAnimating) {
- foreach (SingleFeedItem *item, m_itemlist) {
- item->setRect(rect);
- }
- }
-
- if (m_left != 0) {
- m_left->setPos(width - m_left->geometry().width(),
- height - m_left->geometry().height());
- }
-
- if (m_right != 0) {
- m_right->setPos(width - m_right->geometry().width(), 0);
- }
-}
-
-void Scroller::wheelEvent(QGraphicsSceneWheelEvent *event)
-{
- if (event->delta() < 0) {
- moveNext();
- } else {
- movePrev();
- }
-}
-
-void Scroller::leftClicked()
-{
- movePrev();
-}
-
-void Scroller::rightClicked()
-{
- moveNext();
-}
-
-void Scroller::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_UNUSED(event);
-}
-
-void Scroller::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_UNUSED(event);
-
- QString url;
- if (m_current < m_list.size()) {
- url = m_list.at(m_current).url;
- }
-
- KToolInvocation::invokeBrowser(url);
-}
-
-void Scroller::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
- if (m_list.size() > 1) {
- m_left->show();
- m_right->show();
- }
- m_hovered = true;
- foreach (SingleFeedItem * item, m_activeitemlist) {
- item->setDisplayExtra(true);
- item->update();
- }
- update();
-}
-
-void Scroller::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
- if (m_list.size() > 1) {
- m_left->hide();
- m_right->hide();
- }
- m_hovered = false;
- foreach (SingleFeedItem * item, m_activeitemlist) {
- item->setDisplayExtra(false);
- item->update();
- }
- update();
-}
-
-void Scroller::setAnimations(bool animations)
-{
- m_animations = animations;
-}
-
-bool Scroller::animations() const
-{
- return m_animations;
-}
-
-void Scroller::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
-{
- if (!data.isEmpty()) {
- m_list.clear();
-
- //kDebug() << "feed " << source << " updated.";
- QVariantList items = data["items"].toList();
-
- foreach (const QVariant &tmp, items) {
- QMap<QString, QVariant> item = tmp.toMap();
- QString title = item["title"].toString();
- QString url = item["link"].toString();
- QString iconName = item["icon"].toString();
- QString feedtitle = item["feed_title"].toString();
- QString feedurl = item["feed_url"].toString();
-
- uint timestamp = item["time"].toUInt();
- QDateTime datetime;
- datetime.setTime_t(timestamp);
-
- if (!(timestamp > 0 && m_maxAge > 0 && //Only add if not too old
- datetime.addSecs(m_maxAge * 3600) < QDateTime::currentDateTime())) {
- FeedData data;
- data.text = title;
- data.title = feedtitle;
- data.url = url;
- data.time = timestamp;
-
- KIcon *icon = m_feedIcons.value(iconName);
- if (!icon) {
- QPixmap p = QPixmap(iconName);
- if (!p.isNull()) {
- icon = new KIcon(p.scaled(16, 16));
- m_feedIcons.insert(iconName, icon);
- }
- }
-
- if (icon) {
- data.icon = icon;
- } else {
- data.icon = m_feedIcons["generic"];
- }
-
- data.itemNumber = m_list.size();
- m_list.append(data);
- }
- }
-
- //TODO: separate this and use a timer to update fuzzyDate
- //every minute.
- const int listSize = m_list.size();
- for (int i = 0; i < listSize; ++i) {
- uint timestamp = m_list.at(i).time;
- if (timestamp != 0) {
- QDateTime datetime;
- datetime.setTime_t(timestamp);
- m_list[i].extrainfo = QString("(%1/%2) %3")
- .arg(i+1)
- .arg(m_list.size())
- .arg(fuzzyDate(datetime));
- } else {
- m_list[i].extrainfo = QString("(%1/%2) %3")
- .arg(i+1)
- .arg(m_list.size())
- .arg(m_list.at(i).title);
- }
- m_list[i].title = QString("(%1/%2) %3")
- .arg(i+1)
- .arg(m_list.size())
- .arg(m_list.at(i).title);
- }
-
- if (m_list.size() < 1) {
- FeedData noitems;
- noitems.title = "no items to display";
- noitems.extrainfo = "no items to display";
- noitems.text = data["title"].toString();
- noitems.icon = m_feedIcons["generic"];
-
- m_list.append(noitems);
- }
-
- listUpdated();
- }
-}
-
-//TODO: hmm, we probably want to update the timestamps more often then the feeds
-//get updated... like, every minute
-QString Scroller::fuzzyDate(const QDateTime& datetime)
-{
- QDateTime now = QDateTime::currentDateTime();
- QDate nowdate = now.date();
- QDate date = datetime.date();
-
- if (now < (datetime.addSecs(3600))) {
- return i18np( "%1 minute ago", "%1 minutes ago", (datetime.secsTo(now)/60) );
- } else if (nowdate == date.addDays(1)) {
- return i18n( "yesterday" );
- } else if (now < (datetime.addDays(1))) {
- return i18np( "%1 hour ago", "%1 hours ago", (datetime.secsTo(now)/3600) );
- } else if (now < (datetime.addDays(7))) {
- return i18np( "%1 day ago", "%1 days ago", datetime.daysTo(now));
- } else {
- return i18np( "%1 week ago", "%1 weeks ago", (datetime.daysTo(now)/7));
- }
-}
-
-int Scroller::maxAge() const
-{
- return m_maxAge;
-}
-
-void Scroller::setMaxAge(int maxAge)
-{
- m_maxAge = maxAge;
-}
-
-
-#include "moc_scroller.cpp"
-#endif // SCROLLER_CPP
-
+++ /dev/null
-/*
- * Copyright (C) 2007 Petri Damsten <damu@iki.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef SCROLLER_HEADER
-#define SCROLLER_HEADER
-
-#include "feeddata.h"
-#include <QList>
-#include <QGraphicsWidget>
-#include <QtCore/qsharedpointer.h>
-#include <QAbstractAnimation>
-#include <plasma/plasma_export.h>
-#include <plasma/animator.h>
-#include <plasma/dataengine.h>
-
-
-class KIcon;
-class SingleFeedItem;
-class FeedData;
-#include <QPropertyAnimation>
-
-namespace Plasma
-{
- // namespace Plasma
- class IconWidget;
-}
-
-class Scroller : public QGraphicsWidget
-{
- Q_OBJECT
- Q_PROPERTY(qreal animate READ animValue WRITE animate)
-
-public:
- Scroller(QGraphicsItem *parent = 0);
- virtual ~Scroller();
-
- virtual void setGeometry(const QRectF &geometry);
-
- QList<FeedData> list();
- void delayedMoveNext(int delay);
- void listUpdated();
-
- void setAnimations(bool animations);
- bool animations() const;
-
- int maxAge() const;
- void setMaxAge(int maxAge);
-
- bool dropTarget() const;
- void setDropTarget(bool droptarget);
-
- bool hovering() const;
-
- qreal animValue() const;
-
-public slots:
- void dataUpdated(const QString& source, const Plasma::DataEngine::Data &data);
-
-protected:
- virtual void wheelEvent (QGraphicsSceneWheelEvent *event);
- virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
- virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
-
-protected slots:
- void leftClicked();
- void rightClicked();
- void moveNext();
- void movePrev();
- void animationComplete();
- void clearUnusedItems();
- void animate(qreal value);
-
-private:
- void updateSize();
- void doAnimation(QAbstractAnimation::Direction direction);
- QString fuzzyDate(const QDateTime& datetime);
-
- int m_current;
- bool m_animations;
-
- //how many times has the user clicked / scrolled next or previous
- //while the current animation is being displayed.
- int m_delayedNext;
- int m_delayedPrev;
-
- int m_maxAge;
-
- bool m_droptarget;
-
- QList<FeedData> m_list;
- //itemlist contains all SingleFeedItems that are currently in
- //memory and should be cleared later.
- QList<SingleFeedItem *> m_itemlist;
- //activeitemlist contains all SingleFeedItems that are currently
- //displayed (always 1 or 2 in a horizontal scroller, but a future
- //vertical scroller might need more so we use a list
- QList<SingleFeedItem *> m_activeitemlist;
- QMap<QString, KIcon *> m_feedIcons;
-
- Plasma::IconWidget *m_left;
- Plasma::IconWidget *m_right;
-
- bool m_hovered;
- bool m_isAnimating;
- QWeakPointer<QPropertyAnimation> m_animation;
-};
-
-#endif
+++ /dev/null
-/*
- * Copyright 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
-//Own
-#include "single-feed.h"
-#include "feeddata.h"
-
-//KDE
-#include <kdebug.h>
-#include <kicon.h>
-#include <kcursor.h>
-#include <kglobalsettings.h>
-
-//Plasma
-#include <plasma/svg.h>
-#include <plasma/theme.h>
-
-//Qt
-#include <QPainter>
-#include <QGraphicsItem>
-#include <QFont>
-
-//This implementation is based on a great mockup from pinheiro.
-
-QRectF SingleFeedItem::boundingRect() const
-{
- return m_rect;
-}
-
-SingleFeedItem::SingleFeedItem(QGraphicsItem * parent) : QGraphicsWidget(parent),
- m_displayExtra(true)
-{
- m_background = new Plasma::Svg(this);
- m_background->setImagePath("rssnow/background");
-}
-
-SingleFeedItem::~SingleFeedItem()
-{
-}
-
-void SingleFeedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- qreal height = m_rect.height();
- qreal width = m_rect.width();
-
- p->setRenderHint(QPainter::Antialiasing);
- QFont font = KGlobalSettings::smallestReadableFont();
-
- //paint background
- m_background->paint(p, 0, 0);
-
- //paint icon (if available)
- if (m_feeditem.icon != 0) {
- if (height > 0 ) {
- m_feeditem.icon->paint(p, 2, 2, 16, 16);
- }
- }
-
- //draw title
- // FIXME: either remove since we use a hardcoded background
- // or adjust the background color of the svg as well due to theme
- // settings
- p->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
- font.setBold(true);
- p->setFont(font);
- QString text;
- if (m_displayExtra) {
- text = m_feeditem.extrainfo;
- } else {
- text = m_feeditem.title;
- }
-
- m_doc.setHtml(text);
- text = m_doc.toPlainText();
- QFontMetrics fm(font);
- const int titleHeight = qMax(16, fm.height());
- p->drawText(QRectF(22, 2, width - 24, titleHeight),
- Qt::AlignLeft | Qt::AlignBottom, text);
-
- //draw text
- font.setBold(false);
- p->setFont(font);
- m_doc.setHtml(m_feeditem.text);
- p->drawText(QRectF(2, titleHeight + 4, width - 4, height - titleHeight - 6),
- Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
- m_doc.toPlainText());
-}
-
-void SingleFeedItem::setRect(const QRect& rect)
-{
- //TODO: Hmm, I don't think I'm supposed to fix size / boudingrect this way...
- //Investigate and improve.
- m_rect = rect;
- m_background->resize(m_rect.width(), m_rect.height());
-}
-
-int SingleFeedItem::preferredHeight(int width)
-{
- QFont font = KGlobalSettings::smallestReadableFont();
- m_doc.setTextWidth(width);
- m_doc.setDefaultFont(font);
- m_doc.setHtml(m_feeditem.text);
- m_doc.setPlainText(m_doc.toPlainText());
- int totalHeight = m_doc.size().height();
-
- font.setBold(true);
- m_doc.setDefaultFont(font);
- m_doc.setHtml(m_displayExtra ? m_feeditem.extrainfo : m_feeditem.title);
- m_doc.setPlainText(m_doc.toPlainText());
- totalHeight += m_doc.size().height();
-
- kDebug() << "preferred height is" << totalHeight;
- return totalHeight;
-}
-
-void SingleFeedItem::setFeedData(FeedData feeddata)
-{
- //set feed item and repaint
- m_feeditem = feeddata;
- if (!feeddata.url.isEmpty()) {
- setCursor(Qt::PointingHandCursor);
- } else {
- setCursor(Qt::ArrowCursor);
- }
-
- update();
-}
-
-FeedData SingleFeedItem::feedData() const
-{
- return m_feeditem;
-}
-
-int SingleFeedItem::itemNumber() const
-{
- return m_feeditem.itemNumber;
-}
-
-void SingleFeedItem::setDisplayExtra(bool extra)
-{
- m_displayExtra = extra;
-}
-
-bool SingleFeedItem::displayExtra() const
-{
- return m_displayExtra;
-}
+++ /dev/null
-#ifndef SINGLE_FEED_H
-#define SINGLE_FEED_H
-/*
- * Copyright (C) 2007 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-
-#include "feeddata.h"
-#include <QGraphicsItem>
-#include <QGraphicsWidget>
-#include <QTextDocument>
-
-#include <QRect>
-
-namespace Plasma {
- class Svg;
-}
-
-class SingleFeedItem : public QGraphicsWidget
-{
- public:
- SingleFeedItem(QGraphicsItem * parent = 0);
- ~SingleFeedItem();
- void setFeedData(FeedData feeddata);
- FeedData feedData() const;
- void setRect(const QRect& rect);
- int itemNumber() const;
- void setDisplayExtra(bool extra);
- bool displayExtra() const;
- int preferredHeight(int width);
-
- virtual QRectF boundingRect() const;
- virtual void paint(QPainter *p,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget = 0);
- private:
- QRect m_rect;
- FeedData m_feeditem;
- Plasma::Svg * m_background;
- bool m_displayExtra;
- QTextDocument m_doc;
- // QImage m_htmlImg;
-};
-
-#endif // SINGLE_FEED_H