dde-dock/frame/util/pluginloader.cpp
qiuchangxing 110c4966b1 fix: 修复任务栏“显示桌面”无法移除
正常情况下按下菜单的显示桌面,先把读的bool类型值取反写进去,再读,再根据读的值如果为false添加插件true移除插件,插件加载是否完成判断代码存在问题,导致插件位置标签未写入到json变量里,导致在保存插件是否显示状态值时,将位置值写到了状态标签上,使得值一直是正数,导致读到的值一直是false只能添加插件,不能移除插件,

Log: 修复任务栏“显示桌面”无法移除,按下菜单的显示桌面无法移除显示桌面插件
Bug: https://pms.uniontech.com/zentao/bug-view-74956.html
Change-Id: Ie474c9696e545c8f90b540ec54dd31fd892ebe83
2021-04-26 17:28:23 +09:00

76 lines
2.2 KiB
C++

/*
* 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>
#include <QGSettings>
#include <QApplication>
PluginLoader::PluginLoader(const QString &pluginDirPath, QObject *parent)
: QThread(parent)
, m_pluginDirPath(pluginDirPath)
{
}
void PluginLoader::run()
{
QDir pluginsDir(m_pluginDirPath);
const QStringList files = pluginsDir.entryList(QDir::Files);
auto getDisablePluginList = [ = ]{
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();
QStringList plugins;
// 查找可用插件
for (QString file : files)
{
if (!QLibrary::isLibrary(file))
continue;
// TODO: old dock plugins is uncompatible
if (file.startsWith("libdde-dock-"))
continue;
if (disable_plugins_list.contains(file)) {
qDebug() << "disable loading plugin:" << file;
continue;
}
plugins << file;
}
qApp->setProperty("PLUGINSNUMBER", plugins.count());
for (auto plugin : plugins) {
emit pluginFounded(pluginsDir.absoluteFilePath(plugin));
}
emit finished();
}