[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/rssnow
From: Rob Scheepmaker <r.scheepmaker () student ! utwente ! nl>
Date: 2008-04-07 18:08:15
Message-ID: 1207591695.960625.21987.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 794498 by scheepmaker:
Add configuration options for the animations and made the logo optional.
M +72 -11 config.ui
M +38 -7 news.cpp
M +4 -0 news.h
M +35 -21 scroller.cpp
M +3 -0 scroller.h
--- trunk/playground/base/plasma/applets/rssnow/config.ui #794497:794498
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>272</height>
+ <width>399</width>
+ <height>332</height>
</rect>
</property>
<property name="styleSheet" >
@@ -24,14 +24,14 @@
</widget>
</item>
<item>
- <widget class="KHistoryComboBox" name="feedComboBox" >
+ <widget class="KHistoryComboBox" native="1" name="feedComboBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="autoCompletion" >
+ <property name="autoCompletion" stdset="0" >
<bool>true</bool>
</property>
</widget>
@@ -128,14 +128,75 @@
</layout>
</item>
<item>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Switch interval</string>
+ </property>
+ <property name="buddy" >
+ <cstring>intervalSpinBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QSpinBox" 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>
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>seconds</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="logo" >
+ <property name="text" >
+ <string>Show RSSNOW logo</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="animations" >
+ <property name="text" >
+ <string>Show animations</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
- <width>384</width>
- <height>16</height>
+ <width>20</width>
+ <height>40</height>
</size>
</property>
</spacer>
@@ -144,11 +205,6 @@
</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>
@@ -158,6 +214,11 @@
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
+ <customwidget>
+ <class>KHistoryComboBox</class>
+ <extends>QWidget</extends>
+ <header>khistorycombobox.h</header>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
--- trunk/playground/base/plasma/applets/rssnow/news.cpp #794497:794498
@@ -60,19 +60,19 @@
KConfigGroup cg = config();
m_interval = cg.readEntry("interval", 30);
m_feeds = cg.readEntry("feeds", \
QStringList("http://www.kde.org/dotkdeorg.rdf")); + m_switchInterval = \
cg.readEntry("switchInterval", 10); + m_logo = cg.readEntry("logo", true);
+ m_animations = cg.readEntry("animations", true);
m_layout = new Plasma::VBoxLayout(this);
m_layout->setMargin(0);
m_layout->setSpacing(2);
- //TODO: make icon optional
m_header = new Header(this);
m_feedIcons["generic"] = new KIcon("application-rss+xml");
m_timer = new QTimer(this);
- //TODO: make configurable...
- m_timer->setInterval(10 * 1000);
updateScrollers();
@@ -87,7 +87,11 @@
void News::switchItems()
{
int delay = 1;
- for (int i = 1; i < m_layout->count(); i++ ){
+ 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);
@@ -126,8 +130,8 @@
connect(m_dialog, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(ui.addFeed, SIGNAL(clicked()), this, SLOT(addFeed()));
connect(ui.removeFeed, SIGNAL(clicked()), this, SLOT(removeFeed()));
- connect( ui.feedList, SIGNAL( itemSelectionChanged ()), this, \
SLOT(slotItemChanged()));
- connect( ui.feedComboBox->lineEdit(), SIGNAL( textChanged( const QString& ) \
), this, SLOT( slotChangeText(const QString& ) ) ); + connect(ui.feedList, \
SIGNAL( itemSelectionChanged ()), this, SLOT(slotItemChanged())); + \
connect(ui.feedComboBox->lineEdit(), SIGNAL( textChanged( const QString& ) ), this, \
SLOT( slotChangeText(const QString& ) ) ); ui.removeFeed->setEnabled( false );
KConfig feedsFile(QString("news/feeds"), KConfig::FullConfig, "data");
m_defaultFeeds = feedsFile.group("feeds").entryMap();
@@ -140,6 +144,17 @@
}
ui.intervalSpinBox->setValue(m_interval);
+ ui.switchInterval->setValue(m_switchInterval);
+ 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);
+ }
ui.feedList->addItems(m_feeds);
m_dialog->show();
}
@@ -188,6 +203,10 @@
void News::configAccepted()
{
m_interval = ui.intervalSpinBox->value();
+ m_switchInterval = ui.switchInterval->value();
+ m_logo = ui.logo->isChecked();
+ m_animations = ui.animations->isChecked();
+
m_feeds.clear();
QString feed;
for (int i = 0; i < ui.feedList->count(); i++) {
@@ -201,6 +220,9 @@
KConfigGroup cg = config();
cg.writeEntry("feeds", m_feeds);
cg.writeEntry("interval", m_interval);
+ cg.writeEntry("switchInterval", m_switchInterval);
+ cg.writeEntry("animations", m_animations);
+ cg.writeEntry("logo", m_logo);
updateScrollers();
connectToEngine();
@@ -209,13 +231,20 @@
void News::updateScrollers()
{
m_timer->stop();
+ m_timer->setInterval(m_switchInterval * 1000);
+
+ m_layout->removeItem(m_header);
+ m_header->hide(); //else a weird bug shows up when removing the logo
foreach (Scroller * scroller, m_scrollerList) {
m_layout->removeItem(scroller);
delete scroller;
}
m_scrollerList.clear();
- m_layout->addItem(m_header);
+ if (m_logo) {
+ m_layout->addItem(m_header);
+ m_header->show();
+ }
FeedData data;
data.icon = m_feedIcons["generic"];
@@ -227,12 +256,14 @@
this, SLOT(linkActivated(const QString&)));
m_layout->addItem(scroller);
data.text = feed;
+ scroller->setAnimations(m_animations);
scroller->list()->append(data);
scroller->listUpdated();
m_scrollerList[feed.toLower()] = scroller;
}
m_layout->updateGeometry();
+ m_layout->invalidate();
updateGeometry();
update();
m_timer->start();
--- trunk/playground/base/plasma/applets/rssnow/news.h #794497:794498
@@ -69,7 +69,11 @@
QTimer *m_timer;
uint m_interval;
+ uint m_switchInterval;
+ bool m_animations;
+ bool m_logo;
+
Plasma::VBoxLayout *m_layout;
Header *m_header;
KDialog *m_dialog;
--- trunk/playground/base/plasma/applets/rssnow/scroller.cpp #794497:794498
@@ -43,6 +43,7 @@
m_animid(0),
m_current(0),
m_animdirection(0),
+ m_animations(true),
m_delayedNext(0),
m_delayedPrev(0),
m_list(new QList<FeedData>()),
@@ -159,30 +160,33 @@
}
void Scroller::doAnimation() {
- //yay! sexy animation :p
if (m_list->size() > 1) {
- SingleFeedItem * item = new SingleFeedItem(this);
- item->setFeedData(m_list->at(m_current));
- item->setZValue(m_itemlist->size() + 1);
- item->show();
- item->setPos(m_animdirection * 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;
+ if (m_animations) {
+ SingleFeedItem * item = new SingleFeedItem(this);
+ item->setFeedData(m_list->at(m_current));
+ item->setZValue(m_itemlist->size() + 1);
+ item->show();
+ item->setPos(m_animdirection * 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;
+ m_animid = Phase::self()->customAnimation(frames, time,
+ Phase::LinearCurve,
+ this, "animate");
} else {
- queuelength = m_delayedPrev + 1;
+ m_itemlist->at(m_itemlist->size() - \
1)->setFeedData(m_list->at(m_current)); }
- time = 400 / queuelength;
- frames = time / 40;
- m_animid = Phase::self()->customAnimation(frames, time,
- Phase::EaseInOutCurve,
- this, "animate");
}
}
@@ -336,7 +340,17 @@
m_hovered = false;
}
+void Scroller::setAnimations(bool animations)
+{
+ m_animations = animations;
+}
+bool Scroller::animations()
+{
+ return m_animations;
+}
+
+
#include "scroller.moc"
#endif // SCROLLER_CPP
--- trunk/playground/base/plasma/applets/rssnow/scroller.h #794497:794498
@@ -55,6 +55,8 @@
QList<FeedData> * list();
void delayedMoveNext(int delay);
void listUpdated();
+ void setAnimations(bool animations);
+ bool animations();
bool hovering();
signals:
@@ -86,6 +88,7 @@
AnimId m_animid;
int m_current;
int m_animdirection;
+ int m_animations;
//how many times has the user clicked / scrolled next or previous
//while the current animation is being displayed.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic