On Wednesday 11 August 2010, Aaron J. Seigo wrote:
> On Wednesday, August 11, 2010, todd rme wrote:
> > I would say the mandlebrot wallpaper also benefits from this, since
> > you can see how the colors you select work in practice.  Although it
> 
> easy enough with an in-line preview, but in practice i don't find it a
> necessity. the colours are fairly obvious and hitting "apply" shows me what
>  the real thing is going to end up looking like.

recapping:
* for some wallpaper kinds the monitor preview is just redundant information
* in some wallpapers is easy to build previews without actually using the 
Wallpaper rendering (images, something else?)
* the live preview is quite an important information for some other wallpapers 
that change radically depending on the settings and is not possible to have a 
thumbnail grid, so to see what this is about the only way would be apply and 
then figure out how to undo if one doesn't like the result
* i find reall, really, really overkill a button that shows a fullscreen 
preview of the wallpaper

in the end, if a little live preview is needed should be up to the wallpaper 
implelentation.
the attached patch is a first quick and dirty implementation of tat:
the need of the monitor is decided by Wallpaper::setNeedsPreview(bool)
that at the moment is default off
Image would have it off, slideshow on, mandelbrot and barble on and whatever 
each individual wallpaper needs it or not.

the monitor is now put uder the plugin selection combobox giving a vertical 
layout.
as a sideeffect, user interfaces like the slideshow one that looked too empty 
and squshed together, now with the monitor look more "full" but at the same 
time more spaced

if the idea is good will reviewboard it

Cheers,
Marco Martin
Index: kdelibs/plasma/wallpaper.cpp
===================================================================
--- kdelibs/plasma/wallpaper.cpp	(revision 1162319)
+++ kdelibs/plasma/wallpaper.cpp	(working copy)
@@ -471,7 +471,8 @@
     initialized(false),
     needsConfig(false),
     scriptInitialized(false),
