[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/plasma/applets/frame
From: Georges Toth <gtoth () trypill ! org>
Date: 2008-02-25 2:12:04
Message-ID: 1203905524.509439.31899.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 778962 by gtoth:
- integrated the PoTD dataengine
- added a combobox for selecting a PoTD provider in the configdialog
M +30 -0 config.ui
M +1 -1 configdialog.cpp
M +72 -5 frame.cpp
M +4 -2 frame.h
--- trunk/extragear/plasma/applets/frame/config.ui #778961:778962
@@ -40,6 +40,11 @@
<string>Slideshow</string>
</property>
</item>
+ <item>
+ <property name="text" >
+ <string>Picture of the day</string>
+ </property>
+ </item>
</widget>
</item>
<item>
@@ -253,6 +258,31 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="page_2" >
+ <widget class="QComboBox" name="potdComboBox" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>271</width>
+ <height>27</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="selectPoTDlabel" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>158</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Select Picture of the day source:</string>
+ </property>
+ </widget>
+ </widget>
</widget>
</item>
</layout>
--- trunk/extragear/plasma/applets/frame/configdialog.cpp #778961:778962
@@ -127,4 +127,4 @@
{
Picture myPicture;
previewPicture(myPicture.setPicture(KUrl(path)));
-}
\ No newline at end of file
+}
--- trunk/extragear/plasma/applets/frame/frame.cpp #778961:778962
@@ -43,6 +43,7 @@
#include <KUrlRequester>
#include <KUrl>
#include <KDirSelectDialog>
+#include <KServiceTypeTrader>
#include <math.h>
@@ -68,6 +69,22 @@
delete m_configDialog;
}
+void Frame::dataUpdated( const QString &name, const Plasma::DataEngine::Data &data )
+{
+ QDate mCurrentDate = QDate::currentDate();
+ const QString identifier = m_potdProvider + ":" + mCurrentDate.toString( \
Qt::ISODate ); +
+ QImage _picture = data[ identifier ].value<QImage>();
+
+ if ( !_picture.isNull() ) {
+ m_picture = _picture;
+ m_pixmapCache = QPixmap();
+ prepareGeometryChange();
+ updateGeometry();
+ update();
+ }
+}
+
void Frame::init()
{
m_slideNumber = 0;
@@ -81,6 +98,8 @@
m_slideShowPaths = cg.readEntry("slideshow paths", QStringList());
m_slideshowTime = cg.readEntry("slideshow time", 10); // default to 10 seconds
m_currentUrl = cg.readEntry("url", "Default");
+ m_potdProvider = cg.readEntry("potdProvider", "");
+ m_potd = cg.readEntry("potd", false);
// Frame & Shadow dimensions
m_frameOutline = 8;
@@ -135,6 +154,14 @@
{
if ( !m_configDialog ) {
m_configDialog = new ConfigDialog( 0 );
+
+ KService::List services = KServiceTypeTrader::self()->query( "PlasmaPoTD/Plugin");
+ foreach (KService::Ptr service, services) {
+ const QString *service_name = new QString ( service->name() );
+ const QVariant *service_identifier = new QVariant ( service->property( \
"X-KDE-PlasmaPoTDProvider-Identifier", QVariant::String ).toString() ); + \
m_configDialog->ui.potdComboBox->insertItem( \
m_configDialog->ui.potdComboBox->count(), *service_name, *service_identifier ); + }
+
connect( m_configDialog, SIGNAL( applyClicked() ), this, SLOT( \
configAccepted() ) );
connect( m_configDialog, SIGNAL( okClicked() ), this, SLOT( configAccepted() \
) ); }
@@ -146,7 +173,15 @@
m_configDialog->setShowFrame(m_frame);
m_configDialog->setFrameColor(m_frameColor);
- m_configDialog->ui.pictureComboBox->setCurrentIndex(m_slideShow);//to change \
when adding PoTD + if (m_slideShow)
+ m_configDialog->ui.pictureComboBox->setCurrentIndex(1);
+ else if (m_potd)
+ m_configDialog->ui.pictureComboBox->setCurrentIndex(2);
+ else
+ m_configDialog->ui.pictureComboBox->setCurrentIndex(0);
+
+ m_configDialog->ui.potdComboBox->setCurrentIndex( \
m_configDialog->ui.potdComboBox->findData(m_potdProvider) ); +
m_configDialog->setCurrentUrl(m_currentUrl);
m_configDialog->ui.slideShowDirList->clear();
m_configDialog->ui.slideShowDirList->addItems(m_slideShowPaths);
@@ -171,9 +206,24 @@
m_frameColor = m_configDialog->frameColor();
cg.writeEntry("frameColor", m_frameColor);
+ if (m_configDialog->ui.pictureComboBox->currentIndex() == 1)
+ {
+ m_slideShow = true;
+ m_potd = false;
+ }
+ else if (m_configDialog->ui.pictureComboBox->currentIndex() == 2)
+ {
+ m_slideShow = false;
+ m_potd = true;
+ }
+ else
+ {
+ m_slideShow = false;
+ m_potd = false;
+ }
+
m_currentUrl = m_configDialog->currentUrl();
cg.writeEntry("url", m_currentUrl);
- m_slideShow = m_configDialog->ui.pictureComboBox->currentIndex();
cg.writeEntry("slideshow", m_slideShow);
m_slideShowPaths.clear();
QStringList dirs;
@@ -187,9 +237,12 @@
m_slideShowTimer->setInterval(m_slideshowTime * 1000);
cg.writeEntry("slideshow time", m_slideshowTime);
+ m_potdProvider = \
m_configDialog->ui.potdComboBox->itemData(m_configDialog->ui.potdComboBox->currentIndex()).toString();
+ cg.writeEntry("potdProvider", m_potdProvider);
+ cg.writeEntry("potd", m_potd);
+
initSlideShow();
-
-
+
emit configNeedsSaving();
}
@@ -198,11 +251,25 @@
if (m_slideShow) {
m_mySlideShow->setDirs(m_slideShowPaths);
m_slideShowTimer->start();
+ } else if (m_potd) {
+ Plasma::DataEngine *engine = dataEngine( "potd" );
+ if ( !engine )
+ return;
+
+ QDate mCurrentDate = QDate::currentDate();
+ const QString identifier = m_potdProvider + ":" + mCurrentDate.toString( \
Qt::ISODate ); +
+ engine->disconnectSource( identifier, this );
+ engine->connectSource( identifier, this );
+
+ const Plasma::DataEngine::Data data = engine->query( identifier );
} else {
m_mySlideShow->setImage(m_currentUrl.path());
m_slideShowTimer->stop();
}
- updatePicture();
+
+ if (!m_potd)
+ updatePicture();
}
void Frame::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
--- trunk/extragear/plasma/applets/frame/frame.h #778961:778962
@@ -53,6 +53,7 @@
public slots:
void showConfigurationInterface();
+ void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data );
protected Q_SLOTS:
void dropEvent(QGraphicsSceneDragDropEvent *event);
@@ -79,8 +80,9 @@
bool m_roundCorners;
/// If true, the picture will have a drop shadow.
bool m_shadow;
- /// true if the user wants Wikipedia Picture of the Day (unused)
- bool m_potd;
+ /// PoTD
+ QString m_potdProvider;
+ bool m_potd;
/// Stores the current picture URL when slideShow is false. Wikipedia \
Picture of the Day is default. KUrl m_currentUrl;
/// The current slideshow folder
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic