forked from linuxdeepin/dde-tray-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockcontextmenu.cpp
More file actions
39 lines (32 loc) · 1.04 KB
/
Copy pathdockcontextmenu.cpp
File metadata and controls
39 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
//SPDX-License-Identifier: GPL-3.0-or-later
#include "dockcontextmenu.h"
#include <QPainter>
#include <QWindow>
static const bool IS_WAYLAND_DISPLAY = !qgetenv("WAYLAND_DISPLAY").isEmpty();
DockContextMenu::DockContextMenu(QWidget *parent)
: QMenu(parent)
{
// 解决键盘上下键不能操作右键菜单
if (IS_WAYLAND_DISPLAY) {
setAttribute(Qt::WA_NativeWindow);
windowHandle()->setProperty("_d_dwayland_window-type", "focusmenu");
}
}
void DockContextMenu::paintEvent(QPaintEvent* e)
{
QMenu::paintEvent(e);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
for (auto action : actions()) {
if (action->property("showReminder").toBool()) {
auto geo = actionGeometry(action);
QColor color("#FF3B30");
p.setPen(color);
p.setBrush(color);
p.drawEllipse(geo.x() + geo.width() - 26, geo.y() + (geo.height() - 6) / 2, 6, 6);
}
}
p.end();
}