mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 点击任务栏插件时,只有点击图标区域时才有效点击
点击任务栏插件时,根据图标大小,计算点击区域是否为有效区域 Log: 修复任务栏中的图标的可点击范围超出图标显示区域 Bug: https://pms.uniontech.com/zentao/bug-view-43531.html Change-Id: I7345171a6cc97d45d3d2c1dcb7e5ff4f3178757d Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/2833 Reviewed-by: <mailman@uniontech.com> Reviewed-by: lizhongming <lizhongming@uniontech.com> Tested-by: <mailman@uniontech.com>
This commit is contained in:
parent
76d0acd6d5
commit
ee2e60bbb7
@ -63,6 +63,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
m_popupAdjustDelayTimer->setInterval(10);
|
||||
m_popupAdjustDelayTimer->setSingleShot(true);
|
||||
|
||||
setMouseTracking(true);
|
||||
setGraphicsEffect(m_hoverEffect);
|
||||
|
||||
connect(m_popupTipsDelayTimer, &QTimer::timeout, this, &DockItem::showHoverTips);
|
||||
@ -178,9 +179,15 @@ void DockItem::enterEvent(QEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
m_hover = true;
|
||||
m_hoverEffect->setHighlighting(true);
|
||||
m_popupTipsDelayTimer->start();
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
m_hoverEffect->setHighlighting(true);
|
||||
m_popupTipsDelayTimer->start();
|
||||
} else {
|
||||
m_hover = false;
|
||||
m_hoverEffect->setHighlighting(false);
|
||||
m_popupTipsDelayTimer->stop();
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
@ -200,6 +207,26 @@ void DockItem::leaveEvent(QEvent *e)
|
||||
hidePopup();
|
||||
|
||||
update();
|
||||
|
||||
QWidget::leaveEvent(e);
|
||||
}
|
||||
|
||||
void DockItem::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
m_hoverEffect->setHighlighting(true);
|
||||
m_popupTipsDelayTimer->start();
|
||||
} else {
|
||||
m_hover = false;
|
||||
m_hoverEffect->setHighlighting(false);
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mouseMoveEvent(e);
|
||||
}
|
||||
|
||||
const QRect DockItem::perfectIconRect() const
|
||||
@ -264,6 +291,20 @@ void DockItem::onContextMenuAccepted()
|
||||
emit requestWindowAutoHide(true);
|
||||
}
|
||||
|
||||
bool DockItem::containCursorPos()
|
||||
{
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
return rect.contains(cursorPos);
|
||||
}
|
||||
|
||||
void DockItem::showHoverTips()
|
||||
{
|
||||
// another model popup window already exists
|
||||
|
@ -76,11 +76,12 @@ signals:
|
||||
void requestRefreshWindowVisible() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void enterEvent(QEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
bool event(QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void enterEvent(QEvent *e) override;
|
||||
void leaveEvent(QEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
||||
const QRect perfectIconRect() const;
|
||||
const QPoint popupMarkPoint() ;
|
||||
@ -100,6 +101,7 @@ protected:
|
||||
protected slots:
|
||||
void showContextMenu();
|
||||
void onContextMenuAccepted();
|
||||
bool containCursorPos();
|
||||
|
||||
private:
|
||||
void updatePopupPosition();
|
||||
|
@ -140,7 +140,10 @@ void PluginsItem::mousePressEvent(QMouseEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
m_hover = false;
|
||||
if (!containCursorPos()) {
|
||||
return;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
if (PopupWindow->isVisible())
|
||||
@ -159,8 +162,7 @@ void PluginsItem::mouseMoveEvent(QMouseEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->buttons() != Qt::LeftButton)
|
||||
return DockItem::mouseMoveEvent(e);
|
||||
DockItem::mouseMoveEvent(e);
|
||||
|
||||
e->accept();
|
||||
|
||||
@ -175,8 +177,6 @@ void PluginsItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
DockItem::mouseReleaseEvent(e);
|
||||
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
@ -187,6 +187,10 @@ void PluginsItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
|
||||
e->accept();
|
||||
|
||||
if (!containCursorPos()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QPoint distance = e->pos() - MousePressPoint;
|
||||
if (distance.manhattanLength() < PLUGIN_ITEM_DRAG_THRESHOLD)
|
||||
mouseClicked();
|
||||
@ -198,7 +202,6 @@ void PluginsItem::enterEvent(QEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
m_hover = true;
|
||||
update();
|
||||
|
||||
DockItem::enterEvent(event);
|
||||
@ -234,10 +237,6 @@ bool PluginsItem::eventFilter(QObject *watched, QEvent *event)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
m_hover = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -46,6 +46,7 @@ BluetoothItem::BluetoothItem(QWidget *parent)
|
||||
, m_tipsLabel(new TipsWidget(this))
|
||||
, m_applet(new BluetoothApplet(this))
|
||||
{
|
||||
setMouseTracking(true);
|
||||
m_applet->setVisible(false);
|
||||
m_adapterPowered = m_applet->poweredInitState();
|
||||
|
||||
|
@ -41,6 +41,7 @@ DatetimeWidget::DatetimeWidget(QWidget *parent)
|
||||
, m_24HourFormat(false)
|
||||
, m_timeOffset(false)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setMinimumSize(PLUGIN_BACKGROUND_MIN_SIZE, PLUGIN_BACKGROUND_MIN_SIZE);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ NetworkItem::NetworkItem(QWidget *parent)
|
||||
, m_timer(new QTimer(this))
|
||||
, m_switchWireTimer(new QTimer(this))
|
||||
{
|
||||
setMouseTracking(true);
|
||||
m_timer->setInterval(100);
|
||||
|
||||
m_tipsWidget->setVisible(false);
|
||||
|
@ -121,7 +121,12 @@ const QPixmap OnboardItem::loadSvg(const QString &fileName, const QSize &size) c
|
||||
|
||||
void OnboardItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_pressed = true;
|
||||
if (containCursorPos()) {
|
||||
m_pressed = true;
|
||||
} else {
|
||||
m_pressed = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
@ -138,7 +143,13 @@ void OnboardItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
void OnboardItem::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_hover = true;
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
@ -156,3 +167,17 @@ void OnboardItem::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
bool OnboardItem::containCursorPos()
|
||||
{
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
return rect.contains(cursorPos);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
bool containCursorPos();
|
||||
|
||||
private:
|
||||
Dock::DisplayMode m_displayMode;
|
||||
|
@ -35,6 +35,7 @@ PowerStatusWidget::PowerStatusWidget(QWidget *parent)
|
||||
m_powerInter(new DBusPower(this))
|
||||
{
|
||||
// QIcon::setThemeName("deepin");
|
||||
setMouseTracking(true);
|
||||
|
||||
connect(m_powerInter, &DBusPower::BatteryPercentageChanged, this, static_cast<void (PowerStatusWidget::*)()>(&PowerStatusWidget::update));
|
||||
connect(m_powerInter, &DBusPower::BatteryStateChanged, this, static_cast<void (PowerStatusWidget::*)()>(&PowerStatusWidget::update));
|
||||
|
@ -122,9 +122,28 @@ const QPixmap ShutdownWidget::loadSvg(const QString &fileName, const QSize &size
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
bool ShutdownWidget::containCursorPos()
|
||||
{
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
return rect.contains(cursorPos);
|
||||
}
|
||||
|
||||
void ShutdownWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_pressed = true;
|
||||
if (containCursorPos()) {
|
||||
m_pressed = true;
|
||||
} else {
|
||||
m_pressed = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
@ -141,7 +160,14 @@ void ShutdownWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
void ShutdownWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_hover = true;
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ protected:
|
||||
|
||||
private:
|
||||
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;
|
||||
bool containCursorPos();
|
||||
|
||||
private:
|
||||
Dock::DisplayMode m_displayMode;
|
||||
|
@ -50,6 +50,8 @@ SoundItem::SoundItem(QWidget *parent)
|
||||
, m_applet(new SoundApplet(this))
|
||||
, m_sinkInter(nullptr)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
|
||||
m_tipsLabel->setObjectName("sound");
|
||||
m_tipsLabel->setAccessibleName("soundtips");
|
||||
m_tipsLabel->setVisible(false);
|
||||
|
@ -52,9 +52,9 @@ signals:
|
||||
void requestContextMenu() const;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void wheelEvent(QWheelEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void refreshTips(const bool force = false);
|
||||
|
@ -38,6 +38,7 @@ TrashWidget::TrashWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_popupApplet(new PopupControlWidget(this))
|
||||
{
|
||||
setMouseTracking(true);
|
||||
m_popupApplet->setVisible(false);
|
||||
|
||||
connect(m_popupApplet, &PopupControlWidget::emptyChanged, this, &TrashWidget::updateIconAndRefresh);
|
||||
|
@ -30,6 +30,8 @@ AbstractTrayWidget::AbstractTrayWidget(QWidget *parent, Qt::WindowFlags f)
|
||||
: QWidget(parent, f)
|
||||
, m_handleMouseReleaseTimer(new QTimer(this))
|
||||
{
|
||||
setMouseTracking(true);
|
||||
|
||||
m_handleMouseReleaseTimer->setSingleShot(true);
|
||||
m_handleMouseReleaseTimer->setInterval(100);
|
||||
|
||||
@ -132,3 +134,17 @@ void AbstractTrayWidget::resizeEvent(QResizeEvent *event)
|
||||
setMaximumWidth(QWIDGETSIZE_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractTrayWidget::containCursorPos()
|
||||
{
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
return rect.contains(cursorPos);
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ protected:
|
||||
void handleMouseRelease();
|
||||
const QRect perfectIconRect() const;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
bool containCursorPos();
|
||||
|
||||
private:
|
||||
QTimer *m_handleMouseReleaseTimer;
|
||||
|
@ -45,6 +45,7 @@ FashionTrayControlWidget::FashionTrayControlWidget(Dock::Position position, QWid
|
||||
m_expandDelayTimer->setInterval(400);
|
||||
m_expandDelayTimer->setSingleShot(true);
|
||||
|
||||
setMouseTracking(true);
|
||||
setDockPostion(m_dockPosition);
|
||||
setExpanded(m_expanded);
|
||||
|
||||
@ -147,7 +148,10 @@ void FashionTrayControlWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
event->accept();
|
||||
setExpanded(!m_expanded);
|
||||
|
||||
if (containCursorPos()) {
|
||||
setExpanded(!m_expanded);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -161,7 +165,12 @@ void FashionTrayControlWidget::mousePressEvent(QMouseEvent *event)
|
||||
return QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
m_pressed = true;
|
||||
if (containCursorPos()) {
|
||||
m_pressed = true;
|
||||
} else {
|
||||
m_pressed = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
@ -169,7 +178,12 @@ void FashionTrayControlWidget::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void FashionTrayControlWidget::enterEvent(QEvent *event)
|
||||
{
|
||||
m_hover = true;
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::enterEvent(event);
|
||||
@ -189,6 +203,19 @@ void FashionTrayControlWidget::resizeEvent(QResizeEvent *event)
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void FashionTrayControlWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void FashionTrayControlWidget::refreshArrowPixmap()
|
||||
{
|
||||
QString iconPath;
|
||||
@ -211,3 +238,17 @@ void FashionTrayControlWidget::refreshArrowPixmap()
|
||||
const auto ratio = devicePixelRatioF();
|
||||
m_arrowPix = ImageUtil::loadSvg(iconPath, ":/icons/resources/", PLUGIN_ICON_MAX_SIZE, ratio);
|
||||
}
|
||||
|
||||
bool FashionTrayControlWidget::containCursorPos()
|
||||
{
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
return rect.contains(cursorPos);
|
||||
}
|
||||
|
@ -48,9 +48,11 @@ protected:
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void refreshArrowPixmap();
|
||||
bool containCursorPos();
|
||||
|
||||
private:
|
||||
QTimer *m_expandDelayTimer;
|
||||
|
@ -52,6 +52,7 @@ FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, Abstr
|
||||
setStyleSheet("background: transparent;");
|
||||
setAcceptDrops(true);
|
||||
setObjectName(itemKey);
|
||||
setMouseTracking(true);
|
||||
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setMargin(0);
|
||||
@ -87,6 +88,10 @@ void FashionTrayWidgetWrapper::paintEvent(QPaintEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_itemKey == "sound-item-key") {
|
||||
qDebug() << m_itemKey << rect() << m_absTrayWidget << m_absTrayWidget->rect();
|
||||
}
|
||||
|
||||
if (rect().height() > PLUGIN_BACKGROUND_MIN_SIZE) {
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
@ -136,7 +141,12 @@ void FashionTrayWidgetWrapper::mousePressEvent(QMouseEvent *event)
|
||||
MousePressPoint = event->pos();
|
||||
}
|
||||
|
||||
m_pressed = true;
|
||||
if (containCursorPos()) {
|
||||
m_pressed = true;
|
||||
} else {
|
||||
m_pressed = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
@ -169,7 +179,12 @@ void FashionTrayWidgetWrapper::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
||||
void FashionTrayWidgetWrapper::enterEvent(QEvent *event)
|
||||
{
|
||||
m_hover = true;
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
QWidget::enterEvent(event);
|
||||
@ -213,6 +228,14 @@ void FashionTrayWidgetWrapper::handleMouseMove(QMouseEvent *event)
|
||||
if(m_absTrayWidget.isNull())
|
||||
return;
|
||||
|
||||
if (containCursorPos()) {
|
||||
m_hover = true;
|
||||
} else {
|
||||
m_hover = false;
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
if (event->buttons() != Qt::MouseButton::LeftButton) {
|
||||
return QWidget::mouseMoveEvent(event);
|
||||
}
|
||||
@ -256,6 +279,20 @@ void FashionTrayWidgetWrapper::onTrayWidgetClicked()
|
||||
setAttention(false);
|
||||
}
|
||||
|
||||
bool FashionTrayWidgetWrapper::containCursorPos()
|
||||
{
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
return rect.contains(cursorPos);
|
||||
}
|
||||
|
||||
bool FashionTrayWidgetWrapper::attention() const
|
||||
{
|
||||
return m_attention;
|
||||
|
@ -64,6 +64,7 @@ private:
|
||||
void handleMouseMove(QMouseEvent *event);
|
||||
void onTrayWidgetNeedAttention();
|
||||
void onTrayWidgetClicked();
|
||||
bool containCursorPos();
|
||||
|
||||
private:
|
||||
QPointer<AbstractTrayWidget> m_absTrayWidget;
|
||||
|
@ -33,6 +33,7 @@ IndicatorTrayWidget::IndicatorTrayWidget(const QString &indicatorName, QWidget *
|
||||
, m_indicatorName(indicatorName)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setMouseTracking(true);
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
@ -560,7 +560,12 @@ QPixmap SNITrayWidget::newIconPixmap(IconType iconType)
|
||||
|
||||
void SNITrayWidget::enterEvent(QEvent *event)
|
||||
{
|
||||
m_popupTipsDelayTimer->start();
|
||||
if (containCursorPos()) {
|
||||
m_popupTipsDelayTimer->start();
|
||||
} else {
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
AbstractTrayWidget::enterEvent(event);
|
||||
}
|
||||
@ -576,6 +581,18 @@ void SNITrayWidget::leaveEvent(QEvent *event)
|
||||
AbstractTrayWidget::leaveEvent(event);
|
||||
}
|
||||
|
||||
void SNITrayWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (containCursorPos()) {
|
||||
m_popupTipsDelayTimer->start();
|
||||
} else {
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
AbstractTrayWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void SNITrayWidget::showHoverTips()
|
||||
{
|
||||
if (PopupWindow->model())
|
||||
|
@ -101,6 +101,7 @@ private Q_SLOTS:
|
||||
void popupWindowAccept();
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
@ -41,6 +41,7 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
, m_itemKey(itemKey)
|
||||
{
|
||||
qDebug() << "load tray plugins item: " << m_pluginInter->pluginName() << itemKey << m_centralWidget;
|
||||
setMouseTracking(true);
|
||||
|
||||
m_centralWidget->setParent(this);
|
||||
m_centralWidget->setVisible(true);
|
||||
@ -202,7 +203,13 @@ void SystemTrayItem::enterEvent(QEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
m_popupTipsDelayTimer->start();
|
||||
if (containCursorPos()) {
|
||||
m_popupTipsDelayTimer->start();
|
||||
} else {
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
AbstractTrayWidget::enterEvent(event);
|
||||
@ -249,6 +256,19 @@ void SystemTrayItem::mouseReleaseEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
QPoint cursorPos = this->mapFromGlobal(QCursor::pos());
|
||||
QRect rect(this->rect());
|
||||
|
||||
int iconSize = qMin(rect.width(), rect.height());
|
||||
int w = (rect.width() - iconSize) / 2;
|
||||
int h = (rect.height() - iconSize) / 2;
|
||||
|
||||
rect = rect.adjusted(w, h, -w, -h);
|
||||
|
||||
if (!rect.contains(cursorPos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkAndResetTapHoldGestureState() && event->source() == Qt::MouseEventSynthesizedByQt) {
|
||||
qDebug() << "SystemTray: tap and hold gesture detected, ignore the synthesized mouse release event";
|
||||
return;
|
||||
@ -274,6 +294,18 @@ void SystemTrayItem::showEvent(QShowEvent *event)
|
||||
return AbstractTrayWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void SystemTrayItem::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (containCursorPos()) {
|
||||
m_popupTipsDelayTimer->start();
|
||||
} else {
|
||||
m_popupTipsDelayTimer->stop();
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
AbstractTrayWidget::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
const QPoint SystemTrayItem::popupMarkPoint() const
|
||||
{
|
||||
QPoint p(topleftPoint());
|
||||
|
@ -72,6 +72,7 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
protected:
|
||||
const QPoint popupMarkPoint() const;
|
||||
|
@ -147,7 +147,11 @@ void XEmbedTrayWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
m_sendHoverEvent->start();
|
||||
if (containCursorPos()) {
|
||||
m_sendHoverEvent->start();;
|
||||
} else {
|
||||
m_sendHoverEvent->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void XEmbedTrayWidget::configContainerPosition()
|
||||
|
Loading…
x
Reference in New Issue
Block a user