2018-06-04 21:09:41 +08:00
|
|
|
|
/*
|
|
|
|
|
* 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>
|
2021-03-05 14:41:04 +08:00
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
2020-07-24 09:37:39 +08:00
|
|
|
|
#include "../widgets/tipswidget.h"
|
2020-12-16 17:38:41 +08:00
|
|
|
|
#include "dockpopupwindow.h"
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2021-03-05 14:41:04 +08:00
|
|
|
|
class QGSettingsInterface;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
class AppGraphicsObject;
|
|
|
|
|
class AppDragWidget : public QGraphicsView
|
|
|
|
|
{
|
2020-08-04 15:36:21 +08:00
|
|
|
|
Q_OBJECT
|
2018-06-04 21:09:41 +08:00
|
|
|
|
public:
|
2021-03-05 14:41:04 +08:00
|
|
|
|
explicit AppDragWidget(QGSettingsInterface *interface, QWidget *parent = Q_NULLPTR);
|
2020-06-13 19:19:30 +08:00
|
|
|
|
virtual ~AppDragWidget() override;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
void setAppPixmap(const QPixmap &pix);
|
|
|
|
|
void setDockInfo(Dock::Position dockPosition, const QRect &dockGeometry);
|
2019-01-17 11:00:40 +08:00
|
|
|
|
void setOriginPos(const QPoint position);
|
2021-03-05 14:26:28 +08:00
|
|
|
|
bool isRemoveAble(const QPoint &curPos);
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2021-01-05 12:45:46 +08:00
|
|
|
|
signals:
|
|
|
|
|
void requestRemoveItem();
|
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
protected:
|
2020-06-13 19:19:30 +08:00
|
|
|
|
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;
|
2020-09-19 21:20:35 +08:00
|
|
|
|
void moveEvent(QMoveEvent *event) override;
|
|
|
|
|
void enterEvent(QEvent *event) override;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void initAnimations();
|
|
|
|
|
void showRemoveAnimation();
|
2019-01-17 11:00:40 +08:00
|
|
|
|
void showGoBackAnimation();
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void onRemoveAnimationStateChanged(QAbstractAnimation::State newState,
|
|
|
|
|
QAbstractAnimation::State oldState);
|
2020-07-24 09:37:39 +08:00
|
|
|
|
const QPoint popupMarkPoint(Dock::Position pos);
|
|
|
|
|
const QPoint topleftPoint() const;
|
2020-09-19 21:20:35 +08:00
|
|
|
|
void showRemoveTips();
|
2021-01-05 12:45:46 +08:00
|
|
|
|
bool isRemoveItem();
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
private:
|
2021-03-16 13:16:30 +08:00
|
|
|
|
QGSettingsInterface *m_qgInterface;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
AppGraphicsObject *m_object;
|
|
|
|
|
QGraphicsScene *m_scene;
|
|
|
|
|
QTimer *m_followMouseTimer;
|
|
|
|
|
QPropertyAnimation *m_animScale;
|
|
|
|
|
QPropertyAnimation *m_animRotation;
|
|
|
|
|
QPropertyAnimation *m_animOpacity;
|
|
|
|
|
QParallelAnimationGroup *m_animGroup;
|
2019-01-17 11:00:40 +08:00
|
|
|
|
QPropertyAnimation *m_goBackAnim;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
Dock::Position m_dockPosition;
|
|
|
|
|
QRect m_dockGeometry;
|
2019-01-17 11:00:40 +08:00
|
|
|
|
QPoint m_originPoint;
|
2020-08-18 16:41:25 +08:00
|
|
|
|
QSize m_iconSize;
|
2020-08-04 09:38:32 +08:00
|
|
|
|
Dock::TipsWidget *m_removeTips;
|
|
|
|
|
DockPopupWindow *m_popupWindow;
|
2020-07-24 09:37:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief m_distanceMultiple: 倍数
|
|
|
|
|
* dock栏上应用区驻留应用被拖拽远离dock的距离除以dock的宽或者高(更小的一个)的比值
|
|
|
|
|
*/
|
|
|
|
|
double m_distanceMultiple;
|
2021-01-05 12:45:46 +08:00
|
|
|
|
|
|
|
|
|
bool m_bDragDrop = false; // 图标是否被拖拽
|
2018-06-04 21:09:41 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* APPDRAGWIDGET_H */
|