Skip to content
Open
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
2 changes: 2 additions & 0 deletions panels/dock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ file(
waylanddockhelper.cpp
loadtrayplugins.h
loadtrayplugins.cpp
launcherhelper.h
launcherhelper.cpp
)

# Old dbus interface compatible
Expand Down
3 changes: 3 additions & 0 deletions panels/dock/MenuHelper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
pragma Singleton
import QtQuick
import Qt.labs.platform
import org.deepin.ds.dock.helper 1.0

Item {
property Menu activeMenu: null
function openMenu(menu: Menu) {
if (activeMenu) {
activeMenu.close()
}
// Hide launcher when opening dock menu
LauncherHelper.hideLauncher()
menu.open()
menu.aboutToHide.connect(() => { activeMenu = null })
activeMenu = menu
Expand Down
14 changes: 14 additions & 0 deletions panels/dock/dockpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@

// for old api compatible
#include "dockdbusproxy.h"
#include "dockfrontadaptor.h"

Check warning on line 16 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dockfrontadaptor.h" not found.
#include "dockdaemonadaptor.h"

Check warning on line 17 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dockdaemonadaptor.h" not found.
#include "loadtrayplugins.h"
#include "launcherhelper.h"

#include <DDBusSender>

Check warning on line 21 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 22 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 23 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 24 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 25 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 26 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 27 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 28 in panels/dock/dockpanel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#define SETTINGS DockSettings::instance()

Expand Down Expand Up @@ -54,6 +57,17 @@

bool DockPanel::init()
{
// Register LauncherHelper as QML singleton (only once)
// Use a separate namespace to avoid conflicts with auto-generated registrations
static bool registered = false;
if (!registered) {
qmlRegisterSingletonType<LauncherHelper>("org.deepin.ds.dock.helper", 1, 0, "LauncherHelper",
[](QQmlEngine *, QJSEngine *) -> QObject * {
return LauncherHelper::instance();
Comment on lines +64 to +66
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Consider qualifying LauncherHelper with its namespace in both the template parameter and the factory lambda.

Since LauncherHelper lives in the dock namespace, please qualify it as dock::LauncherHelper in both the qmlRegisterSingletonType template parameter and the lambda return to avoid potential name lookup/ODR issues if another LauncherHelper is introduced elsewhere.

qmlRegisterSingletonType<dock::LauncherHelper>(
    "org.deepin.ds.dock.helper", 1, 0, "LauncherHelper",
    [](QQmlEngine *, QJSEngine *) -> QObject * {
        return dock::LauncherHelper::instance();
    });

});
registered = true;
}

DockAdaptor* adaptor = new DockAdaptor(this);
Q_UNUSED(adaptor)
QDBusConnection::sessionBus().registerService("org.deepin.ds.Dock");
Expand Down
46 changes: 46 additions & 0 deletions panels/dock/launcherhelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "launcherhelper.h"

#include <QDBusInterface>
#include <QDBusMessage>
#include <QLoggingCategory>

Q_LOGGING_CATEGORY(launcherHelper, "org.deepin.dde.shell.dock.launcherhelper")

namespace dock {

LauncherHelper* LauncherHelper::instance()
{
static LauncherHelper* helper = new LauncherHelper();
return helper;
}

LauncherHelper::LauncherHelper(QObject *parent)
: QObject(parent)
{
}

void LauncherHelper::hideLauncher()
{
// Call dde-launchpad's D-Bus interface to hide the launcher
QDBusInterface launcherInterface("org.deepin.dde.Launcher1",
"/org/deepin/dde/Launcher1",
"org.deepin.dde.Launcher1");

if (!launcherInterface.isValid()) {
qCDebug(launcherHelper) << "Launcher D-Bus interface is not available";
return;
}

QDBusMessage reply = launcherInterface.call("Hide");
if (reply.type() == QDBusMessage::ErrorMessage) {
qCWarning(launcherHelper) << "Failed to hide launcher:" << reply.errorMessage();
} else {
qCDebug(launcherHelper) << "Successfully requested launcher to hide";
}
}

}
25 changes: 25 additions & 0 deletions panels/dock/launcherhelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>

namespace dock {

class LauncherHelper : public QObject
{
Q_OBJECT

public:
static LauncherHelper* instance();

Q_INVOKABLE void hideLauncher();

private:
explicit LauncherHelper(QObject *parent = nullptr);
~LauncherHelper() override = default;
};

}