2016-06-14 16:49:29 +08:00
|
|
|
#include "launcheritem.h"
|
|
|
|
#include "util/themeappicon.h"
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QProcess>
|
2016-06-15 16:17:51 +08:00
|
|
|
#include <QMouseEvent>
|
2016-06-14 16:49:29 +08:00
|
|
|
|
|
|
|
LauncherItem::LauncherItem(QWidget *parent)
|
|
|
|
: DockItem(DockItem::Launcher, parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherItem::paintEvent(QPaintEvent *e)
|
|
|
|
{
|
|
|
|
DockItem::paintEvent(e);
|
|
|
|
|
|
|
|
QPainter painter(this);
|
|
|
|
painter.drawPixmap(rect().center() - m_icon.rect().center(), m_icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherItem::resizeEvent(QResizeEvent *e)
|
|
|
|
{
|
|
|
|
DockItem::resizeEvent(e);
|
|
|
|
|
2016-06-21 19:25:30 +08:00
|
|
|
m_icon = ThemeAppIcon::getIcon("deepin-launcher", qMin(width(), height()) * 0.7);
|
2016-06-14 16:49:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherItem::mousePressEvent(QMouseEvent *e)
|
|
|
|
{
|
2016-06-22 11:02:52 +08:00
|
|
|
if (e->button() == Qt::RightButton && !perfectIconRect().contains(e->pos()))
|
|
|
|
return QWidget::mousePressEvent(e);
|
|
|
|
|
2016-06-15 16:17:51 +08:00
|
|
|
if (e->button() != Qt::LeftButton)
|
|
|
|
return;
|
2016-06-14 16:49:29 +08:00
|
|
|
|
|
|
|
QProcess *proc = new QProcess;
|
|
|
|
|
|
|
|
connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), proc, &QProcess::deleteLater);
|
|
|
|
|
|
|
|
QStringList args = QStringList() << "--print-reply"
|
|
|
|
<< "--dest=com.deepin.dde.Launcher"
|
|
|
|
<< "/com/deepin/dde/Launcher"
|
|
|
|
<< "com.deepin.dde.Launcher.Toggle";
|
|
|
|
|
|
|
|
proc->start("dbus-send", args);
|
|
|
|
}
|