mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 适配v20插件在任务栏的显示
对于V20的插件,由于没有实现Icon接口,因此在任务栏显示的时候依然将原来的itemWidget返回的内容显示在任务栏上 Log: Influence: 任务栏显示v20插件 Task: https://pms.uniontech.com/task-view-112073.html Change-Id: Ic820ace51b018447942b7deb92c9ca567eba00e8
This commit is contained in:
parent
f14c19ba9e
commit
9033044f0a
@ -54,10 +54,6 @@ void SingleQuickItem::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
commandArgument.removeFirst();
|
commandArgument.removeFirst();
|
||||||
QProcess::startDetached(command, commandArgument);
|
QProcess::startDetached(command, commandArgument);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *itemWidget = pluginItem()->itemWidget(QUICK_ITEM_KEY);
|
|
||||||
if (itemWidget)
|
|
||||||
Q_EMIT requestShowChildWidget(itemWidget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleQuickItem::resizeEvent(QResizeEvent *event)
|
void SingleQuickItem::resizeEvent(QResizeEvent *event)
|
||||||
|
@ -169,14 +169,14 @@ QIcon PluginAdapter::icon(const DockPart &dockPart)
|
|||||||
return QIcon();
|
return QIcon();
|
||||||
|
|
||||||
switch (dockPart) {
|
switch (dockPart) {
|
||||||
case DockPart::QuickPanel: {
|
case DockPart::QuickPanel:
|
||||||
// 如果图标为空,就使用itemWidget的截图作为它的图标,这种一般是适用于老版本插件或者没有实现v23接口的插件
|
|
||||||
itemWidget->setFixedSize(ICONWIDTH, ICONHEIGHT);
|
|
||||||
return itemWidget->grab();
|
|
||||||
}
|
|
||||||
case DockPart::SystemPanel: {
|
case DockPart::SystemPanel: {
|
||||||
itemWidget->setFixedSize(16, 16);
|
// 如果图标为空,就使用itemWidget的截图作为它的图标,这种一般是适用于老版本插件或者没有实现v23接口的插件
|
||||||
return itemWidget->grab();
|
QSize oldSize = itemWidget->size();
|
||||||
|
itemWidget->setFixedSize(ICONWIDTH, ICONHEIGHT);
|
||||||
|
QPixmap pixmap = itemWidget->grab();
|
||||||
|
itemWidget->setFixedSize(oldSize);
|
||||||
|
return pixmap;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@ typedef struct DragInfo{
|
|||||||
if (!itemWidget)
|
if (!itemWidget)
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
|
|
||||||
itemWidget->setFixedSize(20, 20);
|
|
||||||
return itemWidget->grab();
|
return itemWidget->grab();
|
||||||
}
|
}
|
||||||
} DragInfo;
|
} DragInfo;
|
||||||
@ -568,21 +567,11 @@ QuickDockItem::QuickDockItem(PluginsItemInterface *pluginItem, const QJsonObject
|
|||||||
, m_popupWindow(new DockPopupWindow)
|
, m_popupWindow(new DockPopupWindow)
|
||||||
, m_contextMenu(new QMenu(this))
|
, m_contextMenu(new QMenu(this))
|
||||||
, m_tipParent(nullptr)
|
, m_tipParent(nullptr)
|
||||||
|
, m_mainLayout(nullptr)
|
||||||
{
|
{
|
||||||
m_popupWindow->setShadowBlurRadius(20);
|
initUi();
|
||||||
m_popupWindow->setRadius(6);
|
initConnection();
|
||||||
m_popupWindow->setShadowYOffset(2);
|
initAttribute();
|
||||||
m_popupWindow->setShadowXOffset(0);
|
|
||||||
m_popupWindow->setArrowWidth(18);
|
|
||||||
m_popupWindow->setArrowHeight(10);
|
|
||||||
m_popupWindow->setObjectName("quickitempopup");
|
|
||||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
|
||||||
Qt::WindowFlags flags = m_popupWindow->windowFlags() | Qt::FramelessWindowHint;
|
|
||||||
m_popupWindow->setWindowFlags(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(m_contextMenu, &QMenu::triggered, this, &QuickDockItem::onMenuActionClicked);
|
|
||||||
connect(qApp, &QApplication::aboutToQuit, m_popupWindow, &DockPopupWindow::deleteLater);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickDockItem::~QuickDockItem()
|
QuickDockItem::~QuickDockItem()
|
||||||
@ -696,6 +685,28 @@ void QuickDockItem::leaveEvent(QEvent *event)
|
|||||||
m_popupWindow->hide();
|
m_popupWindow->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuickDockItem::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
if (!m_mainLayout)
|
||||||
|
return QWidget::showEvent(event);
|
||||||
|
|
||||||
|
QWidget *itemWidget = m_pluginItem->itemWidget(m_itemKey);
|
||||||
|
if (itemWidget && m_mainLayout->indexOf(itemWidget) < 0) {
|
||||||
|
itemWidget->setFixedSize(ICONWIDTH - 2, ICONHEIGHT - 2);
|
||||||
|
m_mainLayout->addWidget(itemWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickDockItem::hideEvent(QHideEvent *event)
|
||||||
|
{
|
||||||
|
if (!m_mainLayout)
|
||||||
|
return QWidget::hideEvent(event);
|
||||||
|
|
||||||
|
QWidget *itemWidget = m_pluginItem->itemWidget(m_itemKey);
|
||||||
|
if (itemWidget && m_mainLayout->indexOf(itemWidget) >= 0)
|
||||||
|
m_mainLayout->removeWidget(m_pluginItem->itemWidget(m_itemKey));
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap QuickDockItem::iconPixmap() const
|
QPixmap QuickDockItem::iconPixmap() const
|
||||||
{
|
{
|
||||||
int pixmapSize = static_cast<int>(ICONHEIGHT * qApp->devicePixelRatio());
|
int pixmapSize = static_cast<int>(ICONHEIGHT * qApp->devicePixelRatio());
|
||||||
@ -703,15 +714,41 @@ QPixmap QuickDockItem::iconPixmap() const
|
|||||||
if (!icon.isNull())
|
if (!icon.isNull())
|
||||||
return icon.pixmap(pixmapSize, pixmapSize);
|
return icon.pixmap(pixmapSize, pixmapSize);
|
||||||
|
|
||||||
QWidget *itemWidget = m_pluginItem->itemWidget(m_itemKey);
|
|
||||||
if (itemWidget) {
|
|
||||||
itemWidget->setFixedSize(ICONWIDTH, ICONHEIGHT);
|
|
||||||
return itemWidget->grab();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuickDockItem::initUi()
|
||||||
|
{
|
||||||
|
QPixmap pixmap = iconPixmap();
|
||||||
|
if (!pixmap.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_mainLayout = new QHBoxLayout(this);
|
||||||
|
m_mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_pluginItem->itemWidget(m_itemKey)->installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickDockItem::initAttribute()
|
||||||
|
{
|
||||||
|
m_popupWindow->setShadowBlurRadius(20);
|
||||||
|
m_popupWindow->setRadius(6);
|
||||||
|
m_popupWindow->setShadowYOffset(2);
|
||||||
|
m_popupWindow->setShadowXOffset(0);
|
||||||
|
m_popupWindow->setArrowWidth(18);
|
||||||
|
m_popupWindow->setArrowHeight(10);
|
||||||
|
m_popupWindow->setObjectName("quickitempopup");
|
||||||
|
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||||
|
Qt::WindowFlags flags = m_popupWindow->windowFlags() | Qt::FramelessWindowHint;
|
||||||
|
m_popupWindow->setWindowFlags(flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickDockItem::initConnection()
|
||||||
|
{
|
||||||
|
connect(m_contextMenu, &QMenu::triggered, this, &QuickDockItem::onMenuActionClicked);
|
||||||
|
connect(qApp, &QApplication::aboutToQuit, m_popupWindow, &DockPopupWindow::deleteLater);
|
||||||
|
}
|
||||||
|
|
||||||
QPoint QuickDockItem::topleftPoint() const
|
QPoint QuickDockItem::topleftPoint() const
|
||||||
{
|
{
|
||||||
QPoint p = this->pos();
|
QPoint p = this->pos();
|
||||||
|
@ -107,6 +107,8 @@ protected:
|
|||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
void enterEvent(QEvent *event) override;
|
void enterEvent(QEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
void showEvent(QShowEvent *event) override;
|
||||||
|
void hideEvent(QHideEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint topleftPoint() const;
|
QPoint topleftPoint() const;
|
||||||
@ -114,6 +116,10 @@ private:
|
|||||||
|
|
||||||
QPixmap iconPixmap() const;
|
QPixmap iconPixmap() const;
|
||||||
|
|
||||||
|
void initUi();
|
||||||
|
void initAttribute();
|
||||||
|
void initConnection();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onMenuActionClicked(QAction *action);
|
void onMenuActionClicked(QAction *action);
|
||||||
|
|
||||||
@ -125,6 +131,7 @@ private:
|
|||||||
DockPopupWindow *m_popupWindow;
|
DockPopupWindow *m_popupWindow;
|
||||||
QMenu *m_contextMenu;
|
QMenu *m_contextMenu;
|
||||||
QWidget *m_tipParent;
|
QWidget *m_tipParent;
|
||||||
|
QHBoxLayout *m_mainLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUICKPLUGINWINDOW_H
|
#endif // QUICKPLUGINWINDOW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user