|
|
|
@ -26,6 +26,7 @@
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QDirIterator>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QTemporaryDir>
|
|
|
|
|
|
|
|
|
@ -75,6 +76,11 @@ Factory::~Factory()
|
|
|
|
|
m_parentWidget->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Factory::pluginExists(QString id) const
|
|
|
|
|
{
|
|
|
|
|
return m_plugins.contains(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Factory::customPluginsCount()
|
|
|
|
|
{
|
|
|
|
|
return m_customPluginIds.count();
|
|
|
|
@ -90,6 +96,10 @@ QStringList Factory::customPluginNames()
|
|
|
|
|
return m_customPluginNames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList Factory::customLocalPluginIds()
|
|
|
|
|
{
|
|
|
|
|
return m_customLocalPluginIds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KPluginMetaData Factory::metadata(QString pluginId)
|
|
|
|
|
{
|
|
|
|
@ -105,6 +115,7 @@ void Factory::reload()
|
|
|
|
|
m_plugins.clear();
|
|
|
|
|
m_customPluginIds.clear();
|
|
|
|
|
m_customPluginNames.clear();
|
|
|
|
|
m_customLocalPluginIds.clear();
|
|
|
|
|
|
|
|
|
|
for(const auto &path : m_watchedPaths) {
|
|
|
|
|
QDir standard(path);
|
|
|
|
@ -129,6 +140,10 @@ void Factory::reload()
|
|
|
|
|
m_customPluginNames << metadata.name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (standard.absolutePath().startsWith(QDir::homePath())) {
|
|
|
|
|
m_customLocalPluginIds << metadata.pluginId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString pluginPath = metadata.fileName().remove("metadata.desktop");
|
|
|
|
|
qDebug() << " Indicator Package Loaded ::: " << metadata.name() << " [" << metadata.pluginId() << "]" << " - [" <<pluginPath<<"]";
|
|
|
|
|
/*qDebug() << " Indicator value ::: " << metadata.pluginId();
|
|
|
|
@ -236,7 +251,6 @@ Latte::Types::ImportExportState Factory::importIndicatorFile(QString compressedF
|
|
|
|
|
QDir(installPath).removeRecursively();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Identify Plasma Desktop version
|
|
|
|
|
QProcess process;
|
|
|
|
|
process.start(QString("mv " +packagePath + " " + installPath));
|
|
|
|
|
process.waitForFinished();
|
|
|
|
@ -250,6 +264,39 @@ Latte::Types::ImportExportState Factory::importIndicatorFile(QString compressedF
|
|
|
|
|
return Latte::Types::Failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Factory::removeIndicator(QString id)
|
|
|
|
|
{
|
|
|
|
|
if (m_plugins.contains(id)) {
|
|
|
|
|
QString pluginName = m_plugins[id].name();
|
|
|
|
|
|
|
|
|
|
auto msg = new QMessageBox(m_parentWidget);
|
|
|
|
|
msg->setIcon(QMessageBox::Warning);
|
|
|
|
|
msg->setWindowTitle(i18n("Remove Indicator"));
|
|
|
|
|
msg->setText(
|
|
|
|
|
i18n("Do you want to remove <b>%0</b> indicator from your system?").arg(pluginName));
|
|
|
|
|
msg->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
|
|
|
msg->setDefaultButton(QMessageBox::No);
|
|
|
|
|
|
|
|
|
|
connect(msg, &QMessageBox::finished, this, [ &, msg, id, pluginName](int result) {
|
|
|
|
|
auto showRemovedSucceed = [](QString name) {
|
|
|
|
|
auto notification = new KNotification("remove-done", KNotification::CloseOnTimeout);
|
|
|
|
|
notification->setText(i18nc("indicator_name, removed success","<b>%0</b> indicator removed successfully").arg(name));
|
|
|
|
|
notification->sendEvent();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (result == QMessageBox::Yes) {
|
|
|
|
|
qDebug() << "Trying to remove indicator :: " << id;
|
|
|
|
|
QProcess process;
|
|
|
|
|
process.start(QString("kpackagetool5 -r " +id + " -t Latte/Indicator"));
|
|
|
|
|
process.waitForFinished();
|
|
|
|
|
showRemovedSucceed(pluginName);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
msg->open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Factory::downloadIndicator()
|
|
|
|
|
{
|
|
|
|
|
KNS3::DownloadDialog dialog(QStringLiteral("latte-indicators.knsrc"), m_parentWidget);
|
|
|
|
|