2016-12-31 00:26:38 +03:00
# include "dockpackage.h"
# include <QDebug>
2016-12-25 10:25:27 +03:00
# include <KPackage/PackageLoader>
# include <KI18n/KLocalizedString>
2016-12-31 00:26:38 +03:00
namespace Latte {
DockPackage : : DockPackage ( QObject * parent , const QVariantList & args )
2016-12-25 10:25:27 +03:00
: KPackage : : PackageStructure ( parent , args )
{
}
2016-12-31 00:26:38 +03:00
DockPackage : : ~ DockPackage ( )
2016-12-25 10:25:27 +03:00
{
}
2016-12-31 00:26:38 +03:00
void DockPackage : : initPackage ( KPackage : : Package * package )
2016-12-25 10:25:27 +03:00
{
auto fallback = KPackage : : PackageLoader : : self ( ) - > loadPackage ( " Plasma/Shell " , " org.kde.plasma.desktop " ) ;
package - > setDefaultPackageRoot ( QStringLiteral ( " plasma/shells/ " ) ) ;
2016-12-25 20:13:25 +03:00
package - > setPath ( " org.kde.latte.shell " ) ;
2016-12-31 00:26:38 +03:00
package - > addFileDefinition ( " lattedockui " , QStringLiteral ( " views/Panel.qml " ) , i18n ( " Latte Dock panel " ) ) ;
2016-12-25 10:25:27 +03:00
//Configuration
2016-12-31 00:26:38 +03:00
package - > addFileDefinition ( " lattedockconfigurationui " , QStringLiteral ( " configuration/LatteDockConfiguration.qml " ) , i18n ( " Dock configuration UI " ) ) ;
2016-12-25 10:25:27 +03:00
package - > addFileDefinition ( " configmodel " , QStringLiteral ( " configuration/config.qml " ) , i18n ( " Config model " ) ) ;
package - > setFallbackPackage ( fallback ) ;
qDebug ( ) < < " package is valid " < < package - > isValid ( ) ;
}
2016-12-31 00:26:38 +03:00
void DockPackage : : pathChanged ( KPackage : : Package * package )
2016-12-25 10:25:27 +03:00
{
if ( ! package - > metadata ( ) . isValid ( ) )
return ;
const QString pluginName = package - > metadata ( ) . pluginId ( ) ;
2016-12-25 20:13:25 +03:00
if ( ! pluginName . isEmpty ( ) & & pluginName ! = " org.kde.latte.shell " ) {
2016-12-28 18:33:59 +03:00
auto fallback = KPackage : : PackageLoader : : self ( ) - > loadPackage ( " Plasma/Shell " , " org.kde.latte.shell " ) ;
2016-12-25 10:25:27 +03:00
package - > setFallbackPackage ( fallback ) ;
2016-12-25 20:13:25 +03:00
} else if ( pluginName . isEmpty ( ) | | pluginName = = " org.kde.latte.shell " ) {
2016-12-25 10:25:27 +03:00
package - > setFallbackPackage ( KPackage : : Package ( ) ) ;
}
}
2016-12-31 00:26:38 +03:00
}