mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kdeplasma-addons: set the wallpaper of all containments from frame applet
otherwise if the frame applet is in panel the action does nothing (because its containment is not the desktop containment), the folderview applet has to do the same Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1332e8a218
commit
9e3d5a4136
1 changed files with 32 additions and 22 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <QCheckBox>
|
||||
#include <QFileInfo>
|
||||
#include <QStandardItemModel>
|
||||
#include <Plasma/Corona>
|
||||
#include <Plasma/Containment>
|
||||
#include <Plasma/Wallpaper>
|
||||
|
||||
|
@ -55,6 +56,33 @@
|
|||
#include "picture.h"
|
||||
#include "slideshow.h"
|
||||
|
||||
void kSetContainmentWallpaper(Plasma::Containment *containment, const KUrl &url, const QString &urlMime)
|
||||
{
|
||||
|
||||
if (containment->wallpaper() && containment->wallpaper()->supportsMimetype(urlMime)) {
|
||||
containment->wallpaper()->setUrls(url);
|
||||
} else {
|
||||
KPluginInfo::List wallpaperList = Plasma::Wallpaper::listWallpaperInfoForMimetype(urlMime);
|
||||
bool image = false;
|
||||
foreach (const KPluginInfo &wallpaper, wallpaperList) {
|
||||
if (wallpaper.pluginName() == "image") {
|
||||
image = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (image) {
|
||||
containment->setWallpaper("image");
|
||||
} else if (!wallpaperList.isEmpty()) {
|
||||
containment->setWallpaper(wallpaperList.at(0).name());
|
||||
}
|
||||
|
||||
if (containment->wallpaper()) {
|
||||
containment->wallpaper()->setUrls(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Frame::Frame(QObject *parent, const QVariantList &args)
|
||||
: Plasma::Applet(parent, args),
|
||||
m_configDialog(0),
|
||||
|
@ -145,29 +173,11 @@ void Frame::setImageAsWallpaper()
|
|||
url = m_currentUrl;
|
||||
}
|
||||
|
||||
kDebug() << KMimeType::findByUrl(url).data()->name();
|
||||
const QString urlMime = KMimeType::findByUrl(url)->name();
|
||||
kDebug() << urlMime;
|
||||
|
||||
if (containment()->wallpaper() && containment()->wallpaper()->supportsMimetype(KMimeType::findByUrl(url).data()->name())) {
|
||||
containment()->wallpaper()->setUrls(url);
|
||||
} else {
|
||||
KPluginInfo::List wallpaperList = containment()->wallpaper()->listWallpaperInfoForMimetype(KMimeType::findByUrl(url).data()->name());
|
||||
bool image = false;
|
||||
foreach (const KPluginInfo &wallpaper, wallpaperList) {
|
||||
if (wallpaper.pluginName() == "image") {
|
||||
image = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (image) {
|
||||
containment()->setWallpaper("image");
|
||||
} else if (!wallpaperList.isEmpty()) {
|
||||
containment()->setWallpaper(wallpaperList.at(0).name());
|
||||
}
|
||||
|
||||
if (containment()->wallpaper()) {
|
||||
containment()->wallpaper()->setUrls(url);
|
||||
}
|
||||
foreach (Plasma::Containment *c, containment()->corona()->containments()) {
|
||||
kSetContainmentWallpaper(c, url, urlMime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue