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
13 changes: 2 additions & 11 deletions plugins/dde-dock/airplane-mode/airplanemodeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

#include "airplanemodeitem.h"
#include "airplanemodecontroller.h"
#include "constants.h"

Check warning on line 7 in plugins/dde-dock/airplane-mode/airplanemodeitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.
#include "tipswidget.h"

Check warning on line 8 in plugins/dde-dock/airplane-mode/airplanemodeitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "tipswidget.h" not found.

#include "xdgactivation.h"

#include <DGuiApplicationHelper>

Check warning on line 11 in plugins/dde-dock/airplane-mode/airplanemodeitem.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.

#include <QDBusConnection>
#include <QIcon>
Expand Down Expand Up @@ -119,16 +118,8 @@
if (menuId == SHIFT) {
AMC_PTR->toggle();
} else if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "network/airplaneMode";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "network/airplaneMode"};
QProcess::startDetached("dde-am", args);

Q_EMIT requestHideApplet();
}
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/bluetooth/bluetoothitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
#include "imageutil.h"
#include "tipswidget.h"
#include "componments/bluetoothapplet.h"
#include "constants.h"

Check warning on line 10 in plugins/dde-dock/bluetooth/bluetoothitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.
#include "quickpanelwidget.h"

#include "xdgactivation.h"

#include <DApplication>

Check warning on line 14 in plugins/dde-dock/bluetooth/bluetoothitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 15 in plugins/dde-dock/bluetooth/bluetoothitem.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.

#include <QPainter>
#include <QProcess>
Expand Down Expand Up @@ -128,16 +127,8 @@
}
m_applet->setAdapterPowered(!m_adapterPowered);
} else if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "device/bluetooth";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "device/bluetooth"};
QProcess::startDetached("dde-am", args);
Q_EMIT requestHideApplet();
}
}
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/brightness/brightnessitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "brightnessitem.h"
#include "constants.h"

Check warning on line 6 in plugins/dde-dock/brightness/brightnessitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.
#include "brightnessmodel.h"

#include "xdgactivation.h"

#include <DFontSizeManager>

Check warning on line 10 in plugins/dde-dock/brightness/brightnessitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in plugins/dde-dock/brightness/brightnessitem.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.

#include <QDBusConnection>
#include <QIcon>
Expand Down Expand Up @@ -81,16 +80,8 @@
Q_UNUSED(checked);

if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "display";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "display"};
QProcess::startDetached("dde-am", args);

Q_EMIT requestHideApplet();
}
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/datetime/datetimeplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#include "datetimeplugin.h"
#include "utils.h"
#include "plugins-logging-category.h"

Check warning on line 7 in plugins/dde-dock/datetime/datetimeplugin.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "plugins-logging-category.h" not found.
#include "regionFormat.h"

#include "xdgactivation.h"

#include <DConfig>
#include <DDBusSender>
Expand Down Expand Up @@ -216,16 +215,8 @@
Q_UNUSED(checked)

if (menuId == "open") {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "datetime";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "datetime"};
QProcess::startDetached("dde-am", args);
} else if (menuId == "settings") {
const bool is24HourFormat = m_centralWidget->is24HourFormat();
m_centralWidget->set24HourFormat(!is24HourFormat);
Expand Down
14 changes: 2 additions & 12 deletions plugins/dde-dock/dnd-mode/dndmodeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "dndmodecontroller.h"
#include "tipswidget.h"

#include "xdgactivation.h"

#include <DGuiApplicationHelper>

#include <QDBusConnection>
Expand Down Expand Up @@ -112,16 +110,8 @@ void DndModeItem::invokeMenuItem(const QString menuId, const bool checked)
if (menuId == SHIFT) {
DndModeController::ref().toggle();
} else if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "notification";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "notification"};
QProcess::startDetached("dde-am", args);

Q_EMIT requestHideApplet();
}
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/eye-comfort-mode/eyecomfortmodeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "tipswidget.h"
#include "quickpanelwidget.h"

#include "xdgactivation.h"

#include <DGuiApplicationHelper>

Expand Down Expand Up @@ -187,16 +186,8 @@ void EyeComfortModeItem::invokeMenuItem(const QString menuId, const bool checked
if (menuId == SHIFT) {
EyeComfortModeController::ref().toggle();
} else if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "display";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "display"};
QProcess::startDetached("dde-am", args);
Q_EMIT requestHideApplet();
}
}
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/keyboard-layout/dbusadaptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "fcitxinputmethoditem.h"
#include "plugins-logging-category.h"

#include "xdgactivation.h"

#include <DSysInfo>

Expand Down Expand Up @@ -177,16 +176,8 @@ void DBusAdaptors::refreshMenuSelection()
void DBusAdaptors::handleActionTriggered(QAction *action)
{
if (action == m_addLayoutAction) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "keyboard/Keyboard Layout/Add Keyboard Layout";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "keyboard/Keyboard Layout/Add Keyboard Layout"};
QProcess::startDetached("dde-am", args);
}

const QString layout = action->objectName();
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/notification/notificationplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "notificationplugin.h"

#include "xdgactivation.h"

#include <DGuiApplicationHelper>

