mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
optimize ui effects
Change-Id: I71e9ccadad67b2deed61c4ce0b6271fa35499f3f
This commit is contained in:
parent
f15ddf008a
commit
8d63061963
@ -58,7 +58,7 @@ DockItemController::DockItemController(QObject *parent)
|
|||||||
m_pluginsInter(new DockPluginsController(this)),
|
m_pluginsInter(new DockPluginsController(this)),
|
||||||
m_placeholderItem(new PlaceholderItem)
|
m_placeholderItem(new PlaceholderItem)
|
||||||
{
|
{
|
||||||
m_placeholderItem->hide();
|
// m_placeholderItem->hide();
|
||||||
|
|
||||||
m_itemList.append(new LauncherItem);
|
m_itemList.append(new LauncherItem);
|
||||||
for (auto entry : m_appInter->entries())
|
for (auto entry : m_appInter->entries())
|
||||||
|
@ -20,7 +20,9 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
|||||||
initClientManager();
|
initClientManager();
|
||||||
|
|
||||||
m_id = m_itemEntry->id();
|
m_id = m_itemEntry->id();
|
||||||
|
m_active = m_itemEntry->active();
|
||||||
|
|
||||||
|
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, &AppItem::activeChanged);
|
||||||
connect(m_itemEntry, &DBusDockEntry::TitlesChanged, this, &AppItem::updateTitle);
|
connect(m_itemEntry, &DBusDockEntry::TitlesChanged, this, &AppItem::updateTitle);
|
||||||
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, static_cast<void (AppItem::*)()>(&AppItem::update));
|
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, static_cast<void (AppItem::*)()>(&AppItem::update));
|
||||||
|
|
||||||
@ -45,7 +47,10 @@ int AppItem::iconBaseSize()
|
|||||||
|
|
||||||
int AppItem::itemBaseWidth()
|
int AppItem::itemBaseWidth()
|
||||||
{
|
{
|
||||||
return itemBaseHeight() * 1.4;
|
if (DockDisplayMode == Dock::Fashion)
|
||||||
|
return itemBaseHeight() * 1.1;
|
||||||
|
else
|
||||||
|
return itemBaseHeight() * 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AppItem::itemBaseHeight()
|
int AppItem::itemBaseHeight()
|
||||||
@ -57,7 +62,7 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
{
|
{
|
||||||
DockItem::paintEvent(e);
|
DockItem::paintEvent(e);
|
||||||
|
|
||||||
if (m_draging || !m_itemEntry->isValid())
|
if (m_draging)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
@ -68,29 +73,69 @@ void AppItem::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
const QRect backgroundRect = itemRect.marginsRemoved(QMargins(1, 2, 1, 2));
|
const QRect backgroundRect = itemRect.marginsRemoved(QMargins(1, 2, 1, 2));
|
||||||
if (m_itemEntry->active())
|
if (DockDisplayMode == Efficient)
|
||||||
{
|
{
|
||||||
painter.fillRect(backgroundRect, QColor(70, 100, 200, 120));
|
if (m_active)
|
||||||
|
|
||||||
const int activeLineWidth = 3;
|
|
||||||
QRect activeRect = backgroundRect;
|
|
||||||
switch (DockPosition)
|
|
||||||
{
|
{
|
||||||
case Top: activeRect.setBottom(activeRect.top() + activeLineWidth); break;
|
painter.fillRect(backgroundRect, QColor(70, 100, 200, 120));
|
||||||
case Bottom: activeRect.setTop(activeRect.bottom() - activeLineWidth); break;
|
|
||||||
case Left: activeRect.setRight(activeRect.left() + activeLineWidth); break;
|
|
||||||
case Right: activeRect.setLeft(activeRect.right() - activeLineWidth); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
painter.fillRect(activeRect, QColor(47, 168, 247));
|
const int activeLineWidth = 3;
|
||||||
|
QRect activeRect = backgroundRect;
|
||||||
|
switch (DockPosition)
|
||||||
|
{
|
||||||
|
case Top: activeRect.setBottom(activeRect.top() + activeLineWidth); break;
|
||||||
|
case Bottom: activeRect.setTop(activeRect.bottom() - activeLineWidth); break;
|
||||||
|
case Left: activeRect.setRight(activeRect.left() + activeLineWidth); break;
|
||||||
|
case Right: activeRect.setLeft(activeRect.right() - activeLineWidth); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
painter.fillRect(activeRect, QColor(47, 168, 247));
|
||||||
|
}
|
||||||
|
else if (!m_titles.isEmpty())
|
||||||
|
painter.fillRect(backgroundRect, QColor(255, 255, 255, 50));
|
||||||
|
// else
|
||||||
|
// painter.fillRect(backgroundRect, Qt::gray);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!m_titles.isEmpty())
|
||||||
|
{
|
||||||
|
const int activeLineWidth = 1;
|
||||||
|
const int activeLineLength = 20;
|
||||||
|
QRect activeRect = itemRect;
|
||||||
|
switch (DockPosition)
|
||||||
|
{
|
||||||
|
case Top:
|
||||||
|
activeRect.setBottom(activeRect.top() + activeLineWidth);
|
||||||
|
activeRect.setWidth(activeLineLength);
|
||||||
|
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
||||||
|
break;
|
||||||
|
case Bottom:
|
||||||
|
activeRect.setTop(activeRect.bottom() - activeLineWidth);
|
||||||
|
activeRect.setWidth(activeLineLength);
|
||||||
|
activeRect.moveLeft((itemRect.width() - activeRect.width()) / 2);
|
||||||
|
break;
|
||||||
|
case Left:
|
||||||
|
activeRect.setRight(activeRect.left() + activeLineWidth);
|
||||||
|
activeRect.setHeight(activeLineLength);
|
||||||
|
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
||||||
|
break;
|
||||||
|
case Right:
|
||||||
|
activeRect.setLeft(activeRect.right() - activeLineWidth);
|
||||||
|
activeRect.setHeight(activeLineLength);
|
||||||
|
activeRect.moveTop((itemRect.height() - activeRect.height()) / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
painter.fillRect(activeRect, QColor(163, 167, 166));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!m_titles.isEmpty())
|
|
||||||
painter.fillRect(backgroundRect, QColor(255, 255, 255, 50));
|
|
||||||
// else
|
|
||||||
// painter.fillRect(backgroundRect, Qt::gray);
|
|
||||||
|
|
||||||
// draw icon
|
// draw icon
|
||||||
painter.drawPixmap(itemRect.center() - m_icon.rect().center(), m_icon);
|
if (DockDisplayMode == Efficient)
|
||||||
|
painter.drawPixmap(itemRect.center() - m_smallIcon.rect().center(), m_smallIcon);
|
||||||
|
else
|
||||||
|
painter.drawPixmap(itemRect.center() - m_largeIcon.rect().center(), m_largeIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
||||||
@ -195,7 +240,13 @@ void AppItem::updateTitle()
|
|||||||
void AppItem::updateIcon()
|
void AppItem::updateIcon()
|
||||||
{
|
{
|
||||||
const QString icon = m_itemEntry->icon();
|
const QString icon = m_itemEntry->icon();
|
||||||
const int iconSize = qMin(width(), height()) * 0.7;
|
const int iconSize = qMin(width(), height());
|
||||||
|
|
||||||
m_icon = ThemeAppIcon::getIcon(icon, iconSize);
|
m_smallIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.6);
|
||||||
|
m_largeIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppItem::activeChanged()
|
||||||
|
{
|
||||||
|
m_active = !m_active;
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,18 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
void updateIcon();
|
void updateIcon();
|
||||||
|
void activeChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DBusDockEntry *m_itemEntry;
|
DBusDockEntry *m_itemEntry;
|
||||||
|
|
||||||
bool m_draging;
|
bool m_draging;
|
||||||
|
|
||||||
|
bool m_active;
|
||||||
WindowDict m_titles;
|
WindowDict m_titles;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QPixmap m_icon;
|
QPixmap m_smallIcon;
|
||||||
|
QPixmap m_largeIcon;
|
||||||
|
|
||||||
static int IconBaseSize;
|
static int IconBaseSize;
|
||||||
static QPoint MousePressPos;
|
static QPoint MousePressPos;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
Position DockItem::DockPosition = Position::Top;
|
Position DockItem::DockPosition = Position::Top;
|
||||||
|
DisplayMode DockItem::DockDisplayMode = DisplayMode::Efficient;
|
||||||
|
|
||||||
DockItem::DockItem(const ItemType type, QWidget *parent)
|
DockItem::DockItem(const ItemType type, QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
@ -21,6 +22,11 @@ void DockItem::setDockPosition(const Position side)
|
|||||||
DockPosition = side;
|
DockPosition = side;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockItem::setDockDisplayMode(const DisplayMode mode)
|
||||||
|
{
|
||||||
|
DockDisplayMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
DockItem::ItemType DockItem::itemType() const
|
DockItem::ItemType DockItem::itemType() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
explicit DockItem(const ItemType type, QWidget *parent = nullptr);
|
explicit DockItem(const ItemType type, QWidget *parent = nullptr);
|
||||||
static void setDockPosition(const Position side);
|
static void setDockPosition(const Position side);
|
||||||
|
static void setDockDisplayMode(const DisplayMode mode);
|
||||||
|
|
||||||
ItemType itemType() const;
|
ItemType itemType() const;
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ protected:
|
|||||||
DBusMenuManager *m_menuManagerInter;
|
DBusMenuManager *m_menuManagerInter;
|
||||||
|
|
||||||
static Position DockPosition;
|
static Position DockPosition;
|
||||||
|
static DisplayMode DockDisplayMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOCKITEM_H
|
#endif // DOCKITEM_H
|
||||||
|
@ -18,14 +18,19 @@ void LauncherItem::paintEvent(QPaintEvent *e)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.drawPixmap(rect().center() - m_icon.rect().center(), m_icon);
|
if (DockDisplayMode == Fashion)
|
||||||
|
painter.drawPixmap(rect().center() - m_largeIcon.rect().center(), m_largeIcon);
|
||||||
|
else
|
||||||
|
painter.drawPixmap(rect().center() - m_smallIcon.rect().center(), m_smallIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItem::resizeEvent(QResizeEvent *e)
|
void LauncherItem::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
DockItem::resizeEvent(e);
|
DockItem::resizeEvent(e);
|
||||||
|
|
||||||
m_icon = ThemeAppIcon::getIcon("deepin-launcher", qMin(width(), height()) * 0.7);
|
const int iconSize = qMin(width(), height());
|
||||||
|
m_smallIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.6);
|
||||||
|
m_largeIcon = ThemeAppIcon::getIcon("deepin-launcher", iconSize * 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherItem::mousePressEvent(QMouseEvent *e)
|
void LauncherItem::mousePressEvent(QMouseEvent *e)
|
||||||
|
@ -16,7 +16,8 @@ private:
|
|||||||
void mousePressEvent(QMouseEvent *e);
|
void mousePressEvent(QMouseEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap m_icon;
|
QPixmap m_smallIcon;
|
||||||
|
QPixmap m_largeIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCHERITEM_H
|
#endif // LAUNCHERITEM_H
|
||||||
|
@ -63,12 +63,12 @@ void MainPanel::updateDockDisplayMode(const DisplayMode displayMode)
|
|||||||
{
|
{
|
||||||
m_displayMode = displayMode;
|
m_displayMode = displayMode;
|
||||||
|
|
||||||
const QList<DockItem *> itemList = m_itemController->itemList();
|
// const QList<DockItem *> itemList = m_itemController->itemList();
|
||||||
for (auto item : itemList)
|
// for (auto item : itemList)
|
||||||
{
|
// {
|
||||||
if (item->itemType() == DockItem::Placeholder)
|
// if (item->itemType() == DockItem::Placeholder)
|
||||||
item->setVisible(displayMode == Dock::Efficient);
|
// item->setVisible(displayMode == Dock::Efficient);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanel::resizeEvent(QResizeEvent *e)
|
void MainPanel::resizeEvent(QResizeEvent *e)
|
||||||
|
@ -34,6 +34,7 @@ DockSettings::DockSettings(QObject *parent)
|
|||||||
m_iconSize = m_dockInter->iconSize();
|
m_iconSize = m_dockInter->iconSize();
|
||||||
AppItem::setIconBaseSize(m_iconSize);
|
AppItem::setIconBaseSize(m_iconSize);
|
||||||
DockItem::setDockPosition(m_position);
|
DockItem::setDockPosition(m_position);
|
||||||
|
DockItem::setDockDisplayMode(m_displayMode);
|
||||||
|
|
||||||
m_fashionModeAct.setCheckable(true);
|
m_fashionModeAct.setCheckable(true);
|
||||||
m_efficientModeAct.setCheckable(true);
|
m_efficientModeAct.setCheckable(true);
|
||||||
@ -196,6 +197,7 @@ void DockSettings::iconSizeChanged()
|
|||||||
void DockSettings::displayModeChanged()
|
void DockSettings::displayModeChanged()
|
||||||
{
|
{
|
||||||
m_displayMode = Dock::DisplayMode(m_dockInter->displayMode());
|
m_displayMode = Dock::DisplayMode(m_dockInter->displayMode());
|
||||||
|
DockItem::setDockDisplayMode(m_displayMode);
|
||||||
|
|
||||||
calculateWindowConfig();
|
calculateWindowConfig();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user