mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +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/
|
target.path = $${PREFIX}/bin/
|
||||||
INSTALLS += target dbus_service
|
INSTALLS += target dbus_service
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
item/resources.qrc
|
||||||
|
@ -15,7 +15,11 @@ QPoint AppItem::MousePressPos;
|
|||||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||||
: DockItem(App, parent),
|
: DockItem(App, parent),
|
||||||
m_itemEntry(new DBusDockEntry(entry.path(), this)),
|
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);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
@ -116,38 +120,74 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
{
|
{
|
||||||
if (!m_titles.isEmpty())
|
if (!m_titles.isEmpty())
|
||||||
{
|
{
|
||||||
const int activeLineWidth = 2;
|
QPoint p;
|
||||||
const int activeLineLength = 20;
|
QPixmap pixmap;
|
||||||
QRect activeRect = itemRect;
|
QPixmap activePixmap;
|
||||||
switch (DockPosition)
|
switch (DockPosition)
|
||||||
{
|
{
|
||||||
case Top:
|
case Top:
|
||||||
activeRect.setBottom(activeRect.top() + activeLineWidth);
|
pixmap = m_horizontalIndicator;
|
||||||
activeRect.moveBottom(activeRect.bottom() + 1);
|
activePixmap = m_activeHorizontalIndicator;
|
||||||
activeRect.setWidth(activeLineLength);
|
p.setX((itemRect.width() - pixmap.width()) / 2);
|
||||||
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
p.setY(1);
|
||||||
break;
|
break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
activeRect.setTop(activeRect.bottom() - activeLineWidth);
|
pixmap = m_horizontalIndicator;
|
||||||
activeRect.moveTop(activeRect.top() - 1);
|
activePixmap = m_activeHorizontalIndicator;
|
||||||
activeRect.setWidth(activeLineLength);
|
p.setX((itemRect.width() - pixmap.width()) / 2);
|
||||||
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
p.setY(itemRect.height() - pixmap.height() - 1);
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
activeRect.setRight(activeRect.left() + activeLineWidth);
|
pixmap = m_verticalIndicator;
|
||||||
activeRect.moveRight(activeRect.right() + 1);
|
activePixmap = m_activeVerticalIndicator;
|
||||||
activeRect.setHeight(activeLineLength);
|
p.setX(1);
|
||||||
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
p.setY((itemRect.height() - pixmap.height()) / 2);
|
||||||
break;
|
break;
|
||||||
case Right:
|
case Right:
|
||||||
activeRect.setLeft(activeRect.right() - activeLineWidth);
|
pixmap = m_verticalIndicator;
|
||||||
activeRect.moveLeft(activeRect.left() - 1);
|
activePixmap = m_activeVerticalIndicator;
|
||||||
activeRect.setHeight(activeLineLength);
|
p.setX(itemRect.width() - pixmap.width() - 1);
|
||||||
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
p.setY((itemRect.height() - pixmap.height()) / 2);
|
||||||
break;
|
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;
|
QString m_id;
|
||||||
QPixmap m_smallIcon;
|
QPixmap m_smallIcon;
|
||||||
QPixmap m_largeIcon;
|
QPixmap m_largeIcon;
|
||||||
|
QPixmap m_horizontalIndicator;
|
||||||
|
QPixmap m_verticalIndicator;
|
||||||
|
QPixmap m_activeHorizontalIndicator;
|
||||||
|
QPixmap m_activeVerticalIndicator;
|
||||||
|
|
||||||
static int IconBaseSize;
|
static int IconBaseSize;
|
||||||
static QPoint MousePressPos;
|
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