mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
optimize indicator
Change-Id: I3e4c6e872390583f9a07375f06404a15ca5388f6
This commit is contained in:
parent
4fb2b161fc
commit
33f60adc58
@ -57,3 +57,6 @@ dbus_service.path = /usr/share/dbus-1/services
|
||||
|
||||
target.path = $${PREFIX}/bin/
|
||||
INSTALLS += target dbus_service
|
||||
|
||||
RESOURCES += \
|
||||
item/resources.qrc
|
||||
|
@ -15,7 +15,11 @@ QPoint AppItem::MousePressPos;
|
||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
: DockItem(App, parent),
|
||||
m_itemEntry(new DBusDockEntry(entry.path(), this)),
|
||||
m_draging(false)
|
||||
m_draging(false),
|
||||
m_horizontalIndicator(QPixmap(":/indicator/resources/indicator.png")),
|
||||
m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
|
||||
m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
|
||||
m_activeVerticalIndicator(QPixmap(":/indicator/resources/indicator_active_ver.png"))
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
|
||||
@ -116,38 +120,74 @@ void AppItem::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
if (!m_titles.isEmpty())
|
||||
{
|
||||
const int activeLineWidth = 2;
|
||||
const int activeLineLength = 20;
|
||||
QRect activeRect = itemRect;
|
||||
QPoint p;
|
||||
QPixmap pixmap;
|
||||
QPixmap activePixmap;
|
||||
switch (DockPosition)
|
||||
{
|
||||
case Top:
|
||||
activeRect.setBottom(activeRect.top() + activeLineWidth);
|
||||
activeRect.moveBottom(activeRect.bottom() + 1);
|
||||
activeRect.setWidth(activeLineLength);
|
||||
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
||||
pixmap = m_horizontalIndicator;
|
||||
activePixmap = m_activeHorizontalIndicator;
|
||||
p.setX((itemRect.width() - pixmap.width()) / 2);
|
||||
p.setY(1);
|
||||
break;
|
||||
case Bottom:
|
||||
activeRect.setTop(activeRect.bottom() - activeLineWidth);
|
||||
activeRect.moveTop(activeRect.top() - 1);
|
||||
activeRect.setWidth(activeLineLength);
|
||||
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
||||
pixmap = m_horizontalIndicator;
|
||||
activePixmap = m_activeHorizontalIndicator;
|
||||
p.setX((itemRect.width() - pixmap.width()) / 2);
|
||||
p.setY(itemRect.height() - pixmap.height() - 1);
|
||||
break;
|
||||
case Left:
|
||||
activeRect.setRight(activeRect.left() + activeLineWidth);
|
||||
activeRect.moveRight(activeRect.right() + 1);
|
||||
activeRect.setHeight(activeLineLength);
|
||||
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
||||
pixmap = m_verticalIndicator;
|
||||
activePixmap = m_activeVerticalIndicator;
|
||||
p.setX(1);
|
||||
p.setY((itemRect.height() - pixmap.height()) / 2);
|
||||
break;
|
||||
case Right:
|
||||
activeRect.setLeft(activeRect.right() - activeLineWidth);
|
||||
activeRect.moveLeft(activeRect.left() - 1);
|
||||
activeRect.setHeight(activeLineLength);
|
||||
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
||||
pixmap = m_verticalIndicator;
|
||||
activePixmap = m_activeVerticalIndicator;
|
||||
p.setX(itemRect.width() - pixmap.width() - 1);
|
||||
p.setY((itemRect.height() - pixmap.height()) / 2);
|
||||
break;
|
||||
}
|
||||
|
||||
painter.fillRect(activeRect, QColor(163, 167, 166));
|
||||
if (m_active)
|
||||
painter.drawPixmap(p, activePixmap);
|
||||
else
|
||||
painter.drawPixmap(p, pixmap);
|
||||
|
||||
// const int activeLineWidth = 2;
|
||||
// const int activeLineLength = 20;
|
||||
// QRect activeRect = itemRect;
|
||||
// switch (DockPosition)
|
||||
// {
|
||||
// case Top:
|
||||
// activeRect.setBottom(activeRect.top() + activeLineWidth);
|
||||
// activeRect.moveBottom(activeRect.bottom() + 1);
|
||||
// activeRect.setWidth(activeLineLength);
|
||||
// activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
||||
// break;
|
||||
// case Bottom:
|
||||
// activeRect.setTop(activeRect.bottom() - activeLineWidth);
|
||||
// activeRect.moveTop(activeRect.top() - 1);
|
||||
// activeRect.setWidth(activeLineLength);
|
||||
// activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
||||
// break;
|
||||
// case Left:
|
||||
// activeRect.setRight(activeRect.left() + activeLineWidth);
|
||||
// activeRect.moveRight(activeRect.right() + 1);
|
||||
// activeRect.setHeight(activeLineLength);
|
||||
// activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
||||
// break;
|
||||
// case Right:
|
||||
// activeRect.setLeft(activeRect.right() - activeLineWidth);
|
||||
// activeRect.moveLeft(activeRect.left() - 1);
|
||||
// activeRect.setHeight(activeLineLength);
|
||||
// activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
||||
// break;
|
||||
// }
|
||||
|
||||
// painter.fillRect(activeRect, QColor(163, 167, 166));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,10 @@ private:
|
||||
QString m_id;
|
||||
QPixmap m_smallIcon;
|
||||
QPixmap m_largeIcon;
|
||||
QPixmap m_horizontalIndicator;
|
||||
QPixmap m_verticalIndicator;
|
||||
QPixmap m_activeHorizontalIndicator;
|
||||
QPixmap m_activeVerticalIndicator;
|
||||
|
||||
static int IconBaseSize;
|
||||
static QPoint MousePressPos;
|
||||
|
8
frame/item/resources.qrc
Normal file
8
frame/item/resources.qrc
Normal file
@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/indicator">
|
||||
<file>resources/indicator_active.png</file>
|
||||
<file>resources/indicator.png</file>
|
||||
<file>resources/indicator_ver.png</file>
|
||||
<file>resources/indicator_active_ver.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
frame/item/resources/indicator.png
Normal file
BIN
frame/item/resources/indicator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 136 B |
BIN
frame/item/resources/indicator_active.png
Normal file
BIN
frame/item/resources/indicator_active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 B |
BIN
frame/item/resources/indicator_active_ver.png
Normal file
BIN
frame/item/resources/indicator_active_ver.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 B |
BIN
frame/item/resources/indicator_ver.png
Normal file
BIN
frame/item/resources/indicator_ver.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 B |
Loading…
x
Reference in New Issue
Block a user