mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add unified context menu interface
Change-Id: Ib71440419be82bc134c75638d0c8df3ecec3865f
This commit is contained in:
parent
340f096cdf
commit
2e0094bca2
Notes:
Deepin Code Review
2016-09-19 14:22:11 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Mon, 19 Sep 2016 14:22:11 +0800 Reviewed-on: https://cr.deepin.io/16162 Project: dde/dde-dock Branch: refs/heads/master
@ -56,16 +56,25 @@ void DockPluginsController::itemRemoved(PluginsItemInterface * const itemInter,
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
void DockPluginsController::requestRefershWindowVisible()
|
||||
//void DockPluginsController::requestRefershWindowVisible()
|
||||
//{
|
||||
// for (auto list : m_pluginList.values())
|
||||
// {
|
||||
// for (auto item : list.values())
|
||||
// {
|
||||
// Q_ASSERT(item);
|
||||
// emit item->requestRefershWindowVisible();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void DockPluginsController::requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
for (auto list : m_pluginList.values())
|
||||
{
|
||||
for (auto item : list.values())
|
||||
{
|
||||
emit item->requestRefershWindowVisible();
|
||||
return;
|
||||
}
|
||||
}
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
item->showContextMenu();
|
||||
}
|
||||
|
||||
//void DockPluginsController::requestPopupApplet(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void requestRefershWindowVisible();
|
||||
void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
|
||||
signals:
|
||||
void pluginItemInserted(PluginsItem *pluginItem) const;
|
||||
|
@ -137,6 +137,16 @@ bool PluginsItem::eventFilter(QObject *o, QEvent *e)
|
||||
return DockItem::eventFilter(o, e);
|
||||
}
|
||||
|
||||
void PluginsItem::invokedMenuItem(const QString &itemId, const bool checked)
|
||||
{
|
||||
m_pluginInter->invokedMenuItem(m_itemKey, itemId, checked);
|
||||
}
|
||||
|
||||
const QString PluginsItem::contextMenu() const
|
||||
{
|
||||
return m_pluginInter->itemContextMenu(m_itemKey);
|
||||
}
|
||||
|
||||
QWidget *PluginsItem::popupTips()
|
||||
{
|
||||
return m_pluginInter->itemTipsWidget(m_itemKey);
|
||||
|
@ -34,6 +34,8 @@ private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
|
||||
void invokedMenuItem(const QString &itemId, const bool checked);
|
||||
const QString contextMenu() const;
|
||||
QWidget *popupTips();
|
||||
|
||||
private:
|
||||
|
@ -37,11 +37,10 @@ public:
|
||||
///
|
||||
virtual void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
///
|
||||
/// \brief requestRefershWindowVisible
|
||||
/// tell dock refersh window visible state,
|
||||
/// its useful because sometimes you could force disable auto-hide.
|
||||
/// \brief requestContextMenu
|
||||
/// request show context menu
|
||||
///
|
||||
virtual void requestRefershWindowVisible() = 0;
|
||||
virtual void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
};
|
||||
|
||||
#endif // PLUGINPROXYINTERFACE_H
|
||||
|
@ -77,6 +77,23 @@ public:
|
||||
///
|
||||
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||
|
||||
///
|
||||
/// \brief itemContextMenu
|
||||
/// context menu is shown when RequestPopupMenu called.
|
||||
/// \param itemKey
|
||||
/// \return
|
||||
///
|
||||
virtual const QString itemContextMenu(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||
///
|
||||
/// \brief invokedMenuItem
|
||||
/// call if context menu item is clicked
|
||||
/// \param itemKey
|
||||
/// \param itemId
|
||||
/// menu item id
|
||||
/// \param checked
|
||||
///
|
||||
virtual void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) {Q_UNUSED(itemKey); Q_UNUSED(menuId); Q_UNUSED(checked);}
|
||||
|
||||
///
|
||||
/// \brief itemSortKey
|
||||
/// tell dock where your item wants to put on.
|
||||
|
@ -4,9 +4,7 @@ TrashPlugin::TrashPlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_trashWidget(new TrashWidget)
|
||||
{
|
||||
connect(m_trashWidget, &TrashWidget::requestRefershWindowVisible, [this] {
|
||||
m_proxyInter->requestRefershWindowVisible();
|
||||
});
|
||||
connect(m_trashWidget, &TrashWidget::requestContextMenu, this, &TrashPlugin::showContextMenu);
|
||||
}
|
||||
|
||||
const QString TrashPlugin::pluginName() const
|
||||
@ -44,6 +42,13 @@ const QString TrashPlugin::itemCommand(const QString &itemKey)
|
||||
return "gvfs-open trash://";
|
||||
}
|
||||
|
||||
const QString TrashPlugin::itemContextMenu(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
int TrashPlugin::itemSortKey(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
@ -59,3 +64,8 @@ void TrashPlugin::displayModeChanged(const Dock::DisplayMode displayMode)
|
||||
else
|
||||
m_proxyInter->itemRemoved(this, QString());
|
||||
}
|
||||
|
||||
void TrashPlugin::showContextMenu()
|
||||
{
|
||||
m_proxyInter->requestContextMenu(this, QString());
|
||||
}
|
||||
|
@ -19,10 +19,14 @@ public:
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
const QString itemContextMenu(const QString &itemKey);
|
||||
|
||||
int itemSortKey(const QString &itemKey);
|
||||
void displayModeChanged(const Dock::DisplayMode displayMode);
|
||||
|
||||
private:
|
||||
void showContextMenu();
|
||||
|
||||
private:
|
||||
TrashWidget *m_trashWidget;
|
||||
};
|
||||
|
@ -80,7 +80,8 @@ void TrashWidget::mousePressEvent(QMouseEvent *e)
|
||||
if (e->button() != Qt::RightButton || dis.manhattanLength() > std::min(width(), height()) * 0.8 * 0.5)
|
||||
return QWidget::mousePressEvent(e);
|
||||
|
||||
showMenu();
|
||||
// showMenu();
|
||||
emit requestContextMenu();
|
||||
}
|
||||
|
||||
const QPoint TrashWidget::popupMarkPoint()
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
QSize sizeHint() const;
|
||||
|
||||
signals:
|
||||
void requestContextMenu() const;
|
||||
void requestRefershWindowVisible() const;
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user