add click command

Change-Id: Ie22375f7bb0a88c657a7a74ad30758dec9e3e59d
This commit is contained in:
石博文 2016-06-27 11:04:29 +08:00 committed by Hualet Wang
parent e53b4577bd
commit 464057344c
4 changed files with 18 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;