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-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()) {
|
switch (event->type()) {
|
||||||
case QEvent::MouseButtonPress: {
|
case QEvent::MouseButtonPress: {
|
||||||
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
|
if (mouseEvent->button() != Qt::LeftButton)
|
||||||
|
break;
|
||||||
|
|
||||||
QuickDockItem *dockItem = qobject_cast<QuickDockItem *>(watched);
|
QuickDockItem *dockItem = qobject_cast<QuickDockItem *>(watched);
|
||||||
if (!dockItem)
|
if (!dockItem)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
|
||||||
m_dragInfo->dockItem = dockItem;
|
m_dragInfo->dockItem = dockItem;
|
||||||
m_dragInfo->dragPoint = mouseEvent->pos();
|
m_dragInfo->dragPoint = mouseEvent->pos();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QEvent::MouseButtonRelease: {
|
case QEvent::MouseButtonRelease: {
|
||||||
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
|
if (mouseEvent->button() != Qt::LeftButton)
|
||||||
|
break;
|
||||||
|
|
||||||
if (m_dragInfo->isNull())
|
if (m_dragInfo->isNull())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
|
||||||
if (!m_dragInfo->canDrag(mouseEvent->pos())) {
|
if (!m_dragInfo->canDrag(mouseEvent->pos())) {
|
||||||
// 弹出快捷设置面板
|
// 弹出快捷设置面板
|
||||||
DockPopupWindow *popWindow = QuickSettingContainer::popWindow();
|
DockPopupWindow *popWindow = QuickSettingContainer::popWindow();
|
||||||
@ -541,38 +547,33 @@ void QuickDockItem::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
void QuickDockItem::mousePressEvent(QMouseEvent *event)
|
void QuickDockItem::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->button()) {
|
if (event->button() != Qt::RightButton)
|
||||||
case Qt::RightButton: {
|
return QWidget::mousePressEvent(event);
|
||||||
if (m_contextMenu->actions().isEmpty()) {
|
|
||||||
const QString menuJson = m_pluginItem->itemContextMenu(m_itemKey);
|
|
||||||
if (menuJson.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(menuJson.toLocal8Bit().data());
|
if (m_contextMenu->actions().isEmpty()) {
|
||||||
if (jsonDocument.isNull())
|
const QString menuJson = m_pluginItem->itemContextMenu(m_itemKey);
|
||||||
return;
|
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();
|
QJsonObject jsonMenu = jsonDocument.object();
|
||||||
for (auto item : jsonMenuItems) {
|
|
||||||
QJsonObject itemObj = item.toObject();
|
QJsonArray jsonMenuItems = jsonMenu.value("items").toArray();
|
||||||
QAction *action = new QAction(itemObj.value("itemText").toString());
|
for (auto item : jsonMenuItems) {
|
||||||
action->setCheckable(itemObj.value("isCheckable").toBool());
|
QJsonObject itemObj = item.toObject();
|
||||||
action->setChecked(itemObj.value("checked").toBool());
|
QAction *action = new QAction(itemObj.value("itemText").toString());
|
||||||
action->setData(itemObj.value("itemId").toString());
|
action->setCheckable(itemObj.value("isCheckable").toBool());
|
||||||
action->setEnabled(itemObj.value("isActive").toBool());
|
action->setChecked(itemObj.value("checked").toBool());
|
||||||
m_contextMenu->addAction(action);
|
action->setData(itemObj.value("itemId").toString());
|
||||||
}
|
action->setEnabled(itemObj.value("isActive").toBool());
|
||||||
|
m_contextMenu->addAction(action);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_contextMenu->exec(QCursor::pos());
|
m_contextMenu->exec(QCursor::pos());
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QWidget::mousePressEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickDockItem::enterEvent(QEvent *event)
|
void QuickDockItem::enterEvent(QEvent *event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user