[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-12 18:00:09
Message-ID: 1208023209.763030.23863.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 796130 by scheepmaker:
The applet now adapts to live in a panel, by grouping all scrollers together if it \
doesn't fit otherwise, and hiding the drop target and logo. It now also works again \
with a more recent version of Phase.
M +39 -2 news.cpp
M +3 -0 news.h
M +4 -3 scroller.cpp
M +2 -4 scroller.h
--- trunk/playground/base/plasma/applets/rssnow/news.cpp #796129:796130
@@ -100,8 +100,12 @@
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 < (m_scrollerList.size() - 1)) {
+ if (i < maxScroller) {
kDebug() << "Connect to source: " << m_feedlist.at(i);
engine->connectSource(m_feedlist.at(i++), scroller,
m_interval * 60 * 1000);
@@ -140,6 +144,7 @@
ui.intervalSpinBox->setValue(m_interval);
ui.switchInterval->setValue(m_switchInterval);
+ ui.maxAge->setValue(m_maxAge);
if (m_logo) {
ui.logo->setCheckState(Qt::Checked);
} else {
@@ -265,8 +270,8 @@
scroller->listUpdated();
}
+ m_layout->setSize(contentSize());
m_layout->updateGeometry();
- updateGeometry();
m_timer->start();
connectToEngine();
@@ -321,4 +326,36 @@
}
}
+void News::constraintsUpdated(Plasma::Constraints constraints)
+{
+ kDebug() << "constrainsUpdated : " << constraints;
+ if (constraints & Plasma::FormFactorConstraint) {
+ if (formFactor() == Plasma::Horizontal) {
+ m_logo = false;
+ m_showdroptarget = false;
+ int minSize = (m_feedlist.size() * \
m_scrollerList.first()->minimumSize().height()); + kDebug() << "minimum \
size to contain all scrollers: " << minSize; + if (size().height() < \
minSize) { + //group all feeds together so it can fit:
+ QString allfeeds;
+ foreach (QString feed, m_feedlist) {
+ if (!feed.endsWith(",")) {
+ feed.append(",");
+ }
+ allfeeds.append(feed);
+ }
+ kDebug() << "allfeeds = " << allfeeds;
+ m_feedlist.clear();
+ m_feedlist.append(allfeeds);
+ } else {
+ //TODO: restore default settings.
+ }
+ updateScrollers();
+ }
+ }
+ if (constraints & Plasma::SizeConstraint) {
+ m_layout->setSize(contentSize());
+ updateGeometry();
+ }
+}
#include "news.moc"
--- trunk/playground/base/plasma/applets/rssnow/news.h #796129:796130
@@ -50,6 +50,9 @@
void showConfigurationInterface();
void switchItems();
+ protected:
+ virtual void constraintsUpdated(Plasma::Constraints constraints);
+
protected Q_SLOTS:
void dropEvent(QGraphicsSceneDragDropEvent *event);
--- trunk/playground/base/plasma/applets/rssnow/scroller.cpp #796129:796130
@@ -78,8 +78,8 @@
connect(m_left, SIGNAL(clicked()), this, SLOT(leftClicked()));
connect(m_right, SIGNAL(clicked()), this, SLOT(rightClicked()));
- connect(Phase::self(), SIGNAL(customAnimationComplete(AnimId)),
- this, SLOT(animationComplete(AnimId)));
+ connect(Phase::self(), SIGNAL(customAnimationComplete(Plasma::Phase::AnimId)),
+ this, SLOT(animationComplete(Plasma::Phase::AnimId)));
}
Scroller::~Scroller() {
@@ -135,6 +135,7 @@
if (m_list->size() < 1) { //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);
}
@@ -226,7 +227,7 @@
}
}
-void Scroller::animationComplete(AnimId id)
+void Scroller::animationComplete(Plasma::Phase::AnimId id)
{
bool stillAnimating = false;
if (id == m_animid) {
--- trunk/playground/base/plasma/applets/rssnow/scroller.h #796129:796130
@@ -39,8 +39,6 @@
class Svg;
}
-typedef int AnimId;
-
class Scroller : public Plasma::Widget
{
Q_OBJECT
@@ -85,7 +83,7 @@
void rightClicked();
void moveNext();
void movePrev();
- void animationComplete(AnimId);
+ void animationComplete(Plasma::Phase::AnimId);
void clearUnusedItems();
void animate(qreal anim);
@@ -94,7 +92,7 @@
void doAnimation();
QString fuzzyDate(const QDateTime& datetime);
- AnimId m_animid;
+ Plasma::Phase::AnimId m_animid;
int m_current;
int m_animdirection;
int m_animations;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic