2019-01-07 20:33:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pluginloader.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QLibrary>
|
2020-07-07 17:45:20 +08:00
|
|
|
#include <QGSettings>
|
2021-04-27 10:30:00 +09:00
|
|
|
|
2021-07-26 16:10:50 +08:00
|
|
|
#include <DSysInfo>
|
|
|
|
|
|
|
|
DCORE_USE_NAMESPACE
|
|
|
|
|
2019-01-07 20:33:15 +08:00
|
|
|
PluginLoader::PluginLoader(const QString &pluginDirPath, QObject *parent)
|
|
|
|
: QThread(parent)
|
|
|
|
, m_pluginDirPath(pluginDirPath)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginLoader::run()
|
|
|
|
{
|
2019-01-30 15:55:25 +08:00
|
|
|
QDir pluginsDir(m_pluginDirPath);
|
2021-01-27 15:38:13 +08:00
|
|
|
const QStringList files = pluginsDir.entryList(QDir::Files);
|
2021-03-16 13:16:30 +08:00
|
|
|
|
2021-08-02 17:00:24 +08:00
|
|
|
auto getDisablePluginList = [ = ] {
|
2021-03-16 13:16:30 +08:00
|
|
|
if (QGSettings::isSchemaInstalled("com.deepin.dde.dock.disableplugins")) {
|
|
|
|
QGSettings gsetting("com.deepin.dde.dock.disableplugins", "/com/deepin/dde/dock/disableplugins/");
|
|
|
|
return gsetting.get("disable-plugins-list").toStringList();
|
|
|
|
}
|
|
|
|
return QStringList();
|
|
|
|
};
|
|
|
|
|
|
|
|
const QStringList disable_plugins_list = getDisablePluginList();
|
2019-01-07 20:33:15 +08:00
|
|
|
|
2021-01-27 15:38:13 +08:00
|
|
|
QStringList plugins;
|
|
|
|
|
|
|
|
// 查找可用插件
|
2021-08-02 17:00:24 +08:00
|
|
|
for (QString file : files) {
|
2019-01-07 20:33:15 +08:00
|
|
|
if (!QLibrary::isLibrary(file))
|
|
|
|
continue;
|
|
|
|
|
2021-07-26 16:10:50 +08:00
|
|
|
// 社区版需要加载键盘布局,其他不需要
|
|
|
|
if (file.contains("libkeyboard-layout") && !DSysInfo::isCommunityEdition())
|
|
|
|
continue;
|
|
|
|
|
2019-01-07 20:33:15 +08:00
|
|
|
// TODO: old dock plugins is uncompatible
|
|
|
|
if (file.startsWith("libdde-dock-"))
|
|
|
|
continue;
|
|
|
|
|
2020-07-07 17:45:20 +08:00
|
|
|
if (disable_plugins_list.contains(file)) {
|
|
|
|
qDebug() << "disable loading plugin:" << file;
|
|
|
|
continue;
|
|
|
|
}
|
2021-08-02 17:00:24 +08:00
|
|
|
|
2021-01-27 15:38:13 +08:00
|
|
|
plugins << file;
|
2021-04-27 10:30:00 +09:00
|
|
|
}
|
2022-06-30 16:02:37 +08:00
|
|
|
|
2021-01-27 15:38:13 +08:00
|
|
|
for (auto plugin : plugins) {
|
2021-03-09 13:29:02 +08:00
|
|
|
emit pluginFounded(pluginsDir.absoluteFilePath(plugin));
|
2019-01-07 20:33:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
emit finished();
|
|
|
|
}
|