mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 任务栏多任务视图不能正常移除 (#771)
1.通过任务栏右键移除按钮时,移除对应插件 2.显示桌面和多任务视图需要加入到快捷插件显示中 Log: 修复任务栏多任务视图不能正常移除的问题 Bug: https://github.com/linuxdeepin/developer-center/issues/3599 Influence: 任务栏显示桌面合多任务视图插件的显示
This commit is contained in:
parent
67c66658ee
commit
16ca6eaee9
@ -17,7 +17,7 @@
|
||||
"visibility":"public"
|
||||
},
|
||||
"Dock_Quick_Plugins": {
|
||||
"value": ["power", "network", "shutdown", "trash"],
|
||||
"value": ["power", "network", "shutdown", "trash", "show-desktop", "multitasking"],
|
||||
"serial": 0,
|
||||
"flags": [],
|
||||
"name": "显示在任务栏上的快捷插件",
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#define PLUGIN_STATE_KEY "enable"
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
using namespace Dock;
|
||||
@ -121,7 +120,7 @@ void MultitaskingPlugin::invokedMenuItem(const QString &itemKey, const QString &
|
||||
.arg(1)
|
||||
.call();
|
||||
} else if (menuId == "remove") {
|
||||
pluginStateSwitched();
|
||||
m_proxyInter->itemRemoved(this, PLUGIN_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,5 +152,5 @@ PluginsItemInterface::PluginType MultitaskingPlugin::type()
|
||||
|
||||
PluginFlags MultitaskingPlugin::flags() const
|
||||
{
|
||||
return PluginFlag::Type_Fixed | PluginFlag::Attribute_ForceDock;
|
||||
}
|
||||
return PluginFlag::Type_Fixed | Attribute_CanSetting;
|
||||
}
|
@ -9,11 +9,9 @@
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
||||
#define PLUGIN_STATE_KEY "enable"
|
||||
using namespace Dock;
|
||||
ShowDesktopPlugin::ShowDesktopPlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_pluginLoaded(false)
|
||||
, m_showDesktopWidget(nullptr)
|
||||
, m_tipsLabel(new TipsWidget)
|
||||
{
|
||||
@ -51,21 +49,8 @@ void ShowDesktopPlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
if (!pluginIsDisable()) {
|
||||
loadPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowDesktopPlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, pluginIsDisable());
|
||||
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool ShowDesktopPlugin::pluginIsDisable()
|
||||
{
|
||||
return !m_proxyInter->getValue(this, PLUGIN_STATE_KEY, true).toBool();
|
||||
m_showDesktopWidget.reset(new ShowDesktopWidget);
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
|
||||
const QString ShowDesktopPlugin::itemCommand(const QString &itemKey)
|
||||
@ -113,7 +98,7 @@ void ShowDesktopPlugin::invokedMenuItem(const QString &itemKey, const QString &m
|
||||
if (menuId == "show-desktop") {
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle", QStringList());
|
||||
} else if (menuId == "remove") {
|
||||
pluginStateSwitched();
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,11 +123,6 @@ void ShowDesktopPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void ShowDesktopPlugin::pluginSettingsChanged()
|
||||
{
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
PluginsItemInterface::PluginType ShowDesktopPlugin::type()
|
||||
{
|
||||
return PluginType::Fixed;
|
||||
@ -150,41 +130,5 @@ PluginsItemInterface::PluginType ShowDesktopPlugin::type()
|
||||
|
||||
PluginFlags ShowDesktopPlugin::flags() const
|
||||
{
|
||||
return PluginFlag::Type_Fixed | PluginFlag::Attribute_ForceDock;
|
||||
}
|
||||
|
||||
void ShowDesktopPlugin::updateVisible()
|
||||
{
|
||||
if (pluginIsDisable())
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
else
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
|
||||
void ShowDesktopPlugin::loadPlugin()
|
||||
{
|
||||
if (m_pluginLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_pluginLoaded = true;
|
||||
|
||||
m_showDesktopWidget.reset(new ShowDesktopWidget);
|
||||
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
void ShowDesktopPlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (pluginIsDisable()) {
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
updateVisible();
|
||||
}
|
||||
return PluginFlag::Type_Fixed | Attribute_CanSetting;
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ public:
|
||||
const QString pluginName() const override;
|
||||
const QString pluginDisplayName() const override;
|
||||
void init(PluginProxyInterface *proxyInter) override;
|
||||
void pluginStateSwitched() override;
|
||||
bool pluginIsAllowDisable() override { return true; }
|
||||
bool pluginIsDisable() override;
|
||||
QWidget *itemWidget(const QString &itemKey) override;
|
||||
QWidget *itemTipsWidget(const QString &itemKey) override;
|
||||
const QString itemCommand(const QString &itemKey) override;
|
||||
@ -36,18 +34,10 @@ public:
|
||||
void refreshIcon(const QString &itemKey) override;
|
||||
int itemSortKey(const QString &itemKey) override;
|
||||
void setSortKey(const QString &itemKey, const int order) override;
|
||||
void pluginSettingsChanged() override;
|
||||
PluginType type() override;
|
||||
PluginFlags flags() const override;
|
||||
|
||||
private:
|
||||
void updateVisible();
|
||||
void loadPlugin();
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
bool m_pluginLoaded;
|
||||
|
||||
QScopedPointer<ShowDesktopWidget> m_showDesktopWidget;
|
||||
QScopedPointer<Dock::TipsWidget> m_tipsLabel;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user