mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add plugin item command
Change-Id: Id5df1be8d4d1e477c97f31d1463fc9cb155fe6a9
This commit is contained in:
parent
5aa989debb
commit
d8c7a81465
@ -142,29 +142,29 @@ void DockItem::showContextMenu()
|
||||
|
||||
void DockItem::showPopupTips()
|
||||
{
|
||||
// QWidget * const content = popupTips();
|
||||
// if (!content)
|
||||
// return;
|
||||
QWidget * const content = popupTips();
|
||||
if (!content)
|
||||
return;
|
||||
|
||||
// DArrowRectangle *tips = PopupTips.get();
|
||||
// QWidget *lastContent = tips->getContent();
|
||||
// if (lastContent)
|
||||
// lastContent->hide();
|
||||
DArrowRectangle *tips = PopupTips.get();
|
||||
QWidget *lastContent = tips->getContent();
|
||||
if (lastContent)
|
||||
lastContent->hide();
|
||||
|
||||
// switch (DockPosition)
|
||||
// {
|
||||
// case Top: tips->setArrowDirection(DArrowRectangle::ArrowTop); break;
|
||||
// case Bottom:tips->setArrowDirection(DArrowRectangle::ArrowBottom); break;
|
||||
// case Left: tips->setArrowDirection(DArrowRectangle::ArrowLeft); break;
|
||||
// case Right: tips->setArrowDirection(DArrowRectangle::ArrowRight); break;
|
||||
// }
|
||||
// tips->setContent(content);
|
||||
// tips->setMargin(5);
|
||||
// tips->setWidth(content->sizeHint().width());
|
||||
// tips->setHeight(content->sizeHint().height());
|
||||
switch (DockPosition)
|
||||
{
|
||||
case Top: tips->setArrowDirection(DArrowRectangle::ArrowTop); break;
|
||||
case Bottom:tips->setArrowDirection(DArrowRectangle::ArrowBottom); break;
|
||||
case Left: tips->setArrowDirection(DArrowRectangle::ArrowLeft); break;
|
||||
case Right: tips->setArrowDirection(DArrowRectangle::ArrowRight); break;
|
||||
}
|
||||
tips->setContent(content);
|
||||
tips->setMargin(5);
|
||||
tips->setWidth(content->sizeHint().width());
|
||||
tips->setHeight(content->sizeHint().height());
|
||||
|
||||
// const QPoint p = popupMarkPoint();
|
||||
// tips->show(p.x(), p.y());
|
||||
const QPoint p = popupMarkPoint();
|
||||
tips->show(p.x(), p.y());
|
||||
}
|
||||
|
||||
void DockItem::invokedMenuItem(const QString &itemId, const bool checked)
|
||||
@ -178,6 +178,11 @@ const QString DockItem::contextMenu() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
QWidget *DockItem::popupTips()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QPoint DockItem::popupMarkPoint()
|
||||
{
|
||||
QPoint p;
|
||||
|
@ -51,6 +51,7 @@ protected:
|
||||
void showPopupTips();
|
||||
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
||||
virtual const QString contextMenu() const;
|
||||
virtual QWidget *popupTips();
|
||||
|
||||
private:
|
||||
const QPoint popupMarkPoint();
|
||||
|
@ -16,16 +16,16 @@ QPoint PluginsItem::MousePressPoint = QPoint();
|
||||
PluginsItem::PluginsItem(PluginsItemInterface* const pluginInter, const QString &itemKey, QWidget *parent)
|
||||
: DockItem(Plugins, parent),
|
||||
m_pluginInter(pluginInter),
|
||||
m_centeralWidget(m_pluginInter->itemWidget(itemKey)),
|
||||
m_itemKey(itemKey),
|
||||
m_draging(false)
|
||||
{
|
||||
// construct complex widget layout
|
||||
QWidget *centeralWidget = m_pluginInter->itemWidget(itemKey);
|
||||
Q_ASSERT(centeralWidget);
|
||||
centeralWidget->installEventFilter(this);
|
||||
Q_ASSERT(m_centeralWidget);
|
||||
|
||||
m_centeralWidget->installEventFilter(this);
|
||||
|
||||
QBoxLayout *hLayout = new QHBoxLayout;
|
||||
hLayout->addWidget(centeralWidget);
|
||||
hLayout->addWidget(m_centeralWidget);
|
||||
hLayout->setSpacing(0);
|
||||
hLayout->setMargin(0);
|
||||
|
||||
@ -92,31 +92,15 @@ void PluginsItem::paintEvent(QPaintEvent *e)
|
||||
if (m_draging)
|
||||
return;
|
||||
|
||||
if (!m_hover)
|
||||
return DockItem::paintEvent(e);
|
||||
DockItem::paintEvent(e);
|
||||
|
||||
// TODO: hover
|
||||
// const QPixmap pixmap =
|
||||
|
||||
// if (m_pluginType == PluginsItemInterface::Complex)
|
||||
// return DockItem::paintEvent(e);
|
||||
|
||||
// QPainter painter(this);
|
||||
|
||||
// const QIcon icon = m_pluginInter->itemIcon(m_itemKey);
|
||||
// const QRect iconRect = perfectIconRect();
|
||||
// const QPixmap pixmap = icon.pixmap(iconRect.size());
|
||||
|
||||
// painter.drawPixmap(iconRect, pixmap);
|
||||
|
||||
// if (m_hover)
|
||||
// painter.drawPixmap(iconRect, ImageFactory::lighterEffect(pixmap));
|
||||
// TODO: hover effect
|
||||
}
|
||||
|
||||
bool PluginsItem::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (m_draging)
|
||||
if (o->parent() == this && e->type() == QEvent::Paint)
|
||||
if (o == m_centeralWidget && e->type() == QEvent::Paint)
|
||||
return true;
|
||||
|
||||
return DockItem::eventFilter(o, e);
|
||||
@ -124,16 +108,7 @@ bool PluginsItem::eventFilter(QObject *o, QEvent *e)
|
||||
|
||||
QWidget *PluginsItem::popupTips()
|
||||
{
|
||||
// if (m_pluginInter->tipsType(m_itemKey) == PluginsItemInterface::Complex)
|
||||
// return m_pluginInter->itemTipsWidget(m_itemKey);
|
||||
|
||||
// const QString tips = m_pluginInter->itemTipsString(m_itemKey);
|
||||
// if (tips.isEmpty())
|
||||
// return nullptr;
|
||||
|
||||
// m_simpleTips->setText(tips);
|
||||
|
||||
// return m_simpleTips;
|
||||
return m_pluginInter->itemTipsWidget(m_itemKey);
|
||||
}
|
||||
|
||||
void PluginsItem::startDrag()
|
||||
@ -159,13 +134,13 @@ void PluginsItem::startDrag()
|
||||
|
||||
void PluginsItem::mouseClicked()
|
||||
{
|
||||
// const QString command = m_pluginInter->itemCommand(m_itemKey);
|
||||
// if (!command.isEmpty())
|
||||
// {
|
||||
// QProcess *proc = new QProcess(this);
|
||||
const QString command = m_pluginInter->itemCommand(m_itemKey);
|
||||
if (command.isEmpty())
|
||||
return;
|
||||
|
||||
// connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), proc, &QProcess::deleteLater);
|
||||
QProcess *proc = new QProcess(this);
|
||||
|
||||
// proc->startDetached(command);
|
||||
// }
|
||||
connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), proc, &QProcess::deleteLater);
|
||||
|
||||
proc->startDetached(command);
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ private:
|
||||
|
||||
private:
|
||||
PluginsItemInterface * const m_pluginInter;
|
||||
QWidget *m_centeralWidget;
|
||||
const QString m_itemKey;
|
||||
|
||||
bool m_draging;
|
||||
|
||||
static QPoint MousePressPoint;
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
|
||||
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();}
|
||||
|
||||
protected:
|
||||
Dock::DisplayMode displayMode() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user