mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
add new plugin interface to allow disable plugin
Change-Id: I44ee961151f05bf98c332d28088938bda544740e
This commit is contained in:
parent
82ebb240b9
commit
ae785f6f9a
Notes:
Deepin Code Review
2017-10-23 10:17:40 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Mon, 23 Oct 2017 10:17:40 +0800 Reviewed-on: https://cr.deepin.io/27284 Project: dde/dde-dock Branch: refs/heads/master
@ -48,6 +48,11 @@ const QList<DockItem *> DockItemController::itemList() const
|
||||
return m_itemList;
|
||||
}
|
||||
|
||||
const QList<PluginsItemInterface *> DockItemController::pluginList() const
|
||||
{
|
||||
return m_pluginsInter->m_pluginList.keys();
|
||||
}
|
||||
|
||||
bool DockItemController::appIsOnDock(const QString &appDesktop) const
|
||||
{
|
||||
return m_appInter->IsOnDock(appDesktop);
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
~DockItemController();
|
||||
|
||||
const QList<DockItem *> itemList() const;
|
||||
const QList<PluginsItemInterface *> pluginList() const;
|
||||
bool appIsOnDock(const QString &appDesktop) const;
|
||||
bool itemIsInContainer(DockItem * const item) const;
|
||||
void setDropping(const bool dropping);
|
||||
|
@ -35,6 +35,8 @@ class DockPluginsController : public QObject, PluginProxyInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class DockItemController;
|
||||
|
||||
public:
|
||||
explicit DockPluginsController(DockItemController *itemControllerInter = 0);
|
||||
~DockPluginsController();
|
||||
@ -61,8 +63,6 @@ private:
|
||||
PluginsItem *pluginItemAt(PluginsItemInterface * const itemInter, const QString &itemKey) const;
|
||||
|
||||
private:
|
||||
// QList<PluginsItemInterface *> m_pluginsInterfaceList;
|
||||
// QList<QPluginLoader *> m_pluginLoaderList;
|
||||
QMap<PluginsItemInterface *, QMap<QString, PluginsItem *>> m_pluginList;
|
||||
DockItemController *m_itemControllerInter;
|
||||
};
|
||||
|
@ -110,10 +110,15 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
QAction *statusSubMenuAct = new QAction(tr("Status"), this);
|
||||
statusSubMenuAct->setMenu(statusSubMenu);
|
||||
|
||||
m_hideSubMenu = new WhiteMenu(&m_settingsMenu);
|
||||
QAction *hideSubMenuAct = new QAction(tr("Hide"), this);
|
||||
hideSubMenuAct->setMenu(m_hideSubMenu);
|
||||
|
||||
m_settingsMenu.addAction(modeSubMenuAct);
|
||||
m_settingsMenu.addAction(locationSubMenuAct);
|
||||
m_settingsMenu.addAction(sizeSubMenuAct);
|
||||
m_settingsMenu.addAction(statusSubMenuAct);
|
||||
m_settingsMenu.addAction(hideSubMenuAct);
|
||||
m_settingsMenu.setTitle("Settings Menu");
|
||||
|
||||
connect(&m_settingsMenu, &WhiteMenu::triggered, this, &DockSettings::menuActionClicked);
|
||||
@ -236,6 +241,24 @@ void DockSettings::showDockSettingsMenu()
|
||||
{
|
||||
m_autoHide = false;
|
||||
|
||||
qDeleteAll(m_hideSubMenu->actions());
|
||||
for (auto *p : m_itemController->pluginList())
|
||||
{
|
||||
if (!p->pluginIsAllowDisable())
|
||||
continue;
|
||||
|
||||
const bool enable = !p->pluginIsDisable();
|
||||
const QString &name = p->pluginName();
|
||||
const QString &display = p->pluginDisplayName();
|
||||
|
||||
QAction *act = new QAction(display, this);
|
||||
act->setCheckable(true);
|
||||
act->setChecked(enable);
|
||||
act->setData(name);
|
||||
|
||||
m_hideSubMenu->addAction(act);
|
||||
}
|
||||
|
||||
m_fashionModeAct.setChecked(m_displayMode == Fashion);
|
||||
m_efficientModeAct.setChecked(m_displayMode == Efficient);
|
||||
m_topPosAct.setChecked(m_position == Top);
|
||||
@ -299,6 +322,16 @@ void DockSettings::menuActionClicked(QAction *action)
|
||||
return m_dockInter->setHideMode(KeepHidden);
|
||||
if (action == &m_smartHideAct)
|
||||
return m_dockInter->setHideMode(SmartHide);
|
||||
|
||||
// check plugin hide menu.
|
||||
const QString &data = action->data().toString();
|
||||
if (data.isEmpty())
|
||||
return;
|
||||
for (auto *p : m_itemController->pluginList())
|
||||
{
|
||||
if (p->pluginName() == data)
|
||||
return p->pluginStateSwitched();
|
||||
}
|
||||
}
|
||||
|
||||
void DockSettings::onPositionChanged()
|
||||
|
@ -113,6 +113,7 @@ private:
|
||||
QSize m_mainWindowSize;
|
||||
|
||||
WhiteMenu m_settingsMenu;
|
||||
WhiteMenu *m_hideSubMenu;
|
||||
QAction m_fashionModeAct;
|
||||
QAction m_efficientModeAct;
|
||||
QAction m_topPosAct;
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
/// \return
|
||||
///
|
||||
virtual const QString pluginName() const = 0;
|
||||
virtual const QString pluginDisplayName() const { return QString(); }
|
||||
///
|
||||
/// \brief init
|
||||
/// init your plugins, you need to save proxyInter to m_proxyInter
|
||||
@ -165,6 +166,10 @@ public:
|
||||
///
|
||||
virtual void setItemIsInContainer(const QString &itemKey, const bool container) {Q_UNUSED(itemKey); Q_UNUSED(container);}
|
||||
|
||||
virtual bool pluginIsAllowDisable() { return false; }
|
||||
virtual bool pluginIsDisable() { return false; }
|
||||
virtual void pluginStateSwitched() {}
|
||||
|
||||
///
|
||||
/// \brief displayModeChanged
|
||||
/// override this function to receive display mode changed signal
|
||||
|
@ -39,6 +39,11 @@ const QString NetworkPlugin::pluginName() const
|
||||
return "network";
|
||||
}
|
||||
|
||||
const QString NetworkPlugin::pluginDisplayName() const
|
||||
{
|
||||
return tr("Network");
|
||||
}
|
||||
|
||||
void NetworkPlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
@ -75,6 +80,11 @@ void NetworkPlugin::refershIcon(const QString &itemKey)
|
||||
item->refreshIcon();
|
||||
}
|
||||
|
||||
bool NetworkPlugin::pluginIsDisable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString NetworkPlugin::itemCommand(const QString &itemKey)
|
||||
{
|
||||
for (auto deviceItem : m_deviceItemList)
|
||||
|
@ -36,9 +36,12 @@ public:
|
||||
explicit NetworkPlugin(QObject *parent = 0);
|
||||
|
||||
const QString pluginName() const;
|
||||
const QString pluginDisplayName() const;
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked);
|
||||
void refershIcon(const QString &itemKey);
|
||||
bool pluginIsAllowDisable() { return true; }
|
||||
bool pluginIsDisable();
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
const QString itemContextMenu(const QString &itemKey);
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
|
Loading…
x
Reference in New Issue
Block a user