mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
add launcher item
Change-Id: I2ac8bde9bb84eac7bf14b1781d9bd1d4b0d5465b
This commit is contained in:
parent
e31ebda8db
commit
b9e4c3262c
@ -2,6 +2,7 @@
|
||||
#include "dbus/dbusdockentry.h"
|
||||
#include "item/appitem.h"
|
||||
#include "item/placeholderitem.h"
|
||||
#include "item/launcheritem.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -29,6 +30,7 @@ DockItemController::DockItemController(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_dockInter(new DBusDock(this))
|
||||
{
|
||||
m_itemList.append(new LauncherItem);
|
||||
for (auto entry : m_dockInter->entries())
|
||||
m_itemList.append(new AppItem(entry));
|
||||
m_itemList.append(new PlaceholderItem);
|
||||
|
@ -20,7 +20,8 @@ SOURCES += main.cpp \
|
||||
dbus/dbusclientmanager.cpp \
|
||||
dbus/dbusdock.cpp \
|
||||
dbus/dbusmenu.cpp \
|
||||
util/themeappicon.cpp
|
||||
util/themeappicon.cpp \
|
||||
item/launcheritem.cpp
|
||||
|
||||
HEADERS += \
|
||||
window/mainwindow.h \
|
||||
@ -36,4 +37,5 @@ HEADERS += \
|
||||
dbus/dbusclientmanager.h \
|
||||
dbus/dbusdock.h \
|
||||
dbus/dbusmenu.h \
|
||||
util/themeappicon.h
|
||||
util/themeappicon.h \
|
||||
item/launcheritem.h
|
||||
|
41
item/launcheritem.cpp
Normal file
41
item/launcheritem.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "launcheritem.h"
|
||||
#include "util/themeappicon.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QProcess>
|
||||
|
||||
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)
|
||||
{
|
||||
DockItem::mousePressEvent(e);
|
||||
|
||||
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);
|
||||
}
|
22
item/launcheritem.h
Normal file
22
item/launcheritem.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef LAUNCHERITEM_H
|
||||
#define LAUNCHERITEM_H
|
||||
|
||||
#include "dockitem.h"
|
||||
|
||||
class LauncherItem : public DockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LauncherItem(QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
QPixmap m_icon;
|
||||
};
|
||||
|
||||
#endif // LAUNCHERITEM_H
|
@ -71,6 +71,7 @@ void MainPanel::adjustItemSize()
|
||||
{
|
||||
switch (item->itemType())
|
||||
{
|
||||
case DockItem::Launcher:
|
||||
case DockItem::App: item->setFixedWidth(80); break;
|
||||
default:;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user