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
1 change: 1 addition & 0 deletions applets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
add_subdirectory(dde-am)
add_subdirectory(dde-appearance)
add_subdirectory(dde-apps)
add_subdirectory(dde-shutdown)
15 changes: 15 additions & 0 deletions applets/dde-shutdown/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

add_library(dde-shutdown SHARED
shutdownapplet.cpp
shutdownapplet.h
)

target_link_libraries(dde-shutdown PRIVATE
dde-shell-frame
Qt${QT_MAJOR_VERSION}::DBus
)

ds_install_package(PACKAGE org.deepin.ds.dde-shutdown TARGET dde-shutdown)
7 changes: 7 additions & 0 deletions applets/dde-shutdown/package/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Plugin": {
"Version": "1.0",
"Id": "org.deepin.ds.dde-shutdown",
"Category": "DDE"
}
}
51 changes: 51 additions & 0 deletions applets/dde-shutdown/shutdownapplet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "shutdownapplet.h"
#include "pluginfactory.h"

#include <QDebug>
#include <QGuiApplication>

#include <DDBusSender>
DCORE_USE_NAMESPACE

DS_BEGIN_NAMESPACE
namespace shutdown {

ShutdownApplet::ShutdownApplet(QObject *parent)
: DApplet(parent)
{
}

ShutdownApplet::~ShutdownApplet()
{
}

bool ShutdownApplet::load()
{
return true;
}

bool ShutdownApplet::requestShutdown()

Check warning on line 31 in applets/dde-shutdown/shutdownapplet.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'requestShutdown' is never used.
{
if (QStringLiteral("wayland") == QGuiApplication::platformName()) {
qDebug() << "request treeland shutdown";
} else {
DDBusSender()
.service("org.deepin.dde.ShutdownFront1")
.interface("org.deepin.dde.ShutdownFront1")
.path("/org/deepin/dde/ShutdownFront1")
.method("Show")
.call();
}

return true;
}

D_APPLET_CLASS(ShutdownApplet)
}
DS_END_NAMESPACE

#include "shutdownapplet.moc"
25 changes: 25 additions & 0 deletions applets/dde-shutdown/shutdownapplet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include "applet.h"

DS_BEGIN_NAMESPACE
namespace shutdown {
class ShutdownApplet : public DApplet
{
Q_OBJECT
public:
explicit ShutdownApplet(QObject *parent = nullptr);
~ShutdownApplet();

virtual bool load() override;

public Q_SLOTS:
bool requestShutdown();
};

}
DS_END_NAMESPACE
5 changes: 5 additions & 0 deletions panels/dock/DockCompositor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Item {

signal pluginSurfacesUpdated()
signal popupCreated(var popup)
signal requestShutdown()

function removeDockPluginSurface(model, object) {
for (var i = 0; i < model.count; ++i) {
Expand Down Expand Up @@ -101,6 +102,10 @@ Item {
console.log("plugin popup created", popup.pluginId, popup.itemKey, popup.popupType)
dockCompositor.popupCreated(popup)
}

onRequestShutdown: {
dockCompositor.requestShutdown()
}
}
}
}
6 changes: 6 additions & 0 deletions panels/dock/pluginmanagerextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ void PluginSurface::plugin_dcc_icon(Resource *resource, const QString &icon)
m_dccIcon = icon;
}

void PluginSurface::plugin_request_shutdown(Resource *resource)
{
Q_UNUSED(resource);
Q_EMIT m_manager->requestShutdown();
}

void PluginSurface::plugin_destroy_resource(Resource *resource)
{
Q_UNUSED(resource);
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/pluginmanagerextension_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class PluginManager : public QWaylandCompositorExtensionTemplate<PluginManager>,
void pluginSurfaceDestroyed(PluginSurface*);
void messageRequest(PluginSurface *, const QString &msg);
void dockSizeChanged();
void requestShutdown();

protected:
virtual void plugin_manager_v1_request_message(Resource *resource, const QString &plugin_id, const QString &item_key, const QString &msg) override;
Expand Down Expand Up @@ -131,6 +132,7 @@ class PluginSurface : public QWaylandShellSurfaceTemplate<PluginSurface>, public
protected:
virtual void plugin_mouse_event(Resource *resource, int32_t type) override;
virtual void plugin_dcc_icon(Resource *resource, const QString &icon) override;
virtual void plugin_request_shutdown(Resource *resource) override;
virtual void plugin_destroy_resource(Resource *resource) override;
virtual void plugin_destroy(Resource *resource) override;

Expand Down
9 changes: 9 additions & 0 deletions panels/dock/tray/package/tray.qml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ AppletItem {
DDT.TraySortOrderModel.availableSurfaces = surfacesData
console.log("onPluginSurfacesUpdated", surfacesData.length)
}

function onRequestShutdown() {
var shutdown = DS.applet("org.deepin.ds.dde-shutdown")
if (shutdown) {
shutdown.requestShutdown()
} else {
console.warn("shutdown applet not found")
}
}
}

WaylandOutput {
Expand Down
7 changes: 6 additions & 1 deletion panels/dock/tray/quickpanel/PanelPluginPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ Item {
icon.name: "quickpanel-power"
onClicked: function () {
console.log("clicked shutdown")
model.openShutdownScreen()
var shutdown = DS.applet("org.deepin.ds.dde-shutdown")
if (shutdown) {
shutdown.requestShutdown()
} else {
console.warn("shutdown applet not found")
}
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions panels/dock/tray/quickpanel/quickpanelproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ void QuickPanelProxyModel::openSystemSettings()
.call();
}

void QuickPanelProxyModel::openShutdownScreen()
{
DDBusSender()
.service("org.deepin.dde.ShutdownFront1")
.interface("org.deepin.dde.ShutdownFront1")
.path("/org/deepin/dde/ShutdownFront1")
.method("Show")
.call();
}

QVariant QuickPanelProxyModel::data(const QModelIndex &index, int role) const
{
const auto sourceIndex = mapToSource(index);
Expand Down
1 change: 0 additions & 1 deletion panels/dock/tray/quickpanel/quickpanelproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class QuickPanelProxyModel : public QSortFilterProxyModel, public QQmlParserStat
Q_INVOKABLE QString getTitle(const QString &pluginId) const;
Q_INVOKABLE bool isQuickPanelPopup(const QString &pluginId, const QString &itemKey) const;
Q_INVOKABLE void openSystemSettings();
Q_INVOKABLE void openShutdownScreen();

QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
Expand Down
Loading