[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/frame
From:       Etienne Rebetez <etienne.rebetez () oberwallis ! ch>
Date:       2010-04-18 13:06:24
Message-ID: 20100418130624.DCFD8AC89D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1116030 by erebetez:

Added an option to automaticaly reload the image from the source. (i.e. live cams, \
weather data, etc.)

REVIEWBOARD: http://reviewboard.kde.org/r/3334/
CCMAIL: annma@kde.org
GUI
FEATURE

 M  +28 -2     frame.cpp  
 M  +6 -0      frame.h  
 M  +57 -21    imageSettings.ui  
 M  +5 -1      slideshow.cpp  
 M  +1 -1      slideshow.h  


--- trunk/KDE/kdeplasma-addons/applets/frame/frame.cpp #1116029:1116030
@@ -76,10 +76,15 @@
     m_updateTimer = new QTimer(this);
     m_updateTimer->setSingleShot(true);
     connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(delayedUpdateSize()));
+
+    m_autoUpdateTimer = new QTimer(this);
+    m_autoUpdateTimer->setSingleShot(true);
+    connect(m_autoUpdateTimer, SIGNAL(timeout()), this, SLOT(reloadImage()));
 }
 
 Frame::~Frame()
 {
+    m_autoUpdateTimer->stop();
 }
 
 void Frame::init()
@@ -105,6 +110,7 @@
     setAssociatedApplicationUrls(m_currentUrl);
     m_potdProvider = cg.readEntry("potdProvider", "");
     m_potd = cg.readEntry("potd", false);
+    m_autoUpdateIntervall = cg.readEntry("autoupdate time", 0);
 
     // Frame & Shadow dimensions
     m_frameOutline = 8;
@@ -257,8 +263,6 @@
         resize(sizeHint);
     }
 
-
-
     kDebug() << "Rendering picture";
 
     // create a QPixmap which can be drawn in paintInterface()
@@ -394,6 +398,11 @@
     p->end();
     delete p;
     update();
+
+    if (m_doAutoUpdate && !m_autoUpdateTimer->isActive()) {
+      kDebug() << "Autoupdate timer restarted:" << m_autoUpdateIntervall << "s";
+      m_autoUpdateTimer->start(m_autoUpdateIntervall * 1000);
+    }
 }
 
 void Frame::nextPicture()
@@ -494,6 +503,7 @@
     m_configDialog->imageUi.removeDirButton->setEnabled(!m_slideShowPaths.isEmpty());
                
     m_configDialog->imageUi.slideShowDelay->setTime(QTime(m_slideshowTime / 3600, \
(m_slideshowTime / 60) % 60, m_slideshowTime % 60));  \
m_configDialog->previewPicture(m_mySlideShow->image()); +    \
m_configDialog->imageUi.autoUpdateTime->setTime(QTime(m_autoUpdateIntervall / 3600, \
(m_autoUpdateIntervall / 60) % 60));  }
 
 void Frame::configAccepted()
@@ -541,6 +551,12 @@
     m_slideshowTime = timerTime.second() + timerTime.minute() * 60 + \
timerTime.hour() * 3600;  cg.writeEntry("slideshow time", m_slideshowTime);
 
+    m_autoUpdateTimer->stop();
+
+    QTime AutoUpdateTimer = m_configDialog->imageUi.autoUpdateTime->time();
+    m_autoUpdateIntervall = AutoUpdateTimer.minute() * 60 + AutoUpdateTimer.hour() * \
3600; +    cg.writeEntry("autoupdate time", m_autoUpdateIntervall);
+
     QString potdProvider = \