-    previewing(false)
+    previewing(false),
+    needsPreview(false)
 {
     if (wallpaperDescription.isValid()) {
         QString api = wallpaperDescription.property("X-Plasma-API").toString();
@@ -665,6 +666,16 @@
     d->previewing = previewing;
 }
 
+bool Wallpaper::needsPreview() const
+{
+    return d->needsPreview;
+}
+
+void Wallpaper::setNeedsPreview(const bool preview)
+{
+    d->needsPreview = preview;
+}
+
 const Package *Wallpaper::package() const
 {
     return d->package;
Index: kdelibs/plasma/private/wallpaper_p.h
===================================================================
--- kdelibs/plasma/private/wallpaper_p.h	(revision 1162319)
+++ kdelibs/plasma/private/wallpaper_p.h	(working copy)
@@ -77,6 +77,7 @@
     bool needsConfig : 1;
     bool scriptInitialized : 1;
     bool previewing : 1;
+    bool needsPreview : 1;
 };
 
 class LoadImageThread : public QObject, public QRunnable
Index: kdelibs/plasma/wallpaper.h
===================================================================
--- kdelibs/plasma/wallpaper.h	(revision 1162319)
+++ kdelibs/plasma/wallpaper.h	(working copy)
@@ -343,6 +343,9 @@
          */
         void setPreviewing(bool previewing);
 
+        bool needsPreview() const;
+
+
     Q_SIGNALS:
         /**
          * This signal indicates that wallpaper needs to be repainted.
@@ -490,6 +493,8 @@
         //FIXME: KDE5, this must be moved to the dptr
         QList<QAction*> contextActions;
 
+        void setNeedsPreview(const bool preview);
+
     private:
         Q_PRIVATE_SLOT(d, void renderCompleted(WallpaperRenderThread *renderer, int token, const QImage &image,
                                                const QString &sourceImagePath, const QSize &size,
Index: kdebase/workspace/libs/plasmagenericshell/backgrounddialog.cpp
===================================================================
--- kdebase/workspace/libs/plasmagenericshell/backgrounddialog.cpp	(revision 1162601)
+++ kdebase/workspace/libs/plasmagenericshell/backgrounddialog.cpp	(working copy)
@@ -28,24 +28,14 @@
 #include <Plasma/View>
 #include <Plasma/Corona>
 
+#include "kworkspace/screenpreviewwidget.h"
 #include "kworkspace/kactivityinfo.h"
 #include "kworkspace/kactivitycontroller.h"
 
 #include "ui_BackgroundDialog.h"
 #include "ui_ActivityConfiguration.h"
 
-struct WallpaperInfo
-{
-    WallpaperInfo() {}
-
-    WallpaperInfo(const QString &p, const QString &m)
-        : plugin(p),
-          mode(m)
-    {}
-
-    QString plugin;
-    QString mode;
-};
+typedef QPair<QString, QString> WallpaperInfo;
 Q_DECLARE_METATYPE(WallpaperInfo)
 
 // From kcategorizeditemsviewdelegate by Ivan Cukic
@@ -189,6 +179,7 @@
        wallpaper(0),
        view(v),
        containment(c),
+       preview(0),
        modified(false)
     {
     }
@@ -204,13 +195,14 @@
     Plasma::Wallpaper* wallpaper;
     Plasma::View* view;
     QWeakPointer<Plasma::Containment> containment;
+    ScreenPreviewWidget* preview;
     KPageWidgetItem *activityItem;
     KPageWidgetItem *appearanceItem;
     KPageWidgetItem *mouseItem;
     bool modified;
 };
 
-BackgroundDialog::BackgroundDialog(const QSize& /* res */, Plasma::Containment *c, Plasma::View* view,
+BackgroundDialog::BackgroundDialog(const QSize& res, Plasma::Containment *c, Plasma::View* view,
                                    QWidget* parent, const QString &id, KConfigSkeleton *s)
     : KConfigDialog(parent, id, s),
       d(new BackgroundDialogPrivate(c, view))
@@ -227,6 +219,18 @@
     d->activityUi.setupUi(activity);
     d->activityItem = addPage(activity, i18n("Activity"), "plasma");
 
+    qreal previewRatio = (qreal)res.width() / (qreal)res.height();
+    QSize monitorSize(200, int(200 * previewRatio));
+
+    d->backgroundDialogUi.m_monitor->setFixedSize(200, 200);
+    d->backgroundDialogUi.m_monitor->setText(QString());
+    d->backgroundDialogUi.m_monitor->setWhatsThis(i18n(
+        "This picture of a monitor contains a preview of "
+        "what the current settings will look like on your desktop."));
+    d->preview = new ScreenPreviewWidget(d->backgroundDialogUi.m_monitor);
+    d->preview->setRatio(previewRatio);
+    d->preview->resize(200, 200);
+
     connect(this, SIGNAL(finished(int)), this, SLOT(cleanup()));
     connect(this, SIGNAL(okClicked()), this, SLOT(saveConfig()));
     connect(this, SIGNAL(applyClicked()), this, SLOT(saveConfig()));
@@ -339,7 +343,11 @@
     #if 0
     d->wallpaperLabel->setVisible(doWallpaper);
     #endif
+
     d->backgroundDialogUi.m_wallpaperGroup->setVisible(doWallpaper);
+    d->backgroundDialogUi.m_monitor->setVisible(doWallpaper);
+    d->preview->setVisible(doWallpaper);
+
     //kDebug() << "do wallpapers?!" << doWallpaper;
     if (doWallpaper) {
         // Load wallpaper plugins
@@ -394,6 +402,7 @@
         changeBackgroundMode(wallpaperIndex);
     }
 
+
     connect(d->backgroundDialogUi.m_wallpaperMode, SIGNAL(currentIndexChanged(int)), this, SLOT(changeBackgroundMode(int)));
     settingsModified(false);
 }
@@ -411,20 +420,21 @@
         delete widget;
     }
 
