2015-11-23 20:31:20 +01:00
/*
2020-08-13 21:08:54 +02:00
SPDX - FileCopyrightText : 2015 Marco Martin < notmart @ gmail . com >
SPDX - License - Identifier : GPL - 2.0 - only OR GPL - 3.0 - only OR LicenseRef - KDE - Accepted - GPL
*/
2015-11-23 20:31:20 +01:00
# include "customcorona.h"
# include <QDebug>
# include <QAction>
# include <KActionCollection>
# include <KPackage/Package>
# include <KPackage/PackageLoader>
# include <Plasma/PluginLoader>
CustomCorona : : CustomCorona ( QObject * parent )
: Plasma : : Corona ( parent )
{
KPackage : : Package package = KPackage : : PackageLoader : : self ( ) - > loadPackage ( QStringLiteral ( " Plasma/Shell " ) ) ;
2015-11-24 12:15:11 +01:00
//applications that want to load a plasma scene would have to load their own shell.. TODO: have a simple shell in plasma-framework for this purpose?
2015-11-23 20:31:20 +01:00
package . setPath ( QStringLiteral ( " org.kde.plasma.desktop " ) ) ;
setKPackage ( package ) ;
qmlRegisterUncreatableType < PlasmaQuick : : ContainmentView > ( " org.kde.plasma.shell " , 2 , 0 , " Desktop " , QStringLiteral ( " It is not possible to create objects of type Desktop " ) ) ;
m_view = new PlasmaQuick : : ContainmentView ( this ) ;
2017-12-18 13:00:14 +01:00
m_view - > setSource ( package . fileUrl ( " views " , QStringLiteral ( " Desktop.qml " ) ) ) ;
2015-11-23 20:31:20 +01:00
m_view - > show ( ) ;
load ( ) ;
}
QRect CustomCorona : : screenGeometry ( int id ) const
{
Q_UNUSED ( id ) ;
//TODO?
return QRect ( ) ;
}
void CustomCorona : : load ( )
{
loadLayout ( QStringLiteral ( " exampleplasmashell-appletsrc " ) ) ;
bool desktopFound = false ;
for ( auto c : containments ( ) ) {
if ( c - > containmentType ( ) = = Plasma : : Types : : DesktopContainment ) {
desktopFound = true ;
break ;
}
}
if ( ! desktopFound ) {
qDebug ( ) < < " Loading default layout " ;
Plasma : : Containment * c = createContainment ( QStringLiteral ( " org.kde.desktopcontainment " ) ) ;
2018-01-26 15:48:27 +01:00
c - > createApplet ( QStringLiteral ( " org.kde.plasma.analogclock " ) ) ;
2015-11-23 20:31:20 +01:00
saveLayout ( QStringLiteral ( " exampleplasmashell-appletsrc " ) ) ;
}
//don't let containments to be removed
for ( auto c : containments ( ) ) {
if ( c - > containmentType ( ) = = Plasma : : Types : : DesktopContainment ) {
2015-11-24 12:15:11 +01:00
//example of a shell without a wallpaper
2018-01-26 15:48:27 +01:00
c - > setWallpaper ( QStringLiteral ( " null " ) ) ;
2015-11-23 20:31:20 +01:00
m_view - > setContainment ( c ) ;
2018-01-26 15:48:27 +01:00
if ( QAction * removeAction = c - > actions ( ) - > action ( QStringLiteral ( " remove " ) ) ) {
2015-11-23 20:31:20 +01:00
removeAction - > deleteLater ( ) ;
}
break ;
}
}
}
# include "moc_customcorona.cpp"