dde-dock/frame/item/components/appdragwidget.h
wangnengdeng 6e104465eb fix: 解决"Remove"提示残留在桌面上的问题
问题的原因是因为在拖拽Widget中使用了一个静态的提示”移除“对象,这个可能在一定条件下
出现没有消失的情况。因此将此弹出提示的Widget改成拖拽对象的成员变量,这样当拖拽对象
销毁时,弹出提示对象也会一并给清除,从而解决”移除“提示不消失的问题

Log: 拖动任务栏上的图标移动后,"Remove"提示仍残留在桌面上
Task: https://pms.uniontech.com/zentao/bug-view-40987.html
Change-Id: I42d28c97e80b1cc1522d5a984d11a1a7a4f8eeef
Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/1065
Reviewed-by: fanpengcheng <fanpengcheng@uniontech.com>
Reviewed-by: <mailman@uniontech.com>
Reviewed-by: niecheng <niecheng@uniontech.com>
Tested-by: <mailman@uniontech.com>
2020-08-04 14:34:50 +08:00

91 lines
2.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
*
* Author: listenerri <listenerri@gmail.com>
*
* Maintainer: listenerri <listenerri@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef APPDRAGWIDGET_H
#define APPDRAGWIDGET_H
#include "constants.h"
#include <QPixmap>
#include <QGraphicsObject>
#include <QGraphicsView>
#include <QPainter>
#include <QMouseEvent>
#include <QTimer>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <qwidget.h>
#include "../widgets/tipswidget.h"
#include "util/dockpopupwindow.h"
class AppGraphicsObject;
class AppDragWidget : public QGraphicsView
{
public:
explicit AppDragWidget(QWidget *parent = Q_NULLPTR);
virtual ~AppDragWidget() override;
void setAppPixmap(const QPixmap &pix);
void setDockInfo(Dock::Position dockPosition, const QRect &dockGeometry);
void setOriginPos(const QPoint position);
bool isRemoveAble();
protected:
void mouseMoveEvent(QMouseEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dropEvent(QDropEvent *event) override;
void hideEvent(QHideEvent *event) override;
private:
void initAnimations();
void initConfigurations();
void showRemoveAnimation();
void showGoBackAnimation();
void onRemoveAnimationStateChanged(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState);
const QPoint popupMarkPoint(Dock::Position pos);
const QPoint topleftPoint() const;
private:
AppGraphicsObject *m_object;
QGraphicsScene *m_scene;
QTimer *m_followMouseTimer;
QPropertyAnimation *m_animScale;
QPropertyAnimation *m_animRotation;
QPropertyAnimation *m_animOpacity;
QParallelAnimationGroup *m_animGroup;
QPropertyAnimation *m_goBackAnim;
Dock::Position m_dockPosition;
QRect m_dockGeometry;
QPoint m_originPoint;
Dock::TipsWidget *m_removeTips;
DockPopupWindow *m_popupWindow;
/**
* @brief m_distanceMultiple: 倍数
* dock栏上应用区驻留应用被拖拽远离dock的距离除以dock的宽或者高更小的一个的比值
*/
double m_distanceMultiple;
};
#endif /* APPDRAGWIDGET_H */