mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add click command
Change-Id: Ie22375f7bb0a88c657a7a74ad30758dec9e3e59d
This commit is contained in:
parent
e53b4577bd
commit
464057344c
@ -140,5 +140,13 @@ void PluginsItem::startDrag()
|
||||
|
||||
void PluginsItem::mouseClicked()
|
||||
{
|
||||
const QString command = m_pluginInter->itemCommand(m_itemKey);
|
||||
if (command.isEmpty())
|
||||
return;
|
||||
|
||||
QProcess *proc = new QProcess(this);
|
||||
|
||||
connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), proc, &QProcess::deleteLater);
|
||||
|
||||
proc->startDetached(command);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
virtual QWidget *itemWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
||||
// in simple icon mode, plugins need to implements some data source functions
|
||||
virtual const QIcon itemIcon(const QString &itemKey) {Q_UNUSED(itemKey); return QIcon();}
|
||||
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
||||
|
||||
protected:
|
||||
PluginProxyInterface *m_proxyInter;
|
||||
|
@ -33,6 +33,13 @@ const QIcon ShutdownPlugin::itemIcon(const QString &itemKey)
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
const QString ShutdownPlugin::itemCommand(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
return QString("dbus-send --print-reply --dest=com.deepin.dde.shutdownFront /com/deepin/dde/shutdownFront com.deepin.dde.shutdownFront.Show");
|
||||
}
|
||||
|
||||
int ShutdownPlugin::itemSortKey(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
@ -14,11 +14,12 @@ public:
|
||||
|
||||
const QString pluginName();
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
int itemSortKey(const QString &itemKey);
|
||||
|
||||
PluginType pluginType(const QString &itemKey);
|
||||
|
||||
const QIcon itemIcon(const QString &itemKey);
|
||||
int itemSortKey(const QString &itemKey);
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
|
||||
private:
|
||||
QIcon m_icon;
|
||||
|
Loading…
x
Reference in New Issue
Block a user