mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复无法通过点击插件图标隐藏快捷面板的问题
设置不检测的QWidget,当鼠标在不检测的QWidget内部点击的时候,无需关闭当前快捷面板 Log: Influence: 从插件图标打开快捷面板,再次点击该插件图标,观察快捷面板是否隐藏 Bug: https://pms.uniontech.com/bug-view-175201.html Change-Id: Ia523a7a414cdbd9cbd088ab0729e3b01414b8a93
This commit is contained in:
parent
a88f5e6fa1
commit
80dfd4a2b8
@ -39,6 +39,7 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
|
|||||||
, m_model(false)
|
, m_model(false)
|
||||||
, m_eventMonitor(new XEventMonitor(xEventMonitorService, xEventMonitorPath, QDBusConnection::sessionBus(), this))
|
, m_eventMonitor(new XEventMonitor(xEventMonitorService, xEventMonitorPath, QDBusConnection::sessionBus(), this))
|
||||||
, m_enableMouseRelease(true)
|
, m_enableMouseRelease(true)
|
||||||
|
, m_extendWidget(nullptr)
|
||||||
{
|
{
|
||||||
setMargin(0);
|
setMargin(0);
|
||||||
m_wmHelper = DWindowManagerHelper::instance();
|
m_wmHelper = DWindowManagerHelper::instance();
|
||||||
@ -85,6 +86,11 @@ void DockPopupWindow::setContent(QWidget *content)
|
|||||||
DArrowRectangle::setContent(content);
|
DArrowRectangle::setContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockPopupWindow::setExtendWidget(QWidget *widget)
|
||||||
|
{
|
||||||
|
m_extendWidget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
void DockPopupWindow::show(const QPoint &pos, const bool model)
|
void DockPopupWindow::show(const QPoint &pos, const bool model)
|
||||||
{
|
{
|
||||||
m_model = model;
|
m_model = model;
|
||||||
@ -141,6 +147,12 @@ void DockPopupWindow::showEvent(QShowEvent *e)
|
|||||||
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
|
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockPopupWindow::hideEvent(QHideEvent *event)
|
||||||
|
{
|
||||||
|
m_extendWidget = nullptr;
|
||||||
|
Dtk::Widget::DArrowRectangle::hideEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void DockPopupWindow::enterEvent(QEvent *e)
|
void DockPopupWindow::enterEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
DArrowRectangle::enterEvent(e);
|
DArrowRectangle::enterEvent(e);
|
||||||
@ -191,6 +203,14 @@ void DockPopupWindow::onButtonPress(int type, int x, int y, const QString &key)
|
|||||||
if (popupRect.contains(x, y))
|
if (popupRect.contains(x, y))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_extendWidget) {
|
||||||
|
// 计算额外添加的区域,如果鼠标的点击点在额外的区域内,也无需隐藏
|
||||||
|
QPoint extendPoint = m_extendWidget->mapToGlobal(QPoint(0, 0));
|
||||||
|
QRect extendRect(extendPoint * qApp->devicePixelRatio(), m_extendWidget->size() * qApp->devicePixelRatio());
|
||||||
|
if (extendRect.contains(QPoint(x, y)))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit accept();
|
emit accept();
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
bool model() const;
|
bool model() const;
|
||||||
|
|
||||||
void setContent(QWidget *content);
|
void setContent(QWidget *content);
|
||||||
|
void setExtendWidget(QWidget *widget);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void show(const QPoint &pos, const bool model = false);
|
void show(const QPoint &pos, const bool model = false);
|
||||||
@ -60,6 +61,7 @@ signals:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *e);
|
void showEvent(QShowEvent *e);
|
||||||
|
void hideEvent(QHideEvent *event);
|
||||||
void enterEvent(QEvent *e);
|
void enterEvent(QEvent *e);
|
||||||
bool eventFilter(QObject *o, QEvent *e);
|
bool eventFilter(QObject *o, QEvent *e);
|
||||||
void blockButtonRelease();
|
void blockButtonRelease();
|
||||||
@ -77,6 +79,7 @@ private:
|
|||||||
QString m_eventKey;
|
QString m_eventKey;
|
||||||
DWindowManagerHelper *m_wmHelper;
|
DWindowManagerHelper *m_wmHelper;
|
||||||
bool m_enableMouseRelease;
|
bool m_enableMouseRelease;
|
||||||
|
QWidget *m_extendWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOCKPOPUPWINDOW_H
|
#endif // DOCKPOPUPWINDOW_H
|
||||||
|
@ -416,7 +416,7 @@ void QuickPluginWindow::onUpdatePlugin(PluginsItemInterface *itemInter, const Do
|
|||||||
|
|
||||||
void QuickPluginWindow::onRequestAppletShow(PluginsItemInterface *itemInter, const QString &itemKey)
|
void QuickPluginWindow::onRequestAppletShow(PluginsItemInterface *itemInter, const QString &itemKey)
|
||||||
{
|
{
|
||||||
showPopup(getDockItemByPlugin(itemInter), itemInter, itemInter->itemPopupApplet(itemKey));
|
showPopup(getDockItemByPlugin(itemInter), itemInter, itemInter->itemPopupApplet(itemKey), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickPluginWindow::startDrag()
|
void QuickPluginWindow::startDrag()
|
||||||
@ -433,8 +433,6 @@ void QuickPluginWindow::startDrag()
|
|||||||
drag->setPixmap(dragPixmap);
|
drag->setPixmap(dragPixmap);
|
||||||
|
|
||||||
drag->setHotSpot(dragPixmap.rect().center());
|
drag->setHotSpot(dragPixmap.rect().center());
|
||||||
//connect(static_cast<QuickDragWidget *>(drag->appDragWidget()), &QuickDragWidget::requestDropItem, this, &QuickPluginWindow::onPluginDropItem);
|
|
||||||
//connect(static_cast<QuickDragWidget *>(drag->appDragWidget()), &QuickDragWidget::requestDragMove, this, &QuickPluginWindow::onPluginDragMove);
|
|
||||||
|
|
||||||
drag->exec(Qt::CopyAction);
|
drag->exec(Qt::CopyAction);
|
||||||
// 获取当前鼠标在任务栏快捷图标区域的位置
|
// 获取当前鼠标在任务栏快捷图标区域的位置
|
||||||
@ -477,13 +475,19 @@ QuickDockItem *QuickPluginWindow::getActiveDockItem(QPoint point) const
|
|||||||
return selectWidget;
|
return selectWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickPluginWindow::showPopup(QuickDockItem *item, PluginsItemInterface *itemInter, QWidget *childPage)
|
void QuickPluginWindow::showPopup(QuickDockItem *item, PluginsItemInterface *itemInter, QWidget *childPage, bool isClicked)
|
||||||
{
|
{
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool canBack = true;
|
bool canBack = true;
|
||||||
DockPopupWindow *popWindow = QuickSettingContainer::popWindow();
|
DockPopupWindow *popWindow = QuickSettingContainer::popWindow();
|
||||||
|
if (isClicked && popWindow->isVisible()) {
|
||||||
|
// 如果是点击插件,并且该插件曾经打开快捷面板且已经是显示状态,那么就直接隐藏快捷面板
|
||||||
|
popWindow->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!popWindow->isVisible()) {
|
if (!popWindow->isVisible()) {
|
||||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||||
// TODO: 临时解决方案,如果是wayland环境,toolTip没有消失,因此,此处直接调用接口来隐藏
|
// TODO: 临时解决方案,如果是wayland环境,toolTip没有消失,因此,此处直接调用接口来隐藏
|
||||||
@ -500,6 +504,7 @@ void QuickPluginWindow::showPopup(QuickDockItem *item, PluginsItemInterface *ite
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popWindow->setExtendWidget(item);
|
||||||
popWindow->show(popupPoint(item), true);
|
popWindow->show(popupPoint(item), true);
|
||||||
canBack = false;
|
canBack = false;
|
||||||
}
|
}
|
||||||
@ -568,53 +573,6 @@ int QuickPluginWindow::getDropIndex(QPoint point)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void QuickPluginWindow::onPluginDropItem(QDropEvent *event)
|
|
||||||
{
|
|
||||||
const QuickPluginMimeData *data = qobject_cast<const QuickPluginMimeData *>(event->mimeData());
|
|
||||||
if (!data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 获取当前鼠标在任务栏快捷图标区域的位置
|
|
||||||
QPoint currentPoint = mapFromGlobal(QCursor::pos());
|
|
||||||
// 获取区域图标插入的位置
|
|
||||||
QuickPluginModel::instance()->addPlugin(data->pluginItemInterface(), getDropIndex(currentPoint));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void QuickPluginWindow::onPluginDragMove(QDragMoveEvent *event)
|
|
||||||
{
|
|
||||||
QPoint currentPoint = mapFromGlobal(QCursor::pos());
|
|
||||||
const QuickPluginMimeData *data = qobject_cast<const QuickPluginMimeData *>(event->mimeData());
|
|
||||||
if (!data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 查找移动的
|
|
||||||
PluginsItemInterface *sourceItem = data->pluginItemInterface();
|
|
||||||
if (!sourceItem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QuickDockItem *sourceMoveWidget = getDockItemByPlugin(sourceItem);
|
|
||||||
QuickDockItem *targetItem = getActiveDockItem(currentPoint);
|
|
||||||
// 如果未找到要移动的目标位置,或者移动的目标位置是固定插件,或者原插件和目标插件是同一个插件,则不做任何操作
|
|
||||||
if (!sourceMoveWidget || !targetItem || sourceMoveWidget == targetItem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 重新对所有的插件进行排序
|
|
||||||
QMap<QWidget *, int> allItems;
|
|
||||||
for (int i = 0; i < m_mainLayout->count(); i++) {
|
|
||||||
QWidget *childWidget = m_mainLayout->itemAt(i)->widget();
|
|
||||||
allItems[childWidget] = i;
|
|
||||||
}
|
|
||||||
// 调整列表中的位置
|
|
||||||
/* int sourceIndex = m_activeSettingItems.indexOf(sourceItem);
|
|
||||||
int targetIndex = m_activeSettingItems.indexOf(targetItem->pluginItem());
|
|
||||||
if (sourceIndex >= 0)
|
|
||||||
m_activeSettingItems.move(sourceIndex, targetIndex);
|
|
||||||
else
|
|
||||||
m_activeSettingItems.insert(targetIndex, sourceItem);
|
|
||||||
*/
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickPluginWindow::dragMoveEvent(QDragMoveEvent *event)
|
void QuickPluginWindow::dragMoveEvent(QDragMoveEvent *event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
@ -69,8 +69,6 @@ protected:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onRequestUpdate();
|
void onRequestUpdate();
|
||||||
//void onPluginDropItem(QDropEvent *event);
|
|
||||||
void onPluginDragMove(QDragMoveEvent *event);
|
|
||||||
void onUpdatePlugin(PluginsItemInterface *itemInter, const DockPart &dockPart);
|
void onUpdatePlugin(PluginsItemInterface *itemInter, const DockPart &dockPart);
|
||||||
void onRequestAppletShow(PluginsItemInterface * itemInter, const QString &itemKey);
|
void onRequestAppletShow(PluginsItemInterface * itemInter, const QString &itemKey);
|
||||||
|
|
||||||
@ -83,7 +81,7 @@ private:
|
|||||||
QPoint popupPoint(QWidget *widget) const;
|
QPoint popupPoint(QWidget *widget) const;
|
||||||
QuickDockItem *getDockItemByPlugin(PluginsItemInterface *item);
|
QuickDockItem *getDockItemByPlugin(PluginsItemInterface *item);
|
||||||
QuickDockItem *getActiveDockItem(QPoint point) const;
|
QuickDockItem *getActiveDockItem(QPoint point) const;
|
||||||
void showPopup(QuickDockItem *item, PluginsItemInterface *itemInter = nullptr, QWidget *childPage = nullptr);
|
void showPopup(QuickDockItem *item, PluginsItemInterface *itemInter = nullptr, QWidget *childPage = nullptr, bool isClicked = true);
|
||||||
QList<QuickDockItem *> quickDockItems();
|
QList<QuickDockItem *> quickDockItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user