mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: tray menu is hidden before function call
Log: 修复托盘在菜单中的行为被调用前被隐藏
This commit is contained in:
parent
c65ddcdbc9
commit
64fe544d0c
@ -32,6 +32,7 @@ public:
|
|||||||
virtual bool needShow();
|
virtual bool needShow();
|
||||||
virtual void setNeedShow(bool needShow);
|
virtual void setNeedShow(bool needShow);
|
||||||
virtual QPixmap icon() = 0;
|
virtual QPixmap icon() = 0;
|
||||||
|
virtual bool containsPoint(const QPoint& mouse) = 0;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void iconChanged();
|
void iconChanged();
|
||||||
|
@ -132,7 +132,7 @@ TrayGridWidget *ExpandIconWidget::popupTrayView()
|
|||||||
TrayModel *trayModel = TrayModel::getIconModel();
|
TrayModel *trayModel = TrayModel::getIconModel();
|
||||||
gridParentView->setTrayGridView(trayView);
|
gridParentView->setTrayGridView(trayView);
|
||||||
|
|
||||||
gridParentView->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
|
gridParentView->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
|
||||||
trayView->setModel(trayModel);
|
trayView->setModel(trayModel);
|
||||||
trayView->setItemDelegate(trayDelegate);
|
trayView->setItemDelegate(trayDelegate);
|
||||||
trayView->setSpacing(ITEM_SPACING);
|
trayView->setSpacing(ITEM_SPACING);
|
||||||
@ -294,7 +294,7 @@ void TrayGridWidget::initMember()
|
|||||||
QAbstractItemModel *dataModel = m_trayGridView->model();
|
QAbstractItemModel *dataModel = m_trayGridView->model();
|
||||||
for (int i = 0; i < dataModel->rowCount(); i++) {
|
for (int i = 0; i < dataModel->rowCount(); i++) {
|
||||||
QModelIndex index = dataModel->index(i, 0);
|
QModelIndex index = dataModel->index(i, 0);
|
||||||
SystemPluginItem *widget = qobject_cast<SystemPluginItem *>(m_trayGridView->indexWidget(index));
|
BaseTrayWidget *widget = qobject_cast<BaseTrayWidget *>(m_trayGridView->indexWidget(index));
|
||||||
if (widget && widget->containsPoint(mousePos))
|
if (widget && widget->containsPoint(mousePos))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
void updateIcon() override {}
|
void updateIcon() override {}
|
||||||
QPixmap icon() override;
|
QPixmap icon() override;
|
||||||
static TrayGridWidget *popupTrayView();
|
static TrayGridWidget *popupTrayView();
|
||||||
|
bool containsPoint(const QPoint &mouse) override { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
QPixmap icon() override;
|
QPixmap icon() override;
|
||||||
const QByteArray &pixmapData() const;
|
const QByteArray &pixmapData() const;
|
||||||
const QString text() const;
|
const QString text() const;
|
||||||
|
bool containsPoint(const QPoint &mouse) override { return false; }
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
Q_SCRIPTABLE void setPixmapData(const QByteArray &data);
|
Q_SCRIPTABLE void setPixmapData(const QByteArray &data);
|
||||||
|
@ -779,3 +779,15 @@ void SNITrayItemWidget::setMouseData(QMouseEvent *e)
|
|||||||
|
|
||||||
m_handleMouseReleaseTimer->start();
|
m_handleMouseReleaseTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SNITrayItemWidget::containsPoint(const QPoint &pos) {
|
||||||
|
QPoint ptGlobal = mapToGlobal(QPoint(0, 0));
|
||||||
|
QRect rectGlobal(ptGlobal, this->size());
|
||||||
|
if (rectGlobal.contains(pos)) return true;
|
||||||
|
|
||||||
|
// 如果菜单列表隐藏,则认为不在区域内
|
||||||
|
if (!m_menu->isVisible()) return false;
|
||||||
|
|
||||||
|
// 判断鼠标是否在菜单区域
|
||||||
|
return m_menu->geometry().contains(pos);
|
||||||
|
}
|
||||||
|
@ -59,6 +59,8 @@ public:
|
|||||||
|
|
||||||
static void setDockPostion(const Dock::Position pos) { DockPosition = pos; }
|
static void setDockPostion(const Dock::Position pos) { DockPosition = pos; }
|
||||||
|
|
||||||
|
bool containsPoint(const QPoint& mouse) override;
|
||||||
|
|
||||||
QPixmap icon() override;
|
QPixmap icon() override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -369,7 +369,7 @@ void SystemPluginItem::hidePopup()
|
|||||||
emit requestWindowAutoHide(true);
|
emit requestWindowAutoHide(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemPluginItem::containsPoint(QPoint pos)
|
bool SystemPluginItem::containsPoint(const QPoint& pos)
|
||||||
{
|
{
|
||||||
QPoint ptGlobal = mapToGlobal(QPoint(0, 0));
|
QPoint ptGlobal = mapToGlobal(QPoint(0, 0));
|
||||||
QRect rectGlobal(ptGlobal, this->size());
|
QRect rectGlobal(ptGlobal, this->size());
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
void showPopupApplet(QWidget * const applet);
|
void showPopupApplet(QWidget * const applet);
|
||||||
void hidePopup();
|
void hidePopup();
|
||||||
bool containsPoint(QPoint pos);
|
bool containsPoint(const QPoint& mouse) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void itemVisibleChanged(bool visible);
|
void itemVisibleChanged(bool visible);
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
static bool isXEmbedKey(const QString &itemKey);
|
static bool isXEmbedKey(const QString &itemKey);
|
||||||
virtual bool isValid() override {return m_valid;}
|
virtual bool isValid() override {return m_valid;}
|
||||||
QPixmap icon() override;
|
QPixmap icon() override;
|
||||||
|
bool containsPoint(const QPoint &mouse) override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showEvent(QShowEvent *e) override;
|
void showEvent(QShowEvent *e) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user