Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 0 additions & 129 deletions plugins/dde-dock/common/dockcontextmenu.cpp

This file was deleted.

62 changes: 0 additions & 62 deletions plugins/dde-dock/common/dockcontextmenu.h

This file was deleted.

2 changes: 2 additions & 0 deletions src/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ add_executable(trayplugin-loader
loader.qrc
dqwaylandplatform.h
dqwaylandplatform.cpp
dockcontextmenu.h
dockcontextmenu.cpp
)

target_include_directories(trayplugin-loader PUBLIC
Expand Down
39 changes: 39 additions & 0 deletions src/loader/dockcontextmenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
//SPDX-License-Identifier: GPL-3.0-or-later

#include "dockcontextmenu.h"

#include <QPainter>

Check warning on line 7 in src/loader/dockcontextmenu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPainter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 8 in src/loader/dockcontextmenu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.

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();
}
14 changes: 14 additions & 0 deletions src/loader/dockcontextmenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
//
//SPDX-License-Identifier: GPL-3.0-or-later

#include <QMenu>

Check warning on line 5 in src/loader/dockcontextmenu.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMenu> not found. Please note: Cppcheck does not need standard library headers to get proper results.

class DockContextMenu : public QMenu
{
public:
explicit DockContextMenu(QWidget *parent = nullptr);

protected:
void paintEvent(QPaintEvent* e) override;
};
5 changes: 4 additions & 1 deletion src/loader/pluginitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include "constants.h"
#include "pluginitem.h"
#include "plugin.h"

Check warning on line 7 in src/loader/pluginitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "plugin.h" not found.
#include "widgetplugin.h"
#include "dockcontextmenu.h"

#include <QHBoxLayout>

Check warning on line 11 in src/loader/pluginitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QHBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMouseEvent>

Check warning on line 12 in src/loader/pluginitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMouseEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QMenu>

const static QString DockQuickPlugins = "Dock_Quick_Plugins";
Expand All @@ -17,7 +18,7 @@
: QWidget(parent)
, m_pluginsItemInterface(pluginItemInterface)
, m_itemKey(itemKey)
, m_menu(new QMenu)
, m_menu(new DockContextMenu(this))
, m_tooltipTimer(new QTimer(this))
, m_tipsWidget(nullptr)
{
Expand Down Expand Up @@ -291,6 +292,8 @@
action->setChecked(itemObj.value("checked").toBool());
action->setData(itemObj.value("itemId").toString());
action->setEnabled(itemObj.value("isActive").toBool());
auto showReminder = itemObj.value("showReminder").toBool();
action->setProperty("showReminder", showReminder);
m_menu->addAction(action);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/loader/pluginitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const int Attribute_ForceUnDock = 0x800000;

class QMenu;
class DockContextMenu;
class PluginItem : public QWidget
{
Q_OBJECT
Expand Down