-    if (d->wallpaper && d->wallpaper->pluginName() != wallpaperInfo.plugin) {
+    if (d->wallpaper && d->wallpaper->pluginName() != wallpaperInfo.first) {
         delete d->wallpaper;
         d->wallpaper = 0;
     }
 
     if (!d->wallpaper) {
-        d->wallpaper = Plasma::Wallpaper::load(wallpaperInfo.plugin);
+        d->wallpaper = Plasma::Wallpaper::load(wallpaperInfo.first);
     }
 
     if (d->wallpaper) {
         d->wallpaper->setPreviewing(true);
-        d->wallpaper->setRenderingMode(wallpaperInfo.mode);
-        KConfigGroup cfg = wallpaperConfig(wallpaperInfo.plugin);
-        //kDebug() << "making a" << wallpaperInfo.plugin << "in mode" << wallpaperInfo.mode;
+        d->preview->setPreview(d->wallpaper);
+        d->wallpaper->setRenderingMode(wallpaperInfo.second);
+        KConfigGroup cfg = wallpaperConfig(wallpaperInfo.first);
+        //kDebug() << "making a" << wallpaperInfo.first << "in mode" << wallpaperInfo.second;
         if (d->containment) {
             d->wallpaper->setTargetSizeHint(d->containment.data()->size());
         }
@@ -433,6 +443,10 @@
         WallpaperWidget *wallpaperWidget = new WallpaperWidget(d->backgroundDialogUi.m_wallpaperGroup);
         w = d->wallpaper->createConfigurationInterface(wallpaperWidget);
         connect(wallpaperWidget, SIGNAL(modified(bool)), this, SLOT(settingsModified(bool)));
+
+        const bool needsPreview = d->wallpaper->needsPreview();
+        d->backgroundDialogUi.m_monitorWidget->setVisible(needsPreview);
+        d->preview->setVisible(needsPreview);
     }
 
     if (!w) {
@@ -461,6 +475,8 @@
 
 void BackgroundDialog::saveConfig()
 {
+    QString wallpaperPlugin = d->backgroundDialogUi.m_wallpaperMode->itemData(d->backgroundDialogUi.m_wallpaperMode->currentIndex()).value<WallpaperInfo>().first;
+    QString wallpaperMode = d->backgroundDialogUi.m_wallpaperMode->itemData(d->backgroundDialogUi.m_wallpaperMode->currentIndex()).value<WallpaperInfo>().second;
     QString containment = d->activityUi.m_containmentComboBox->itemData(d->activityUi.m_containmentComboBox->currentIndex(),
                                                           AppletDelegate::PluginNameRole).toString();
 
@@ -532,9 +548,7 @@
     }
 
     if (d->containment) {
-        const int index = d->backgroundDialogUi.m_wallpaperMode->currentIndex();
-        WallpaperInfo wallpaperInfo = d->backgroundDialogUi.m_wallpaperMode->itemData(index).value<WallpaperInfo>();
-        d->containment.data()->setWallpaper(wallpaperInfo.plugin, wallpaperInfo.mode);
+        d->containment.data()->setWallpaper(wallpaperPlugin, wallpaperMode);
     }
 
     settingsModified(false);
Index: kdebase/workspace/libs/plasmagenericshell/BackgroundDialog.ui
===================================================================
--- kdebase/workspace/libs/plasmagenericshell/BackgroundDialog.ui	(revision 1162601)
+++ kdebase/workspace/libs/plasmagenericshell/BackgroundDialog.ui	(working copy)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>443</width>
-    <height>290</height>
+    <width>435</width>
+    <height>412</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -23,7 +23,96 @@
    </size>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="1" column="0" colspan="3">
+   <item row="0" column="0">
+    <widget class="QLabel" name="m_wallpaperTypeLabel">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>129</width>
+       <height>0</height>
+      </size>
+     </property>
+     <property name="text">
+      <string>&amp;Type:</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+     <property name="buddy">
+      <cstring>m_wallpaperMode</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QComboBox" name="m_wallpaperMode">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>150</width>
+       <height>0</height>
+      </size>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="2">
+    <widget class="QWidget" name="m_monitorWidget" native="true">
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <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>
+      <item>
+       <widget class="QLabel" name="m_monitor">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Monitor</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer_2">
+        <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>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="2">
     <widget class="QWidget" name="m_wallpaperGroup" native="true">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -54,47 +143,6 @@
      </layout>
     </widget>
    </item>
-   <item row="0" column="2">
-    <widget class="QComboBox" name="m_wallpaperMode">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-       <horstretch>1</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="minimumSize">
-      <size>
-       <width>150</width>
-       <height>0</height>
-      </size>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="1">
-    <widget class="QLabel" name="m_wallpaperTypeLabel">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="minimumSize">
-      <size>
-       <width>129</width>
-       <height>0</height>
-      </size>
-     </property>
-     <property name="text">
-      <string>&amp;Type:</string>
-     </property>
-     <property name="alignment">
-      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-     </property>
-     <property name="buddy">
-      <cstring>m_wallpaperMode</cstring>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <resources/>
Index: kdebase/workspace/plasma/generic/wallpapers/image/image.cpp
===================================================================
--- kdebase/workspace/plasma/generic/wallpapers/image/image.cpp	(revision 1162601)
+++ kdebase/workspace/plasma/generic/wallpapers/image/image.cpp	(working copy)
@@ -69,6 +69,8 @@
         m_mode = renderingMode().name();
     }
 
+    setNeedsPreview(m_mode != "SingleImage");
+kWarning()<<"BBBB"<<needsPreview();
     calculateGeometry();
 
     m_delay = config.readEntry("slideTimer", 10);
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to