mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix hidpi painter offset error
Change-Id: Iab995625e8a691501992f9c011dfc7c4165ce8b1
This commit is contained in:
parent
d4dc910d0a
commit
d2aeb844fa
Notes:
Deepin Code Review
2018-01-24 11:24:59 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Wed, 24 Jan 2018 11:24:59 +0800 Reviewed-on: https://cr.deepin.io/30999 Project: dde/dde-dock Branch: refs/heads/master
@ -6,6 +6,8 @@
|
||||
|
||||
HoverHighlightEffect::HoverHighlightEffect(QObject *parent)
|
||||
: QGraphicsEffect(parent)
|
||||
|
||||
, m_highlighting(false)
|
||||
{
|
||||
|
||||
}
|
||||
@ -14,7 +16,7 @@ void HoverHighlightEffect::draw(QPainter *painter)
|
||||
{
|
||||
const QPixmap pix = sourcePixmap(Qt::DeviceCoordinates);
|
||||
|
||||
if (isEnabled())
|
||||
if (m_highlighting)
|
||||
{
|
||||
painter->drawPixmap(0, 0, ImageFactory::lighterEffect(pix));
|
||||
} else {
|
||||
|
@ -10,8 +10,13 @@ class HoverHighlightEffect : public QGraphicsEffect
|
||||
public:
|
||||
explicit HoverHighlightEffect(QObject *parent = nullptr);
|
||||
|
||||
void setHighlighting(const bool highlighting) { m_highlighting = highlighting; }
|
||||
|
||||
protected:
|
||||
void draw(QPainter *painter);
|
||||
|
||||
private:
|
||||
bool m_highlighting;
|
||||
};
|
||||
|
||||
#endif // HOVERHIGHLIGHTEFFECT_H
|
||||
|
@ -36,6 +36,8 @@ DockItem::DockItem(QWidget *parent)
|
||||
m_hover(false),
|
||||
m_popupShown(false),
|
||||
|
||||
m_hoverEffect(new HoverHighlightEffect(this)),
|
||||
|
||||
m_popupTipsDelayTimer(new QTimer(this)),
|
||||
m_popupAdjustDelayTimer(new QTimer(this)),
|
||||
|
||||
@ -59,8 +61,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
m_popupAdjustDelayTimer->setInterval(100);
|
||||
m_popupAdjustDelayTimer->setSingleShot(true);
|
||||
|
||||
setGraphicsEffect(new HoverHighlightEffect(this));
|
||||
graphicsEffect()->setEnabled(false);
|
||||
setGraphicsEffect(m_hoverEffect);
|
||||
|
||||
connect(m_popupTipsDelayTimer, &QTimer::timeout, this, &DockItem::showHoverTips);
|
||||
connect(m_popupAdjustDelayTimer, &QTimer::timeout, this, &DockItem::updatePopupPosition);
|
||||
@ -117,8 +118,8 @@ void DockItem::mousePressEvent(QMouseEvent *e)
|
||||
void DockItem::enterEvent(QEvent *e)
|
||||
{
|
||||
m_hover = true;
|
||||
m_hoverEffect->setHighlighting(true);
|
||||
m_popupTipsDelayTimer->start();
|
||||
graphicsEffect()->setEnabled(true);
|
||||
|
||||
update();
|
||||
|
||||
@ -130,8 +131,8 @@ void DockItem::leaveEvent(QEvent *e)
|
||||
QWidget::leaveEvent(e);
|
||||
|
||||
m_hover = false;
|
||||
m_hoverEffect->setHighlighting(false);
|
||||
m_popupTipsDelayTimer->stop();
|
||||
graphicsEffect()->setEnabled(false);
|
||||
|
||||
// auto hide if popup is not model window
|
||||
if (m_popupShown && !PopupWindow->model())
|
||||
|
@ -24,8 +24,10 @@
|
||||
|
||||
#include "constants.h"
|
||||
#include "util/dockpopupwindow.h"
|
||||
#include "components/hoverhighlighteffect.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QPointer>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -95,6 +97,8 @@ protected:
|
||||
bool m_hover;
|
||||
bool m_popupShown;
|
||||
|
||||
QPointer<HoverHighlightEffect> m_hoverEffect;
|
||||
|
||||
QTimer *m_popupTipsDelayTimer;
|
||||
QTimer *m_popupAdjustDelayTimer;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user