mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include "launcheritem.h"
|
|
#include "util/themeappicon.h"
|
|
|
|
#include <QPainter>
|
|
#include <QProcess>
|
|
#include <QMouseEvent>
|
|
|
|
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);
|
|
|
|
m_icon = ThemeAppIcon::getIcon("deepin-launcher", 48);
|
|
}
|
|
|
|
void LauncherItem::mousePressEvent(QMouseEvent *e)
|
|
{
|
|
if (e->button() != Qt::LeftButton)
|
|
return;
|
|
|
|
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);
|
|
}
|