mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add popup applet signal
Change-Id: I85032991ceda2a08363df9518ec56b2e45b7d2b2
This commit is contained in:
parent
d8c7a81465
commit
056f550da1
@ -55,6 +55,14 @@ void DockPluginsController::itemRemoved(PluginsItemInterface * const itemInter,
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
void DockPluginsController::requestPopupApplet(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
|
||||
Q_ASSERT(item);
|
||||
item->showPopupApplet();
|
||||
}
|
||||
|
||||
void DockPluginsController::loadPlugins()
|
||||
{
|
||||
// Q_ASSERT(m_pluginLoaderList.isEmpty());
|
||||
|
@ -22,6 +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 requestPopupApplet(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
|
||||
signals:
|
||||
void pluginItemInserted(PluginsItem *pluginItem) const;
|
||||
|
@ -46,6 +46,7 @@ protected:
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
const QRect perfectIconRect() const;
|
||||
const QPoint popupMarkPoint();
|
||||
|
||||
void showContextMenu();
|
||||
void showPopupTips();
|
||||
@ -53,9 +54,6 @@ protected:
|
||||
virtual const QString contextMenu() const;
|
||||
virtual QWidget *popupTips();
|
||||
|
||||
private:
|
||||
const QPoint popupMarkPoint();
|
||||
|
||||
protected:
|
||||
ItemType m_type;
|
||||
bool m_hover;
|
||||
|
@ -49,6 +49,11 @@ void PluginsItem::detachPluginWidget()
|
||||
widget->setParent(nullptr);
|
||||
}
|
||||
|
||||
void PluginsItem::showPopupApplet()
|
||||
{
|
||||
emit requestPopupApplet(popupMarkPoint(), m_pluginInter->itemPopupApplet(m_itemKey));
|
||||
}
|
||||
|
||||
void PluginsItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton)
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
|
||||
int itemSortKey() const;
|
||||
void detachPluginWidget();
|
||||
void showPopupApplet();
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
virtual void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
virtual void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
virtual void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
virtual void requestPopupApplet(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
};
|
||||
|
||||
#endif // PLUGINPROXYINTERFACE_H
|
||||
|
@ -15,19 +15,23 @@ public:
|
||||
virtual const QString pluginName() const = 0;
|
||||
// init plugins
|
||||
virtual void init(PluginProxyInterface *proxyInter) = 0;
|
||||
// dock display mode changed
|
||||
virtual void displayModeChanged(const Dock::DisplayMode displayMode) {Q_UNUSED(displayMode);}
|
||||
// dock position changed
|
||||
virtual void positionChanged(const Dock::Position position) {Q_UNUSED(position);}
|
||||
// plugin item widget
|
||||
virtual QWidget *itemWidget(const QString &itemKey) = 0;
|
||||
|
||||
virtual QWidget *itemTipsWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||
virtual QWidget *itemPopupApplet(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||
|
||||
// item sort key
|
||||
virtual int itemSortKey(const QString &itemKey) {Q_UNUSED(itemKey); return 0;}
|
||||
// reset sort key when plugins order changed
|
||||
virtual void setSortKey(const QString &itemKey, const int order) {Q_UNUSED(itemKey); Q_UNUSED(order);}
|
||||
|
||||
virtual QWidget *itemWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||
virtual QWidget *itemTipsWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||
// dock display mode changed
|
||||
virtual void displayModeChanged(const Dock::DisplayMode displayMode) {Q_UNUSED(displayMode);}
|
||||
// dock position changed
|
||||
virtual void positionChanged(const Dock::Position position) {Q_UNUSED(position);}
|
||||
|
||||
|
||||
protected:
|
||||
Dock::DisplayMode displayMode() const
|
||||
|
@ -62,6 +62,8 @@ void FashionTrayItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mousePressEvent(e);
|
||||
|
||||
emit requestPopupApplet();
|
||||
|
||||
m_pressPoint = e->pos();
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,9 @@ public:
|
||||
|
||||
TrayWidget *activeTray();
|
||||
|
||||
signals:
|
||||
void requestPopupApplet() const;
|
||||
|
||||
public slots:
|
||||
void setActiveTray(TrayWidget *tray);
|
||||
|
||||
|
@ -11,7 +11,6 @@ SystemTrayPlugin::SystemTrayPlugin(QObject *parent)
|
||||
m_trayInter(new DBusTrayManager(this)),
|
||||
m_tipsWidget(new TipsWidget)
|
||||
{
|
||||
m_fashionItem = new FashionTrayItem;
|
||||
}
|
||||
|
||||
const QString SystemTrayPlugin::pluginName() const
|
||||
@ -23,6 +22,10 @@ void SystemTrayPlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
m_fashionItem = new FashionTrayItem;
|
||||
|
||||
connect(m_fashionItem, &FashionTrayItem::requestPopupApplet, this, &SystemTrayPlugin::requestPopupApplet);
|
||||
|
||||
connect(m_trayInter, &DBusTrayManager::Added, this, &SystemTrayPlugin::trayAdded);
|
||||
connect(m_trayInter, &DBusTrayManager::Removed, this, &SystemTrayPlugin::trayRemoved);
|
||||
connect(m_trayInter, &DBusTrayManager::Changed, this, &SystemTrayPlugin::trayChanged);
|
||||
@ -47,11 +50,9 @@ QWidget *SystemTrayPlugin::itemWidget(const QString &itemKey)
|
||||
return m_trayList[trayWinId];
|
||||
}
|
||||
|
||||
QWidget *SystemTrayPlugin::itemTipsWidget(const QString &itemKey)
|
||||
QWidget *SystemTrayPlugin::itemPopupApplet(const QString &itemKey)
|
||||
{
|
||||
// only display tips widget on fashion mode
|
||||
if (itemKey != FASHION_MODE_ITEM)
|
||||
return nullptr;
|
||||
Q_ASSERT(itemKey == FASHION_MODE_ITEM);
|
||||
|
||||
// not have other tray icon
|
||||
if (m_trayList.size() < 2)
|
||||
@ -132,3 +133,8 @@ void SystemTrayPlugin::switchToMode(const Dock::DisplayMode mode)
|
||||
m_proxyInter->itemAdded(this, QString::number(winId));
|
||||
}
|
||||
}
|
||||
|
||||
void SystemTrayPlugin::requestPopupApplet()
|
||||
{
|
||||
m_proxyInter->requestPopupApplet(this, FASHION_MODE_ITEM);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
void displayModeChanged(const Dock::DisplayMode mode);
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
|
||||
private:
|
||||
void updateTipsContent();
|
||||
@ -31,6 +31,7 @@ private slots:
|
||||
void trayRemoved(const quint32 winId);
|
||||
void trayChanged(const quint32 winId);
|
||||
void switchToMode(const Dock::DisplayMode mode);
|
||||
void requestPopupApplet();
|
||||
|
||||
private:
|
||||
DBusTrayManager *m_trayInter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user