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

List:       kde-devel
Subject:    patch for screensaver kslideshow to close whish 36191
From:       Sven Leiber <s.leiber () web ! de>
Date:       2003-06-10 16:31:23
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Attatched I have a diff for the slidshow screensaver to add a random picture 
position to the config. I have make some look and feel updates, too. So can 
somebody who have access to the cvs add the diff file to the cvs? It was in 
kdeartwork. And can close the whish 36191 please?


Sven
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+5gfqtVfdSzRKOQQRAjehAJ0W7bLJ0kdaSXDOonIBAk9DsaOiZACgo86D
YCf7HNxXYd0Bwfb+FvuQLxM=
=glnV
-----END PGP SIGNATURE-----

["slideshow.diff" (text/x-diff)]

diff -ur /home/sven/backup/kdeartwork-backup/kscreensaver/kdesavers/slideshow.cpp \
                /home/sven/backup/kdeartwork/kscreensaver/kdesavers/slideshow.cpp
--- /home/sven/backup/kdeartwork-backup/kscreensaver/kdesavers/slideshow.cpp	2003-05-02 \
                00:09:23.000000000 +0200
+++ /home/sven/backup/kdeartwork/kscreensaver/kdesavers/slideshow.cpp	2003-06-10 \
17:45:26.000000000 +0200 @@ -2,6 +2,7 @@
  *  (C) 1999 Stefan Taferner <taferner@kde.org>
  *  (C) 2001 Martin R. Jones <mjones@kde.org>
  *  (C) 2003 Chris Howells <howells@kde.org>
+ *  (C) 2003 Sven Leiber <s.leiber@web.de>
  *
  * This code is under GPL
  *
@@ -10,7 +11,6 @@
 
 
 #include <qdir.h>
-#include <qpushbutton.h>
 #include <qcolor.h>
 #include <qlabel.h>
 #include <qlayout.h>
@@ -30,6 +30,8 @@
 #include <kfiledialog.h>
 #include <kstandarddirs.h>
 #include <kurlrequester.h>
+#include <kaboutdata.h>
+#include <kaboutapplication.h>
 #include <kdebug.h>
 
 #include <stdlib.h>
@@ -41,12 +43,18 @@
 #include "slideshow.moc"
 #include "slideshowcfg.h"
 
+
+#define SLIDESHOW_VERSION "2.3.0"
+static const char *version = SLIDESHOW_VERSION;
+static const char *description = I18N_NOOP("KSlideshow");
+
+
 // libkscreensaver interface
 extern "C"
 {
     const char *kss_applicationName = "kslideshow.kss";
     const char *kss_description = I18N_NOOP( "KSlideshow" );
-    const char *kss_version = "2.2.0";
+    const char *kss_version = SLIDESHOW_VERSION;
 
     KScreenSaver *kss_create( WId id )
     {
@@ -128,6 +136,7 @@
   mDirectory = config->readEntry("Directory", QDir::homeDirPath());
   mDelay = config->readNumEntry("Delay", 10) * 1000;
   mSubdirectory = config->readBoolEntry("SubDirectory", false);
+  mRandomPosition = config->readBoolEntry("RandomPosition", false);
 
   loadDirectory();
 }
@@ -745,11 +754,37 @@
     }
     else
     {
-      x = (ww - iw) >> 1;
-      y = (wh - ih) >> 1;
+      if(iw > ww || ih > wh)
+      {
+        fx = (double)ww / iw;
+	fy = (double)wh / ih;
+	if (fx > fy) fx = fy;
+	if (fx > 2) fx = 2;
+	iw = (int)(iw * fx);
+	ih = (int)(ih * fx);
+	QImage scaledImg = mImage.smoothScale(iw, ih);
+	
+	x = (ww - iw) >> 1;
+	y = (wh - ih) >> 1;
+	
+	p.drawImage(x, y, scaledImg);
+      }
+      else
+      {
+        if(mRandomPosition)
+        {
+          x = rand() % (ww - iw);
+          y = rand() % (wh - ih);
+        }
+        else
+        {
+          x = (ww - iw) >> 1;
+          y = (wh - ih) >> 1;
+        }
 
-      // bitBlt(&mNextScreen, x, y, &mImage, 0, 0, iw, ih, CopyROP, false);
-      p.drawImage(x, y, mImage);
+        // bitBlt(&mNextScreen, x, y, &mImage, 0, 0, iw, ih, CopyROP, false);
+        p.drawImage(x, y, mImage);
+      }
     }
 
     if (mPrintName)
@@ -871,11 +906,7 @@
 
   mSaver = NULL;
 
