Handle PluginItemWrapper's enter and leave event

This commit is contained in:
杨万青 2015-07-13 16:16:21 +08:00
parent 487ed2d733
commit 65b95b99f9
3 changed files with 23 additions and 13 deletions

View File

@ -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);
});
}

View File

@ -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()

View File

@ -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;