fix: not left mouse click will also trigger the command of plugin

Log: make only Left mouse click will trigger the command of plugin
This commit is contained in:
chenhongtao 2023-04-18 10:14:33 +08:00 committed by Access
parent 384fdc46ba
commit 82caae4c83
3 changed files with 15 additions and 2 deletions

View File

@ -10,12 +10,13 @@
#include <DGuiApplicationHelper>
#include <DFontSizeManager>
#include <DStyle>
#include <QLabel>
#include <QHBoxLayout>
#include <QPainter>
#include <QPainterPath>
#include <DStyle>
#include <QMouseEvent>
DGUI_USE_NAMESPACE
DWIDGET_USE_NAMESPACE
@ -81,6 +82,10 @@ bool BluetoothMainWidget::eventFilter(QObject *watcher, QEvent *event)
break;
}
case QEvent::MouseButtonRelease: {
QMouseEvent *mouseevent = static_cast<QMouseEvent *>(event);
if (mouseevent->button() != Qt::LeftButton) {
return QWidget::eventFilter(watcher, event);
}
bool status = !(isOpen());
for (const Adapter *adapter : m_adapterManager->adapters())
m_adapterManager->setAdapterPowered(adapter, status);

View File

@ -13,6 +13,7 @@
#include <QLabel>
#include <QHBoxLayout>
#include <QPainter>
#include <QMouseEvent>
#define BGSIZE 36
#define ICONWIDTH 24
@ -73,6 +74,10 @@ bool LargerQuickItem::eventFilter(QObject *obj, QEvent *event)
switch (event->type()) {
case QEvent::MouseButtonRelease: {
QMouseEvent *mouseevent = static_cast<QMouseEvent *>(event);
if (mouseevent->button() != Qt::LeftButton) {
return QuickSettingItem::eventFilter(obj, event);
}
if (obj->objectName() == "expandLabel") {
// 如果是鼠标的按下事件
QWidget *widget = pluginItem()->itemPopupApplet(QUICK_ITEM_KEY);

View File

@ -12,6 +12,7 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QMouseEvent>
static constexpr int ICONHEIGHT = 24;
static constexpr int ICONWIDTH = 24;
@ -38,7 +39,9 @@ QuickSettingItem::QuickItemStyle StandardQuickItem::type() const
void StandardQuickItem::mouseReleaseEvent(QMouseEvent *event)
{
Q_UNUSED(event);
if (event->button() != Qt::LeftButton) {
return;
}
QStringList commandArgument = pluginItem()->itemCommand(itemKey()).split(" ");
if (commandArgument.size() > 0) {
QString command = commandArgument.first();