2016-06-03 16:06:11 +08:00
|
|
|
#include "appitem.h"
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
|
|
|
: DockItem(parent),
|
|
|
|
m_itemEntry(new DBusDockEntry(entry.path(), this))
|
|
|
|
{
|
2016-06-06 10:59:29 +08:00
|
|
|
qDebug() << m_itemEntry->data();
|
2016-06-03 16:06:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppItem::paintEvent(QPaintEvent *e)
|
|
|
|
{
|
|
|
|
DockItem::paintEvent(e);
|
|
|
|
|
2016-06-06 10:59:29 +08:00
|
|
|
const QRect itemRect = rect();
|
|
|
|
const int iconSize = std::min(itemRect.width(), itemRect.height());
|
|
|
|
|
|
|
|
QRect iconRect;
|
|
|
|
iconRect.setWidth(iconSize);
|
|
|
|
iconRect.setHeight(iconSize);
|
|
|
|
iconRect.moveTopLeft(itemRect.center() - iconRect.center());
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
QPainter painter(this);
|
|
|
|
painter.fillRect(rect(), Qt::cyan);
|
2016-06-06 10:59:29 +08:00
|
|
|
painter.fillRect(iconRect, Qt::yellow);
|
2016-06-03 16:06:11 +08:00
|
|
|
painter.drawText(rect(), m_itemEntry->id());
|
|
|
|
}
|