mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复移除蓝牙设备后快捷面板依然显示的问题
记录子面板中当前显示的插件的指针,当移除插件时,回到主面板 Log: Influence: 从电脑上移除蓝牙设备,观察快捷区域和快捷面板是否还有蓝牙图标 Bug: https://pms.uniontech.com/bug-view-171533.html Change-Id: Ia4106d943d0f9df9788db1b87ef8d8fab31c6be3
This commit is contained in:
parent
04756c8f38
commit
4c324fe872
@ -63,9 +63,29 @@ typedef struct DragInfo{
|
|||||||
if (dragPoint.isNull())
|
if (dragPoint.isNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (qAbs(currentPoint.x() - dragPoint.x()) >=5 ||
|
if (!dragPixmap())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (qAbs(currentPoint.x() - dragPoint.x()) >= 5 ||
|
||||||
qAbs(currentPoint.y() - dragPoint.y()) >= 5);
|
qAbs(currentPoint.y() - dragPoint.y()) >= 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap dragPixmap() const {
|
||||||
|
if (!dockItem)
|
||||||
|
return QPixmap();
|
||||||
|
|
||||||
|
QPixmap pixmap = dockItem->pluginItem()->icon(DockPart::QuickShow).pixmap(QSize(ITEMSIZE, ITEMSIZE));
|
||||||
|
if (!pixmap.isNull())
|
||||||
|
return pixmap;
|
||||||
|
|
||||||
|
QString itemKey = QuickSettingController::instance()->itemKey(dockItem->pluginItem());
|
||||||
|
QWidget *itemWidget = dockItem->pluginItem()->itemWidget(itemKey);
|
||||||
|
if (!itemWidget)
|
||||||
|
return QPixmap();
|
||||||
|
|
||||||
|
itemWidget->setFixedSize(20, 20);
|
||||||
|
return itemWidget->grab();
|
||||||
|
}
|
||||||
} DragInfo;
|
} DragInfo;
|
||||||
|
|
||||||
static QStringList fixedPluginNames{ "network", "sound", "power" };
|
static QStringList fixedPluginNames{ "network", "sound", "power" };
|
||||||
@ -235,7 +255,7 @@ bool QuickPluginWindow::eventFilter(QObject *watched, QEvent *event)
|
|||||||
|
|
||||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
if (m_dragInfo->canDrag(mouseEvent->pos())) {
|
if (m_dragInfo->canDrag(mouseEvent->pos())) {
|
||||||
startDrag(m_dragInfo->dockItem->pluginItem());
|
startDrag();
|
||||||
m_dragInfo->reset();
|
m_dragInfo->reset();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -349,14 +369,19 @@ void QuickPluginWindow::onUpdatePlugin(PluginsItemInterface *itemInter, const Do
|
|||||||
dockItem->update();
|
dockItem->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickPluginWindow::startDrag(PluginsItemInterface *moveItem)
|
void QuickPluginWindow::startDrag()
|
||||||
{
|
{
|
||||||
|
if (!m_dragInfo->dockItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PluginsItemInterface *moveItem = m_dragInfo->dockItem->pluginItem();
|
||||||
AppDrag *drag = new AppDrag(this, new QuickDragWidget);
|
AppDrag *drag = new AppDrag(this, new QuickDragWidget);
|
||||||
QuickPluginMimeData *mimedata = new QuickPluginMimeData(moveItem);
|
QuickPluginMimeData *mimedata = new QuickPluginMimeData(moveItem);
|
||||||
drag->setMimeData(mimedata);
|
drag->setMimeData(mimedata);
|
||||||
drag->appDragWidget()->setDockInfo(m_position, QRect(mapToGlobal(pos()), size()));
|
drag->appDragWidget()->setDockInfo(m_position, QRect(mapToGlobal(pos()), size()));
|
||||||
QPixmap dragPixmap = moveItem->icon(DockPart::QuickPanel).pixmap(QSize(ITEMSIZE, ITEMSIZE));
|
QPixmap dragPixmap = m_dragInfo->dragPixmap();
|
||||||
drag->setPixmap(dragPixmap);
|
drag->setPixmap(dragPixmap);
|
||||||
|
|
||||||
drag->setHotSpot(QPoint(0, 0));
|
drag->setHotSpot(QPoint(0, 0));
|
||||||
|
|
||||||
connect(drag->appDragWidget(), &AppDragWidget::requestSplitWindow, this, [ this, moveItem ] {
|
connect(drag->appDragWidget(), &AppDragWidget::requestSplitWindow, this, [ this, moveItem ] {
|
||||||
|
@ -73,7 +73,7 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
void initUi();
|
void initUi();
|
||||||
void initConnection();
|
void initConnection();
|
||||||
void startDrag(PluginsItemInterface *moveItem);
|
void startDrag();
|
||||||
PluginsItemInterface *findQuickSettingItem(const QPoint &mousePoint, const QList<PluginsItemInterface *> &settingItems);
|
PluginsItemInterface *findQuickSettingItem(const QPoint &mousePoint, const QList<PluginsItemInterface *> &settingItems);
|
||||||
int getDropIndex(QPoint point);
|
int getDropIndex(QPoint point);
|
||||||
QPoint popupPoint(QWidget *widget) const;
|
QPoint popupPoint(QWidget *widget) const;
|
||||||
@ -106,12 +106,12 @@ protected:
|
|||||||
void enterEvent(QEvent *event) override;
|
void enterEvent(QEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
|
||||||
QPixmap iconPixmap() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint topleftPoint() const;
|
QPoint topleftPoint() const;
|
||||||
QPoint popupMarkPoint() const;
|
QPoint popupMarkPoint() const;
|
||||||
|
|
||||||
|
QPixmap iconPixmap() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onMenuActionClicked(QAction *action);
|
void onMenuActionClicked(QAction *action);
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ QuickSettingContainer::QuickSettingContainer(QWidget *parent)
|
|||||||
, m_displaySettingWidget(new DisplaySettingWidget(this))
|
, m_displaySettingWidget(new DisplaySettingWidget(this))
|
||||||
, m_childPage(new PluginChildPage(this))
|
, m_childPage(new PluginChildPage(this))
|
||||||
, m_dragInfo(new struct QuickDragInfo)
|
, m_dragInfo(new struct QuickDragInfo)
|
||||||
|
, m_childShowPlugin(nullptr)
|
||||||
{
|
{
|
||||||
initUi();
|
initUi();
|
||||||
initConnection();
|
initConnection();
|
||||||
@ -94,6 +95,7 @@ QuickSettingContainer::~QuickSettingContainer()
|
|||||||
|
|
||||||
void QuickSettingContainer::showHomePage()
|
void QuickSettingContainer::showHomePage()
|
||||||
{
|
{
|
||||||
|
m_childShowPlugin = nullptr;
|
||||||
m_switchLayout->setCurrentIndex(0);
|
m_switchLayout->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +241,8 @@ void QuickSettingContainer::onPluginRemove(PluginsItemInterface *itemInter)
|
|||||||
|
|
||||||
m_quickSettings.removeOne(removeItem);
|
m_quickSettings.removeOne(removeItem);
|
||||||
removeItem->deleteLater();
|
removeItem->deleteLater();
|
||||||
|
if (m_childShowPlugin == itemInter)
|
||||||
|
showHomePage();
|
||||||
|
|
||||||
updateItemLayout();
|
updateItemLayout();
|
||||||
onResizeView();
|
onResizeView();
|
||||||
@ -250,7 +254,8 @@ void QuickSettingContainer::onShowChildWidget(QWidget *childWidget)
|
|||||||
if (!quickWidget)
|
if (!quickWidget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
showWidget(childWidget, quickWidget->pluginItem()->pluginDisplayName());
|
m_childShowPlugin = quickWidget->pluginItem();
|
||||||
|
showWidget(childWidget, m_childShowPlugin->pluginDisplayName());
|
||||||
onResizeView();
|
onResizeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ private:
|
|||||||
PluginChildPage *m_childPage;
|
PluginChildPage *m_childPage;
|
||||||
QuickDragInfo *m_dragInfo;
|
QuickDragInfo *m_dragInfo;
|
||||||
QList<QuickSettingItem *> m_quickSettings;
|
QList<QuickSettingItem *> m_quickSettings;
|
||||||
|
PluginsItemInterface *m_childShowPlugin;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QuickPluginMimeData : public QMimeData
|
class QuickPluginMimeData : public QMimeData
|
||||||
|
Loading…
x
Reference in New Issue
Block a user