mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Item add highlight effect finished
This commit is contained in:
parent
736ea569df
commit
879aa67eb3
@ -104,17 +104,6 @@ void Panel::changeDockMode(Dock::DockMode newMode, Dock::DockMode oldMode)
|
||||
{
|
||||
updateBackground();
|
||||
|
||||
if (dockCons->getDockMode() == Dock::FashionMode)
|
||||
{
|
||||
leftLayout->setVerticalAlignment(DockLayout::AlignTop);
|
||||
rightLayout->setVerticalAlignment(DockLayout::AlignTop);
|
||||
}
|
||||
else
|
||||
{
|
||||
leftLayout->setVerticalAlignment(DockLayout::AlignVCenter);
|
||||
rightLayout->setVerticalAlignment(DockLayout::AlignVCenter);
|
||||
}
|
||||
|
||||
leftLayout->relayout();
|
||||
rightLayout->relayout();
|
||||
|
||||
|
@ -156,17 +156,6 @@ void AppItem::initBackground()
|
||||
}
|
||||
}
|
||||
|
||||
void AppItem::initHighlight()
|
||||
{
|
||||
m_highlight = new HighlightEffect(m_appIcon, this);
|
||||
m_highlight->setFixedSize(this->size());
|
||||
m_highlight->move(m_appIcon->pos());
|
||||
connect(this, &AppItem::mouseEntered, m_highlight, &HighlightEffect::showLighter);
|
||||
connect(this, &AppItem::mouseExited, m_highlight, &HighlightEffect::showNormal);
|
||||
connect(this, &AppItem::mousePress, m_highlight, &HighlightEffect::showDarker);
|
||||
connect(this, &AppItem::mouseRelease, m_highlight, &HighlightEffect::showLighter);
|
||||
}
|
||||
|
||||
void AppItem::initClientManager()
|
||||
{
|
||||
m_clientmanager = new DBusClientManager(this);
|
||||
@ -227,8 +216,8 @@ void AppItem::updateTitle()
|
||||
return;
|
||||
case Dock::ClassicMode:
|
||||
m_appIcon->setVisible(true);
|
||||
m_appTitle->resize(width() - m_appIcon->width(),m_appIcon->height());
|
||||
m_appTitle->move(m_appIcon->x() + m_appIcon->width(),m_appIcon->y());
|
||||
m_appTitle->resize(m_isActived ? (width() - m_appIcon->width()) : 0,m_appIcon->height());
|
||||
m_appTitle->move(m_appIcon->x() + m_appIcon->width(), m_appIcon->y());
|
||||
m_appTitle->show();
|
||||
break;
|
||||
default:
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "appicon.h"
|
||||
#include "appbackground.h"
|
||||
#include "arrowrectangle.h"
|
||||
#include "highlighteffect.h"
|
||||
#include "../dockconstants.h"
|
||||
|
||||
struct AppItemData {
|
||||
@ -75,7 +74,6 @@ private slots:
|
||||
private:
|
||||
void resizeResources();
|
||||
void initBackground();
|
||||
void initHighlight();
|
||||
void initClientManager();
|
||||
void setActived(bool value);
|
||||
|
||||
@ -93,7 +91,6 @@ private:
|
||||
AppItemData m_itemData;
|
||||
DockModeData *dockCons = DockModeData::instance();
|
||||
AppBackground * appBackground = NULL;
|
||||
HighlightEffect * m_highlight = NULL;
|
||||
AppIcon * m_appIcon = NULL;
|
||||
QLabel * m_appTitle = NULL;
|
||||
|
||||
|
@ -9,6 +9,7 @@ HighlightEffect::HighlightEffect(QWidget * source, QWidget *parent) :
|
||||
m_source(source)
|
||||
{
|
||||
setFixedSize(m_source->size());
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +35,8 @@ void HighlightEffect::setDarker(int darker)
|
||||
|
||||
void HighlightEffect::showDarker()
|
||||
{
|
||||
setVisible(true);
|
||||
|
||||
m_effectState = ESDarker;
|
||||
|
||||
this->repaint();
|
||||
@ -41,6 +44,8 @@ void HighlightEffect::showDarker()
|
||||
|
||||
void HighlightEffect::showLighter()
|
||||
{
|
||||
setVisible(true);
|
||||
|
||||
m_effectState = ESLighter;
|
||||
|
||||
this->repaint();
|
||||
@ -48,6 +53,8 @@ void HighlightEffect::showLighter()
|
||||
|
||||
void HighlightEffect::showNormal()
|
||||
{
|
||||
setVisible(true);
|
||||
|
||||
m_effectState = ESNormal;
|
||||
|
||||
this->repaint();
|
||||
@ -65,9 +72,9 @@ void HighlightEffect::paintEvent(QPaintEvent *)
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
|
||||
if (m_effectState == ESLighter) {
|
||||
painter.fillRect(pixmap.rect(), QColor::fromRgbF(1, 1, 1, 0.3));
|
||||
painter.fillRect(pixmap.rect(), QColor::fromRgbF(1, 1, 1, 0.2));
|
||||
} else if (m_effectState == ESDarker) {
|
||||
painter.fillRect(pixmap.rect(), QColor::fromRgbF(0, 0, 0, 0.3));
|
||||
painter.fillRect(pixmap.rect(), QColor::fromRgbF(0, 0, 0, 0.2));
|
||||
}
|
||||
|
||||
painter.end();
|
||||
|
@ -16,21 +16,29 @@ LauncherItem::LauncherItem(QWidget *parent) : AbstractDockItem(parent)
|
||||
|
||||
void LauncherItem::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
emit mousePress(globalX(), globalY());
|
||||
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
void LauncherItem::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
emit mouseRelease(globalX(), globalY());
|
||||
|
||||
m_launcherProcess->start("dde-launcher",QStringList());
|
||||
}
|
||||
|
||||
void LauncherItem::enterEvent(QEvent *)
|
||||
{
|
||||
emit mouseEntered();
|
||||
|
||||
showPreview();
|
||||
}
|
||||
|
||||
void LauncherItem::leaveEvent(QEvent *)
|
||||
{
|
||||
emit mouseExited();
|
||||
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ AbstractDockItem::AbstractDockItem(QWidget * parent) :
|
||||
QFrame(parent)
|
||||
{
|
||||
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
AbstractDockItem::~AbstractDockItem()
|
||||
@ -44,12 +45,18 @@ bool AbstractDockItem::actived()
|
||||
void AbstractDockItem::resize(int width,int height){
|
||||
QFrame::resize(width,height);
|
||||
|
||||
if (m_highlight)
|
||||
m_highlight->setFixedSize(size());
|
||||
|
||||
emit widthChanged();
|
||||
}
|
||||
|
||||
void AbstractDockItem::resize(const QSize &size){
|
||||
QFrame::resize(size);
|
||||
|
||||
if (m_highlight)
|
||||
m_highlight->setFixedSize(size);
|
||||
|
||||
emit widthChanged();
|
||||
}
|
||||
|
||||
@ -68,6 +75,18 @@ void AbstractDockItem::setNextPos(int x, int y)
|
||||
m_itemNextPos.setX(x); m_itemNextPos.setY(y);
|
||||
}
|
||||
|
||||
void AbstractDockItem::move(const QPoint &value)
|
||||
{
|
||||
QWidget::move(value);
|
||||
m_highlight->move(pos());
|
||||
}
|
||||
|
||||
void AbstractDockItem::move(int x, int y)
|
||||
{
|
||||
QWidget::move(x,y);
|
||||
m_highlight->move(pos());
|
||||
}
|
||||
|
||||
int AbstractDockItem::globalX()
|
||||
{
|
||||
return mapToGlobal(QPoint(0,0)).x();
|
||||
@ -163,3 +182,39 @@ void AbstractDockItem::invokeMenuItem(QString, bool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AbstractDockItem::setParent(QWidget *parent)
|
||||
{
|
||||
QWidget::setParent(parent);
|
||||
initHighlight();
|
||||
}
|
||||
|
||||
void AbstractDockItem::initHighlight()
|
||||
{
|
||||
//the size and position will update with move() and resize()
|
||||
QWidget * lParent = qobject_cast<QWidget *>(parent());
|
||||
if (lParent)
|
||||
{
|
||||
if (!m_highlight)
|
||||
{
|
||||
m_highlight = new HighlightEffect(this, lParent);
|
||||
connect(this, &AbstractDockItem::dragStart, [=](){
|
||||
m_highlight->setVisible(false);
|
||||
});
|
||||
connect(this, &AbstractDockItem::mousePress, [=](){
|
||||
m_highlight->showDarker();
|
||||
});
|
||||
connect(this, &AbstractDockItem::mouseRelease, [=](){
|
||||
m_highlight->showLighter();
|
||||
});
|
||||
connect(this, &AbstractDockItem::mouseEntered, [=](){
|
||||
m_highlight->showLighter();
|
||||
});
|
||||
connect(this, &AbstractDockItem::mouseExited, [=](){
|
||||
m_highlight->showNormal();
|
||||
});
|
||||
}
|
||||
else
|
||||
m_highlight->setParent(lParent);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define ABSTRACTDOCKITEM_H
|
||||
|
||||
#include "Widgets/arrowrectangle.h"
|
||||
#include "Widgets/highlighteffect.h"
|
||||
#include <QDebug>
|
||||
|
||||
class DBusMenu;
|
||||
class DBusMenuManager;
|
||||
@ -24,6 +26,8 @@ public:
|
||||
QPoint getNextPos();
|
||||
void setNextPos(const QPoint &value);
|
||||
void setNextPos(int x, int y);
|
||||
void move(const QPoint &value);
|
||||
void move(int x, int y);
|
||||
|
||||
int globalX();
|
||||
int globalY();
|
||||
@ -38,6 +42,8 @@ public:
|
||||
virtual QString getMenuContent();
|
||||
virtual void invokeMenuItem(QString itemId, bool checked);
|
||||
|
||||
void setParent(QWidget * parent);
|
||||
|
||||
signals:
|
||||
void dragStart();
|
||||
void dragEntered(QDragEnterEvent * event);
|
||||
@ -55,11 +61,14 @@ protected:
|
||||
bool m_moveable = true;
|
||||
bool m_isActived = false;
|
||||
ArrowRectangle *m_previewAR = new ArrowRectangle();
|
||||
HighlightEffect * m_highlight = NULL;
|
||||
|
||||
QPoint m_itemNextPos;
|
||||
|
||||
DBusMenu * m_dbusMenu = NULL;
|
||||
DBusMenuManager * m_dbusMenuManager = NULL;
|
||||
|
||||
void initHighlight();
|
||||
};
|
||||
|
||||
#endif // ABSTRACTDOCKITEM_H
|
||||
|
@ -20,7 +20,7 @@ const int APP_PREVIEW_WIDTH = 160;
|
||||
const int APP_PREVIEW_HEIGHT = 100;
|
||||
const int APP_PREVIEW_MARGIN = 18 ;
|
||||
|
||||
const int APP_ITEM_FASHION_HEIGHT = 70;
|
||||
const int APP_ITEM_FASHION_HEIGHT = 48;
|
||||
const int APP_ITEM_FASHION_NORMAL_WIDTH = 48;
|
||||
const int APP_ITEM_FASHION_ACTIVE_WIDTH = 48;
|
||||
const int APP_ITEM_FASHION_SPACING = 3;
|
||||
@ -39,7 +39,7 @@ const int APP_ITEM_CLASSIC_SPACING = 4;
|
||||
const int APP_ITEM_CLASSIC_ICON_SIZE = 24;
|
||||
|
||||
//////////////// APpplet ////////////////////////////
|
||||
const int APPLET_FASHION_ITEM_HEIGHT = 70;
|
||||
const int APPLET_FASHION_ITEM_HEIGHT = 48;
|
||||
const int APPLET_FASHION_ITEM_WIDTH = 48;
|
||||
const int APPLET_FASHION_ITEM_SPACING = 3;
|
||||
const int APPLET_FASHION_ICON_SIZE = 48;
|
||||
|
Loading…
x
Reference in New Issue
Block a user