basic support for wallpapers
This commit is contained in:
parent
75ca61159f
commit
db078f8b53
@ -57,7 +57,7 @@ public:
|
||||
desktop(-1), // all desktops
|
||||
lastDesktop(-1),
|
||||
type(Containment::NoContainmentType),
|
||||
drawWallpaper(true),
|
||||
drawWallpaper(false),
|
||||
containmentActionsSource(Global)
|
||||
{
|
||||
}
|
||||
|
@ -21,10 +21,16 @@
|
||||
|
||||
#include "containmentinterface.h"
|
||||
|
||||
#include <QQmlExpression>
|
||||
#include <QQmlProperty>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
#include <Plasma/Corona>
|
||||
#include <Plasma/Package>
|
||||
#include <Plasma/PluginLoader>
|
||||
|
||||
#include "declarative/qmlobject.h"
|
||||
|
||||
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
||||
: AppletInterface(parent)
|
||||
@ -41,6 +47,7 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
||||
connect(containment()->corona(), SIGNAL(availableScreenRegionChanged()),
|
||||
this, SIGNAL(availableScreenRegionChanged()));
|
||||
}
|
||||
loadWallpaper();
|
||||
}
|
||||
|
||||
QVariantList ContainmentInterface::applets()
|
||||
@ -56,7 +63,13 @@ QVariantList ContainmentInterface::applets()
|
||||
|
||||
void ContainmentInterface::setDrawWallpaper(bool drawWallpaper)
|
||||
{
|
||||
if (drawWallpaper == m_appletScriptEngine->drawWallpaper()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_appletScriptEngine->setDrawWallpaper(drawWallpaper);
|
||||
|
||||
loadWallpaper();
|
||||
}
|
||||
|
||||
bool ContainmentInterface::drawWallpaper()
|
||||
@ -139,7 +152,41 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
|
||||
|
||||
void ContainmentInterface::loadWallpaper()
|
||||
{
|
||||
if (m_appletScriptEngine->drawWallpaper()) {
|
||||
if (m_wallpaperQmlObject) {
|
||||
return;
|
||||
}
|
||||
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
|
||||
pkg.setPath("org.kde.wallpaper.image");
|
||||
|
||||
m_wallpaperQmlObject = new QmlObject(this);
|
||||
m_wallpaperQmlObject->setQmlPath(pkg.filePath("mainscript"));
|
||||
|
||||
if (m_wallpaperQmlObject->mainComponent() &&
|
||||
m_wallpaperQmlObject->rootObject() &&
|
||||
!m_wallpaperQmlObject->mainComponent()->isError()) {
|
||||
m_wallpaperQmlObject->rootObject()->setProperty("z", -1000);
|
||||
m_wallpaperQmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
|
||||
|
||||
//set anchors
|
||||
QQmlExpression expr(m_appletScriptEngine->engine()->rootContext(), m_wallpaperQmlObject->rootObject(), "parent");
|
||||
QQmlProperty prop(m_wallpaperQmlObject->rootObject(), "anchors.fill");
|
||||
prop.write(expr.evaluate());
|
||||
|
||||
} else if (m_wallpaperQmlObject->mainComponent()) {
|
||||
qWarning() << "Error loading the wallpaper" << m_wallpaperQmlObject->mainComponent()->errors();
|
||||
m_wallpaperQmlObject->deleteLater();
|
||||
m_wallpaperQmlObject = 0;
|
||||
|
||||
} else {
|
||||
qWarning() << "Error loading the wallpaper, package not found";
|
||||
}
|
||||
|
||||
} else {
|
||||
m_wallpaperQmlObject->deleteLater();
|
||||
m_wallpaperQmlObject = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QString ContainmentInterface::activityId() const
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include "appletinterface.h"
|
||||
|
||||
class QmlObject;
|
||||
|
||||
class ContainmentInterface : public AppletInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -72,6 +74,9 @@ protected Q_SLOTS:
|
||||
void appletAddedForward(Plasma::Applet *applet, const QPointF &pos);
|
||||
void appletRemovedForward(Plasma::Applet *applet);
|
||||
void loadWallpaper();
|
||||
|
||||
private:
|
||||
QmlObject *m_wallpaperQmlObject;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
add_subdirectory(desktop)
|
||||
add_subdirectory(toolbox)
|
||||
add_subdirectory(wallpaper)
|
||||
|
@ -11,7 +11,6 @@ Name[uk]=Набір інструментів для стаціонарних к
|
||||
Name[x-test]=xxDesktop Toolboxxx
|
||||
Type=Service
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-KDE-ParentApp=
|
||||
X-KDE-PluginInfo-Author=Marco Martin
|
||||
X-KDE-PluginInfo-Category=
|
||||
|
4
shell/qmlpackages/wallpaper/CMakeLists.txt
Normal file
4
shell/qmlpackages/wallpaper/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
install(DIRECTORY . DESTINATION ${DATA_INSTALL_DIR}/plasma/packages/org.kde.wallpaper.image PATTERN .svn EXCLUDE PATTERN CMakeLists.txt EXCLUDE PATTERN Messages.sh EXCLUDE)
|
||||
|
||||
|
25
shell/qmlpackages/wallpaper/contents/ui/main.qml
Normal file
25
shell/qmlpackages/wallpaper/contents/ui/main.qml
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
color: "darkblue"
|
||||
|
||||
}
|
15
shell/qmlpackages/wallpaper/metadata.desktop
Normal file
15
shell/qmlpackages/wallpaper/metadata.desktop
Normal file
@ -0,0 +1,15 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Keywords=
|
||||
Name=Image wallpaper
|
||||
Type=Service
|
||||
|
||||
X-KDE-ParentApp=
|
||||
X-KDE-PluginInfo-Author=Marco Martin
|
||||
X-KDE-PluginInfo-Category=
|
||||
X-KDE-PluginInfo-Email=mart@kde.org
|
||||
X-KDE-PluginInfo-License=GPLv2+
|
||||
X-KDE-PluginInfo-Name=org.kde.wallpaper.image
|
||||
X-KDE-PluginInfo-Version=
|
||||
X-KDE-PluginInfo-Website=
|
||||
X-Plasma-MainScript=ui/main.qml
|
@ -21,9 +21,8 @@ import QtQuick 2.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id: root
|
||||
color: "darkblue"
|
||||
width: 640
|
||||
height: 480
|
||||
|
||||
|
@ -61,6 +61,7 @@ void View::setContainment(Plasma::Containment *cont)
|
||||
qDebug() << "using as graphic containment" << graphicObject << m_containment.data();
|
||||
|
||||
//graphicObject->setProperty("visible", false);
|
||||
graphicObject->setProperty("drawWallpaper", true);
|
||||
graphicObject->setProperty("parent", QVariant::fromValue(rootObject()));
|
||||
rootObject()->setProperty("containment", QVariant::fromValue(graphicObject));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user