m_configDialog->imageUi.potdComboBox->itemData(m_configDialog->imageUi.potdComboBox->currentIndex()).toString();
  
     if ((wasPotd && !m_potd) || (m_potd && potdProvider != m_potdProvider)) {
@@ -569,6 +585,7 @@
 void Frame::initSlideShow()
 {
     m_mySlideShow->setUpdateInterval(0);
+    m_doAutoUpdate = false;
 
     if (m_slideShow) {
         m_mySlideShow->setRandom(m_random);
@@ -585,6 +602,10 @@
     } else { //no slideshow so no random stuff
         m_mySlideShow->setRandom(false);
         m_mySlideShow->setImage(m_currentUrl.url());
+
+        if (m_autoUpdateIntervall > 0) {
+            m_doAutoUpdate = true;
+        }
     }
 
     if (!m_potd) {
@@ -711,4 +732,9 @@
     }
 }
 
+void Frame::reloadImage()
+{
+    m_mySlideShow->updateImage(m_currentUrl.url());
+}
+
 #include "frame.moc"
--- trunk/KDE/kdeplasma-addons/applets/frame/frame.h #1116029:1116030
@@ -74,6 +74,7 @@
     void delayedUpdateSize();
     void scalePictureAndUpdate();
     void imageScaled(const QImage &img);
+    void reloadImage();
 
 protected:
     void constraintsEvent(Plasma::Constraints constraints);
@@ -116,6 +117,11 @@
     bool m_random;
     bool m_recursiveSlideShow;
     SlideShow* m_mySlideShow;
+    /// Autoupdate
+    int m_autoUpdateIntervall;
+    bool m_doAutoUpdate;
+    QTimer* m_autoUpdateTimer;
+
     QPixmap m_pixmap;
     QImage m_scaledImage;
     QTimer* m_updateTimer;
--- trunk/KDE/kdeplasma-addons/applets/frame/imageSettings.ui #1116029:1116030
@@ -53,25 +53,19 @@
            <property name="text">
             <string>Picture:</string>
            </property>
-           <property name="buddy">
-            <cstring>picRequester</cstring>
-           </property>
           </widget>
          </item>
          <item>
-          <widget class="KUrlComboRequester" name="picRequester">
-           <property name="sizePolicy">
-            <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
-             <horstretch>0</horstretch>
-             <verstretch>0</verstretch>
-            </sizepolicy>
-           </property>
+          <widget class="KUrlRequester" name="picRequester">
            <property name="acceptDrops">
             <bool>true</bool>
            </property>
            <property name="filter">
             <string>*.png *.jpeg *.jpg *.svg *.svgz</string>
            </property>
+           <property name="mode">
+            <set>KFile::ExistingOnly|KFile::File</set>
+           </property>
            <property name="fileDialogModality">
             <enum>Qt::NonModal</enum>
            </property>
@@ -123,17 +117,65 @@
         </layout>
        </item>
        <item>
-        <spacer>
+        <spacer name="verticalSpacer_2">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeType">
-          <enum>QSizePolicy::Expanding</enum>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
          </property>
+        </spacer>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_2">
+         <item>
+          <widget class="QLabel" name="label_4">
+           <property name="text">
+            <string>Autoupdate:</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QTimeEdit" name="autoUpdateTime">
+           <property name="toolTip">
+            <string>Updates the picture from the source in the given time.
+Useful if you want a live cam or weather data to be up to date.</string>
+           </property>
+           <property name="specialValueText">
+            <string>never</string>
+           </property>
+           <property name="displayFormat">
+            <string>hh'h' mm'min'</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_3">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>438</width>
-           <height>16</height>
+           <width>20</width>
+           <height>40</height>
           </size>
          </property>
         </spacer>
@@ -355,12 +397,6 @@
    <header>kpushbutton.h</header>
   </customwidget>
   <customwidget>
-   <class>KUrlComboRequester</class>
-   <extends>KUrlRequester</extends>
-   <header>kurlrequester.h</header>
-   <container>1</container>
-  </customwidget>
-  <customwidget>
    <class>KComboBox</class>
    <extends>QComboBox</extends>
    <header>kcombobox.h</header>
--- trunk/KDE/kdeplasma-addons/applets/frame/slideshow.cpp #1116029:1116030
@@ -117,6 +117,11 @@
     return m_image;
 }
 
+void SlideShow::updateImage(QString newUrl)
+{
+    m_picture->setPicture(newUrl);
+}
+
 KUrl SlideShow::url(int offset)
 {
     if (!m_picturePaths.isEmpty()) {
@@ -215,4 +220,3 @@
 }
 
 #include "slideshow.moc"
-
--- trunk/KDE/kdeplasma-addons/applets/frame/slideshow.h #1116029:1116030
@@ -46,7 +46,7 @@
     QImage image() const;
     KUrl currentUrl() const;
     QString message() const;
-
+    void updateImage(QString);
     void setUpdateInterval(int msec);
 
 public Q_SLOTS:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic