mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Handle PluginItemWrapper's enter and leave event
This commit is contained in:
parent
487ed2d733
commit
65b95b99f9
@ -29,9 +29,9 @@ Panel::Panel(QWidget *parent)
|
||||
this, SLOT(slotDockModeChanged(Dock::DockMode,Dock::DockMode)));
|
||||
|
||||
|
||||
QHBoxLayout * testLayout = new QHBoxLayout;
|
||||
testLayout->addStretch();
|
||||
this->setLayout(testLayout);
|
||||
// QHBoxLayout * testLayout = new QHBoxLayout;
|
||||
// testLayout->addStretch();
|
||||
// this->setLayout(testLayout);
|
||||
|
||||
DockPluginManager *pluginManager = new DockPluginManager(this);
|
||||
connect(DockModeData::instance(), &DockModeData::dockModeChanged,
|
||||
@ -40,14 +40,11 @@ Panel::Panel(QWidget *parent)
|
||||
QList<DockPluginProxy*> proxies = pluginManager->getAll();
|
||||
foreach (DockPluginProxy* proxy, proxies) {
|
||||
connect(proxy, &DockPluginProxy::itemAdded, [=](AbstractDockItem* item) {
|
||||
testLayout->addWidget(item);
|
||||
rightLayout->addItem(item);
|
||||
});
|
||||
connect(proxy, &DockPluginProxy::itemRemoved, [=](AbstractDockItem* item) {
|
||||
int index = testLayout->indexOf(item);
|
||||
if (index != -1) {
|
||||
testLayout->removeWidget(item);
|
||||
item->deleteLater();
|
||||
}
|
||||
int index = rightLayout->indexOf(item);
|
||||
rightLayout->removeItem(index);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,19 @@ PluginItemWrapper::PluginItemWrapper(DockPluginInterface *plugin,
|
||||
|
||||
QWidget * PluginItemWrapper::getContents()
|
||||
{
|
||||
if (m_pluginItemContents)
|
||||
return m_pluginItemContents;
|
||||
else
|
||||
return NULL;
|
||||
return m_plugin->getContents(m_uuid);
|
||||
}
|
||||
|
||||
void PluginItemWrapper::enterEvent(QEvent *)
|
||||
{
|
||||
emit mouseEntered();
|
||||
showPreview();
|
||||
}
|
||||
|
||||
void PluginItemWrapper::leaveEvent(QEvent *)
|
||||
{
|
||||
emit mouseExited();
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
PluginItemWrapper::~PluginItemWrapper()
|
||||
|
@ -14,6 +14,10 @@ public:
|
||||
QWidget * getContents();
|
||||
QString uuid() const;
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent * event);
|
||||
void leaveEvent(QEvent * event);
|
||||
|
||||
private:
|
||||
QWidget *m_pluginItemContents = NULL;
|
||||
DockPluginInterface * m_plugin;
|
||||
|
Loading…
x
Reference in New Issue
Block a user