Expand Down Expand Up @@ -134,16 +133,8 @@ void NotificationPlugin::invokedMenuItem(const QString &itemKey, const QString &
if (menuId == TOGGLE_DND) {
m_notification->setDndMode(!m_notification->dndMode());
} else if (menuId == NOTIFICATION_SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "notification";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "notification"};
QProcess::startDetached("dde-am", args);
}
}

Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/power/powerplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "dbus/dbusaccount.h"
#include "plugins-logging-category.h"

#include "xdgactivation.h"

#include <DConfig>

Expand Down Expand Up @@ -143,16 +142,8 @@ void PowerPlugin::invokedMenuItem(const QString &itemKey, const QString &menuId,
Q_UNUSED(checked)

if (menuId == "power") {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "power";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "power"};
QProcess::startDetached("dde-am", args);
}
}

Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/shutdown/shutdownplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "./dbus/org_deepin_dde_sessionmanager.h"
#include "plugins-logging-category.h"

#include "xdgactivation.h"

#include <DSysInfo>
#include <DDBusSender>
Expand Down Expand Up @@ -309,16 +308,8 @@ void ShutdownPlugin::invokedMenuItem(const QString &itemKey, const QString &menu
QCoreApplication::processEvents(QEventLoop::AllEvents, 200);

if (menuId == "power") {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "power";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "power"};
QProcess::startDetached("dde-am", args);
} else if (menuId == "Lock") {
if (QFile::exists(ICBC_CONF_FILE)) {
QDBusMessage send = QDBusMessage::createMethodCall("org.deepin.dde.LockFront1", "/org/deepin/dde/LockFront1", "org.deepin.dde.LockFront1", "SwitchTTYAndShow");
Expand Down
13 changes: 2 additions & 11 deletions plugins/dde-dock/sound/soundview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "utils.h"
#include "soundmodel.h"

#include "xdgactivation.h"

#include <DApplication>
#include <DGuiApplicationHelper>
Expand Down Expand Up @@ -108,16 +107,8 @@ void SoundView::invokeMenuItem(const QString menuId, const bool checked)
if (menuId == MUTE) {
SoundController::ref().SetMuteQueued(!SoundModel::ref().isMute());
} else if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "sound";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "sound"};
QProcess::startDetached("dde-am", args);
Q_EMIT requestHideApplet();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <constants.h>

#include "xdgactivation.h"

#include <DGuiApplicationHelper>

Expand Down Expand Up @@ -221,16 +220,8 @@ void WirelessCastingItem::invokeMenuItem(const QString menuId, const bool checke
{
Q_UNUSED(checked);
if (menuId == SETTINGS) {
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation](const QString &token) {
QStringList args {"--by-user", "org.deepin.dde.control-center"};
if (!token.isEmpty())
args << "-e" << "XDG_ACTIVATION_TOKEN=" + token;
args << "--" << "-p" << "display";
QProcess::startDetached("dde-am", args);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
QStringList args {"--by-user", "org.deepin.dde.control-center", "--", "-p", "display"};
QProcess::startDetached("dde-am", args);

Q_EMIT requestHideApplet();
}
Expand Down
29 changes: 27 additions & 2 deletions src/loader/pluginitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
#include "widgetplugin.h"
#include "dockcontextmenu.h"

#include <xdgactivation.h>

#include <QHBoxLayout>
#include <QMouseEvent>
#include <QMenu>
#include <QPainter>
#include <QProcess>
#include <QProcessEnvironment>

const static QString DockQuickPlugins = "Dock_Quick_Plugins";

Expand Down Expand Up @@ -39,7 +43,18 @@ PluginItem::PluginItem(PluginsItemInterface *pluginItemInterface, const QString
if (actionStr == Dock::dockMenuItemId || actionStr == Dock::unDockMenuItemId) {
m_dbusProxy->setItemOnDock(DockQuickPlugins, m_itemKey, actionStr == Dock::dockMenuItemId);
} else {
m_pluginsItemInterface->invokedMenuItem(m_itemKey, action->data().toString(), action->isCheckable() ? action->isChecked() : true);
const QString menuId = action->data().toString();
const bool checked = action->isCheckable() ? action->isChecked() : true;
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [this, activation, menuId, checked](const QString &token) {
if (!token.isEmpty())
qputenv("XDG_ACTIVATION_TOKEN", token.toUtf8());
m_pluginsItemInterface->invokedMenuItem(m_itemKey, menuId, checked);
if (!token.isEmpty())
qunsetenv("XDG_ACTIVATION_TOKEN");
activation->deleteLater();
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
}, Qt::SingleShotConnection);
activation->requestToken();
}
});
}
Expand Down Expand Up @@ -372,7 +387,17 @@ bool PluginItem::executeCommand()
QStringList commandList = command.split(" ");
QString program = commandList.takeFirst(); // 剩下是参数

QProcess::startDetached(program, commandList);
auto *activation = new tray::XdgActivation(this);
connect(activation, &tray::XdgActivation::tokenReady, this, [activation, program, commandList](const QString &token) {
QProcess process;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (!token.isEmpty())
env.insert("XDG_ACTIVATION_TOKEN", token);
process.setProcessEnvironment(env);
process.startDetached(program, commandList);
activation->deleteLater();
}, Qt::SingleShotConnection);
activation->requestToken();
return true;
}
return false;
Expand Down
Loading