-  connect(mCbxZoom, SIGNAL(clicked()), SLOT(writeSettings()));
-
-  connect(mCbxRandom, SIGNAL(clicked()), SLOT(writeSettings()));
-
-  connect(mCbxShowName, SIGNAL(clicked()), SLOT(writeSettings()));
+  connect(mCbxZoom, SIGNAL(clicked()), SLOT(slotZoom()));
 
   mPreview->setFixedSize(220, 170);
   mPreview->setBackgroundColor(black);
@@ -886,8 +917,6 @@
   connect(mDirChooser, SIGNAL(returnPressed(const QString &)), \
SLOT(slotDirSelected(const QString &)));  connect(mDirChooser, \
SIGNAL(urlSelected(const QString &)), SLOT(slotDirSelected(const QString &)));  
-  connect(mCbxSubdirectory, SIGNAL(clicked()), SLOT(writeSettings()));
-
   connect(about, SIGNAL(clicked()), SLOT(slotAbout()));
 
   connect(ok, SIGNAL(clicked()), SLOT(slotOkPressed()));
@@ -910,6 +939,7 @@
   mDelay->setValue(config->readNumEntry("Delay", 20));
   mDirChooser->setURL(config->readEntry("Directory"));
   mCbxSubdirectory->setChecked(config->readBoolEntry("SubDirectory", false));
+  mCbxRandomPosition->setChecked(config->readBoolEntry("RandomPosition", false));
 }
 
 
@@ -925,6 +955,7 @@
   config->writeEntry("Delay", mDelay->value());
   config->writeEntry("Directory", mDirChooser->url());
   config->writeEntry("SubDirectory", mCbxSubdirectory->isChecked());
+  config->writeEntry("RandomPosition", mCbxRandomPosition->isChecked());
 
   config->sync();
 
@@ -952,13 +983,25 @@
 
 
 //-----------------------------------------------------------------------------
-void kSlideShowSetup::slotAbout()
+void kSlideShowSetup::slotZoom()
 {
-  KMessageBox::about(this,
-     i18n("SlideShow Version 1.2\n\n"
-     "Copyright (c) 1999 by\n"
-     "Stefan Taferner <taferner@kde.org>\n"
-     "Copyright (c) 2003 by\n"
-     "Chris Howells <howells@kde.org\n"));
+  if(mCbxZoom->isChecked())
+    mCbxRandomPosition->setEnabled(false);
+  else
+    mCbxRandomPosition->setEnabled(true);
 }
 
+
+//-----------------------------------------------------------------------------
+void kSlideShowSetup::slotAbout()
+{
+  KAboutData aboutData( "kslideshow.kss", I18N_NOOP("SlideShow"),
+                       version, description, KAboutData::License_GPL,
+                       "(c) 1999-2003, The KDE Team" );
+  aboutData.addAuthor("Stefan Taferner", 0, "taferner@kde.org");
+  aboutData.addAuthor("Chris Howells", 0, "howells@kde.org");
+  aboutData.addAuthor("Sven Leiber", 0, "s.leiber@web.de");
+  
+  KAboutApplication mAbout(&aboutData, this, 0);
+  mAbout.exec();
+}
diff -ur /home/sven/backup/kdeartwork-backup/kscreensaver/kdesavers/slideshow.h \
                /home/sven/backup/kdeartwork/kscreensaver/kdesavers/slideshow.h
--- /home/sven/backup/kdeartwork-backup/kscreensaver/kdesavers/slideshow.h	2003-05-02 \
                00:09:23.000000000 +0200
+++ /home/sven/backup/kdeartwork/kscreensaver/kdesavers/slideshow.h	2003-06-10 \
00:58:54.000000000 +0200 @@ -1,5 +1,6 @@
 /* Slide Show Screen Saver
  * (C) 1999 Stefan Taferner <taferner@kde.org>
+ * (C) 2003 Sven Leiber <s.leiber@web.de>
  */
 
 
@@ -15,7 +16,9 @@
 #include <qpainter.h>
 #include <qimage.h>
 #include <qcombobox.h>
+
 #include <kscreensaver.h>
+#include <kpushbutton.h>
 
 #include "slideshowcfg.h"
 
@@ -104,6 +107,7 @@
   bool mZoomImages;
   bool mPrintName;
   bool mSubdirectory;
+  bool mRandomPosition;
   int mDelay;
   QString mDirectory;
 
@@ -128,6 +132,7 @@
 protected slots:
   void slotOkPressed();
   void slotAbout();
+  void slotZoom();
   void writeSettings();
   void slotDirSelected(const QString &where);
 
diff -ur /home/sven/backup/kdeartwork-backup/kscreensaver/kdesavers/slideshowcfg.ui \
                /home/sven/backup/kdeartwork/kscreensaver/kdesavers/slideshowcfg.ui
--- /home/sven/backup/kdeartwork-backup/kscreensaver/kdesavers/slideshowcfg.ui	2003-04-20 \
                21:19:47.000000000 +0200
