mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 修复右键插件区域再单击弹出菜单的问题
在插件区域右键弹出菜单后,无需将事件传给基类,因此不会再触发主窗口的菜单的弹出操作 Log: 修复插件区域交互的问题 Influence: 右键插件区域,再左键,观察插件区域菜单是否正常显示 Bug: https://pms.uniontech.com/bug-view-171559.html Change-Id: I6fd4c974c10b89e4921c15e8bf0bb8aecef3eeca
This commit is contained in:
parent
305f1ba8fb
commit
1bf372f2d0
@ -179,20 +179,26 @@ bool QuickPluginWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress: {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() != Qt::LeftButton)
|
||||
break;
|
||||
|
||||
QuickDockItem *dockItem = qobject_cast<QuickDockItem *>(watched);
|
||||
if (!dockItem)
|
||||
break;
|
||||
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
m_dragInfo->dockItem = dockItem;
|
||||
m_dragInfo->dragPoint = mouseEvent->pos();
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() != Qt::LeftButton)
|
||||
break;
|
||||
|
||||
if (m_dragInfo->isNull())
|
||||
break;
|
||||
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (!m_dragInfo->canDrag(mouseEvent->pos())) {
|
||||
// 弹出快捷设置面板
|
||||
DockPopupWindow *popWindow = QuickSettingContainer::popWindow();
|
||||
@ -541,38 +547,33 @@ void QuickDockItem::paintEvent(QPaintEvent *event)
|
||||
|
||||
void QuickDockItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
switch (event->button()) {
|
||||
case Qt::RightButton: {
|
||||
if (m_contextMenu->actions().isEmpty()) {
|
||||
const QString menuJson = m_pluginItem->itemContextMenu(m_itemKey);
|
||||
if (menuJson.isEmpty())
|
||||
return;
|
||||
if (event->button() != Qt::RightButton)
|
||||
return QWidget::mousePressEvent(event);
|
||||
|
||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(menuJson.toLocal8Bit().data());
|
||||
if (jsonDocument.isNull())
|
||||
return;
|
||||
if (m_contextMenu->actions().isEmpty()) {
|
||||
const QString menuJson = m_pluginItem->itemContextMenu(m_itemKey);
|
||||
if (menuJson.isEmpty())
|
||||
return;
|
||||
|
||||
QJsonObject jsonMenu = jsonDocument.object();
|
||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(menuJson.toLocal8Bit().data());
|
||||
if (jsonDocument.isNull())
|
||||
return;
|
||||
|
||||
QJsonArray jsonMenuItems = jsonMenu.value("items").toArray();
|
||||
for (auto item : jsonMenuItems) {
|
||||
QJsonObject itemObj = item.toObject();
|
||||
QAction *action = new QAction(itemObj.value("itemText").toString());
|
||||
action->setCheckable(itemObj.value("isCheckable").toBool());
|
||||
action->setChecked(itemObj.value("checked").toBool());
|
||||
action->setData(itemObj.value("itemId").toString());
|
||||
action->setEnabled(itemObj.value("isActive").toBool());
|
||||
m_contextMenu->addAction(action);
|
||||
}
|
||||
QJsonObject jsonMenu = jsonDocument.object();
|
||||
|
||||
QJsonArray jsonMenuItems = jsonMenu.value("items").toArray();
|
||||
for (auto item : jsonMenuItems) {
|
||||
QJsonObject itemObj = item.toObject();
|
||||
QAction *action = new QAction(itemObj.value("itemText").toString());
|
||||
action->setCheckable(itemObj.value("isCheckable").toBool());
|
||||
action->setChecked(itemObj.value("checked").toBool());
|
||||
action->setData(itemObj.value("itemId").toString());
|
||||
action->setEnabled(itemObj.value("isActive").toBool());
|
||||
m_contextMenu->addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
m_contextMenu->exec(QCursor::pos());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
QWidget::mousePressEvent(event);
|
||||
m_contextMenu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void QuickDockItem::enterEvent(QEvent *event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user