+++ /home/sven/backup/kdeartwork/kscreensaver/kdesavers/slideshowcfg.ui	2003-06-09 \
23:12:08.000000000 +0200 @@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
 <class>SlideshowCfg</class>
 <widget class="QDialog">
     <property name="name">
@@ -8,8 +8,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>414</width>
-            <height>266</height>
+            <width>429</width>
+            <height>290</height>
         </rect>
     </property>
     <property name="caption">
@@ -19,6 +19,12 @@
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
+        <property name="margin">
+            <number>5</number>
+        </property>
+        <property name="spacing">
+            <number>2</number>
+        </property>
         <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
             <property name="name">
                 <cstring>layout12</cstring>
@@ -80,57 +86,23 @@
                 </spacer>
             </hbox>
         </widget>
-        <widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
+        <spacer row="1" column="0">
             <property name="name">
-                <cstring>layout2</cstring>
+                <cstring>spacer11</cstring>
             </property>
-            <hbox>
-                <property name="name">
-                    <cstring>unnamed</cstring>
-                </property>
-                <widget class="QPushButton">
-                    <property name="name">
-                        <cstring>about</cstring>
-                    </property>
-                    <property name="text">
-                        <string>&amp;About</string>
-                    </property>
-                </widget>
-                <spacer>
-                    <property name="name">
-                        <cstring>spacer1</cstring>
-                    </property>
-                    <property name="orientation">
-                        <enum>Horizontal</enum>
-                    </property>
-                    <property name="sizeType">
-                        <enum>Expanding</enum>
-                    </property>
-                    <property name="sizeHint">
-                        <size>
-                            <width>71</width>
-                            <height>20</height>
-                        </size>
-                    </property>
-                </spacer>
-                <widget class="QPushButton">
-                    <property name="name">
-                        <cstring>ok</cstring>
-                    </property>
-                    <property name="text">
-                        <string>&amp;OK</string>
-                    </property>
-                </widget>
-                <widget class="QPushButton">
-                    <property name="name">
-                        <cstring>cancel</cstring>
-                    </property>
-                    <property name="text">
-                        <string>&amp;Cancel</string>
-                    </property>
-                </widget>
-            </hbox>
-        </widget>
+            <property name="orientation">
+                <enum>Vertical</enum>
+            </property>
+            <property name="sizeType">
+                <enum>Expanding</enum>
+            </property>
+            <property name="sizeHint">
+                <size>
+                    <width>20</width>
+                    <height>16</height>
+                </size>
+            </property>
+        </spacer>
         <widget class="QFrame" row="0" column="1" rowspan="2" colspan="1">
             <property name="name">
                 <cstring>mPreview</cstring>
@@ -150,26 +122,9 @@
                 <enum>Plain</enum>
             </property>
         </widget>
-        <spacer row="1" column="0">
-            <property name="name">
-                <cstring>spacer11</cstring>
-            </property>
-            <property name="orientation">
-                <enum>Vertical</enum>
-            </property>
-            <property name="sizeType">
-                <enum>Expanding</enum>
-            </property>
-            <property name="sizeHint">
-                <size>
-                    <width>20</width>
-                    <height>31</height>
-                </size>
-            </property>
-        </spacer>
         <widget class="QLayoutWidget" row="0" column="0">
             <property name="name">
-                <cstring>layout7</cstring>
+                <cstring>layout11</cstring>
             </property>
             <vbox>
                 <property name="name">
@@ -199,6 +154,14 @@
                         <string>Show names</string>
                     </property>
                 </widget>
+                <widget class="QCheckBox">
+                    <property name="name">
+                        <cstring>mCbxRandomPosition</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Random position</string>
+                    </property>
+                </widget>
                 <widget class="QLayoutWidget">
                     <property name="name">
                         <cstring>layout6</cstring>
@@ -239,12 +202,72 @@
                 </widget>
             </vbox>
         </widget>
+        <widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
+            <property name="name">
+                <cstring>layout11</cstring>
+            </property>
+            <hbox>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <widget class="KPushButton">
+                    <property name="name">
+                        <cstring>about</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;About</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+A</string>
+                    </property>
+                </widget>
+                <spacer>
+                    <property name="name">
+                        <cstring>spacer1</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Expanding</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>165</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+                <widget class="KPushButton">
+                    <property name="name">
+                        <cstring>ok</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;OK</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+O</string>
+                    </property>
+                </widget>
+                <widget class="KPushButton">
+                    <property name="name">
+                        <cstring>cancel</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Cancel</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+C</string>
+                    </property>
+                </widget>
+            </hbox>
+        </widget>
     </grid>
 </widget>
+<customwidgets>
+</customwidgets>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>
-    <includehint>kurlrequester.h</includehint>
     <includehint>klineedit.h</includehint>
-    <includehint>kpushbutton.h</includehint>
 </includehints>
 </UI>



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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