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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "../appitem.h"
|
2020-07-24 09:37:39 +08:00
|
|
|
|
#include "appdragwidget.h"
|
|
|
|
|
#include <QGSettings>
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
class AppGraphicsObject : public QGraphicsObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-06-13 19:19:30 +08:00
|
|
|
|
explicit AppGraphicsObject(QGraphicsItem *parent = Q_NULLPTR) : QGraphicsObject(parent) {}
|
|
|
|
|
~AppGraphicsObject() override { }
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
void setAppPixmap(QPixmap pix)
|
|
|
|
|
{
|
|
|
|
|
m_appPixmap = pix;
|
|
|
|
|
resetProperty();
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void resetProperty()
|
|
|
|
|
{
|
|
|
|
|
setScale(1.0);
|
|
|
|
|
setRotation(0);
|
|
|
|
|
setOpacity(1.0);
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
|
QRectF boundingRect() const override
|
2018-06-04 21:09:41 +08:00
|
|
|
|
{
|
|
|
|
|
return m_appPixmap.rect();
|
2019-01-17 11:00:40 +08:00
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) override {
|
2018-06-04 21:09:41 +08:00
|
|
|
|
Q_ASSERT(!m_appPixmap.isNull());
|
|
|
|
|
|
|
|
|
|
painter->drawPixmap(QPoint(0, 0), m_appPixmap);
|
2019-01-17 11:00:40 +08:00
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QPixmap m_appPixmap;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppDragWidget::AppDragWidget(QWidget *parent) :
|
|
|
|
|
QGraphicsView(parent),
|
|
|
|
|
m_object(new AppGraphicsObject),
|
|
|
|
|
m_scene(new QGraphicsScene(this)),
|
|
|
|
|
m_followMouseTimer(new QTimer(this)),
|
|
|
|
|
m_animScale(new QPropertyAnimation(m_object, "scale", this)),
|
|
|
|
|
m_animRotation(new QPropertyAnimation(m_object, "rotation", this)),
|
|
|
|
|
m_animOpacity(new QPropertyAnimation(m_object, "opacity", this)),
|
2019-01-17 11:00:40 +08:00
|
|
|
|
m_animGroup(new QParallelAnimationGroup(this)),
|
2020-07-24 09:37:39 +08:00
|
|
|
|
m_goBackAnim(new QPropertyAnimation(this, "pos", this)),
|
2020-08-04 09:38:32 +08:00
|
|
|
|
m_removeTips(new TipsWidget(this)),
|
|
|
|
|
m_popupWindow(nullptr)
|
2018-06-04 21:09:41 +08:00
|
|
|
|
{
|
2020-07-24 09:37:39 +08:00
|
|
|
|
m_removeTips->setText(tr("Remove"));
|
|
|
|
|
m_removeTips->setObjectName("AppRemoveTips");
|
|
|
|
|
m_removeTips->setVisible(false);
|
|
|
|
|
m_removeTips->installEventFilter(this);
|
|
|
|
|
|
|
|
|
|
DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr);
|
|
|
|
|
arrowRectangle->setShadowBlurRadius(20);
|
|
|
|
|
arrowRectangle->setRadius(18);
|
|
|
|
|
arrowRectangle->setShadowYOffset(2);
|
|
|
|
|
arrowRectangle->setShadowXOffset(0);
|
|
|
|
|
arrowRectangle->setArrowWidth(18);
|
|
|
|
|
arrowRectangle->setArrowHeight(10);
|
2020-08-04 09:38:32 +08:00
|
|
|
|
m_popupWindow = arrowRectangle;
|
|
|
|
|
m_popupWindow->setRadius(18);
|
2020-07-24 09:37:39 +08:00
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
m_scene->addItem(m_object);
|
|
|
|
|
setScene(m_scene);
|
|
|
|
|
|
|
|
|
|
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground);
|
2019-09-23 16:27:37 +08:00
|
|
|
|
viewport()->setAutoFillBackground(false);
|
|
|
|
|
setFrameShape(QFrame::NoFrame);
|
2018-06-04 21:09:41 +08:00
|
|
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
setMouseTracking(true);
|
|
|
|
|
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
|
|
|
|
|
initAnimations();
|
2020-07-24 09:37:39 +08:00
|
|
|
|
initConfigurations();
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
|
|
|
|
m_followMouseTimer->setSingleShot(false);
|
|
|
|
|
m_followMouseTimer->setInterval(1);
|
|
|
|
|
connect(m_followMouseTimer, &QTimer::timeout, [this] {
|
2020-06-13 19:19:30 +08:00
|
|
|
|
QPoint destPos = QCursor::pos();
|
2020-08-28 18:47:34 +08:00
|
|
|
|
if (DWindowManagerHelper::instance()->hasComposite()) {
|
|
|
|
|
move(destPos.x() - width() / 2, destPos.y() - height() / 2);
|
|
|
|
|
} else {
|
|
|
|
|
move(destPos.x(), destPos.y()); //窗口特效未开启时会隐藏m_object绘制的图标,移动的图标为QDrag绘制的图标,大小为(10,10)
|
|
|
|
|
}
|
2020-06-13 19:19:30 +08:00
|
|
|
|
});
|
2018-06-04 21:09:41 +08:00
|
|
|
|
m_followMouseTimer->start();
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
|
AppDragWidget::~AppDragWidget()
|
|
|
|
|
{
|
2020-08-04 09:38:32 +08:00
|
|
|
|
if (m_popupWindow != nullptr) {
|
|
|
|
|
delete m_popupWindow;
|
|
|
|
|
m_popupWindow=nullptr;
|
|
|
|
|
}
|
2019-01-17 11:00:40 +08:00
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2018-08-08 11:35:08 +08:00
|
|
|
|
void AppDragWidget::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
QGraphicsView::mouseMoveEvent(event);
|
|
|
|
|
// hide widget when receiving mouseMoveEvent because this means drag-and-drop has been finished
|
2019-01-17 11:00:40 +08:00
|
|
|
|
if (m_goBackAnim->state() != QPropertyAnimation::State::Running
|
|
|
|
|
&& m_animGroup->state() != QParallelAnimationGroup::Running) {
|
|
|
|
|
hide();
|
|
|
|
|
}
|
2018-08-08 11:35:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void AppDragWidget::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
|
{
|
|
|
|
|
event->accept();
|
2021-01-05 12:45:46 +08:00
|
|
|
|
m_bDragDrop = true;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppDragWidget::dragMoveEvent(QDragMoveEvent *event)
|
|
|
|
|
{
|
2020-09-19 21:20:35 +08:00
|
|
|
|
Q_UNUSED(event);
|
|
|
|
|
showRemoveTips();
|
2021-01-05 12:45:46 +08:00
|
|
|
|
if (isRemoveItem() && m_bDragDrop) {
|
|
|
|
|
emit requestRemoveItem();
|
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 09:37:39 +08:00
|
|
|
|
const QPoint AppDragWidget::topleftPoint() const
|
|
|
|
|
{
|
|
|
|
|
QPoint p;
|
|
|
|
|
const QWidget *w = this;
|
|
|
|
|
do {
|
|
|
|
|
p += w->pos();
|
|
|
|
|
w = qobject_cast<QWidget *>(w->parent());
|
|
|
|
|
} while (w);
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QPoint AppDragWidget::popupMarkPoint(Dock::Position pos)
|
|
|
|
|
{
|
|
|
|
|
QPoint p(topleftPoint());
|
2020-08-18 16:41:25 +08:00
|
|
|
|
QRect r = rect();
|
|
|
|
|
//关闭特效,原本的图标设置小,然后隐藏,需要手动设置大小保证tips位置正确
|
|
|
|
|
if (!DWindowManagerHelper::instance()->hasComposite()) {
|
|
|
|
|
r.setWidth(m_iconSize.width() + 3);
|
|
|
|
|
r.setHeight(m_iconSize.height() + 3);
|
|
|
|
|
}
|
2020-07-24 09:37:39 +08:00
|
|
|
|
|
|
|
|
|
switch (pos) {
|
|
|
|
|
case Top:
|
|
|
|
|
p += QPoint(r.width() / 2, r.height());
|
|
|
|
|
break;
|
|
|
|
|
case Bottom:
|
2020-08-18 16:41:25 +08:00
|
|
|
|
if (!DWindowManagerHelper::instance()->hasComposite()) {
|
|
|
|
|
p += QPoint(0 , -r.height() / 2);
|
|
|
|
|
} else {
|
|
|
|
|
p += QPoint(r.width() / 2, 0);
|
|
|
|
|
}
|
2020-07-24 09:37:39 +08:00
|
|
|
|
break;
|
|
|
|
|
case Left:
|
|
|
|
|
p += QPoint(r.width(), r.height() / 2);
|
|
|
|
|
break;
|
|
|
|
|
case Right:
|
|
|
|
|
p += QPoint(0, r.height() / 2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void AppDragWidget::dropEvent(QDropEvent *event)
|
|
|
|
|
{
|
|
|
|
|
m_followMouseTimer->stop();
|
2021-01-05 12:45:46 +08:00
|
|
|
|
m_bDragDrop = false;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2021-03-05 14:26:28 +08:00
|
|
|
|
if (isRemoveAble(QCursor::pos())) {
|
2020-08-18 16:41:25 +08:00
|
|
|
|
if (DWindowManagerHelper::instance()->hasComposite()) {
|
|
|
|
|
showRemoveAnimation();
|
|
|
|
|
} else {
|
|
|
|
|
hide();
|
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
AppItem *appItem = static_cast<AppItem *>(event->source());
|
|
|
|
|
appItem->undock();
|
2020-08-04 09:38:32 +08:00
|
|
|
|
m_popupWindow->setVisible(false);
|
2018-06-04 21:09:41 +08:00
|
|
|
|
} else {
|
2020-08-18 16:41:25 +08:00
|
|
|
|
if (DWindowManagerHelper::instance()->hasComposite()) {
|
|
|
|
|
showGoBackAnimation();
|
|
|
|
|
} else {
|
|
|
|
|
hide();
|
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppDragWidget::hideEvent(QHideEvent *event)
|
|
|
|
|
{
|
|
|
|
|
deleteLater();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppDragWidget::setAppPixmap(const QPixmap &pix)
|
|
|
|
|
{
|
2020-08-18 16:41:25 +08:00
|
|
|
|
if (DWindowManagerHelper::instance()->hasComposite()) {
|
|
|
|
|
// QSize(3, 3) to fix pixmap be cliped
|
|
|
|
|
setFixedSize(pix.size() + QSize(3, 3));
|
|
|
|
|
} else {
|
|
|
|
|
setFixedSize(QSize(10, 10));
|
|
|
|
|
}
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2020-08-18 16:41:25 +08:00
|
|
|
|
m_iconSize = pix.size();
|
2018-06-04 21:09:41 +08:00
|
|
|
|
m_object->setAppPixmap(pix);
|
|
|
|
|
m_object->setTransformOriginPoint(pix.rect().center());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppDragWidget::setDockInfo(Dock::Position dockPosition, const QRect &dockGeometry)
|
|
|
|
|
{
|
|
|
|
|
m_dockPosition = dockPosition;
|
|
|
|
|
m_dockGeometry = dockGeometry;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-17 11:00:40 +08:00
|
|
|
|
void AppDragWidget::setOriginPos(const QPoint position)
|
|
|
|
|
{
|
|
|
|
|
m_originPoint = position;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void AppDragWidget::initAnimations()
|
|
|
|
|
{
|
|
|
|
|
m_animScale->setDuration(300);
|
|
|
|
|
m_animScale->setStartValue(1.0);
|
|
|
|
|
m_animScale->setEndValue(0.0);
|
|
|
|
|
|
|
|
|
|
m_animRotation->setDuration(300);
|
|
|
|
|
m_animRotation->setStartValue(0);
|
|
|
|
|
m_animRotation->setEndValue(90);
|
|
|
|
|
|
|
|
|
|
m_animOpacity->setDuration(300);
|
|
|
|
|
m_animOpacity->setStartValue(1.0);
|
|
|
|
|
m_animOpacity->setEndValue(0.0);
|
|
|
|
|
|
|
|
|
|
m_animGroup->addAnimation(m_animScale);
|
|
|
|
|
m_animGroup->addAnimation(m_animRotation);
|
|
|
|
|
m_animGroup->addAnimation(m_animOpacity);
|
|
|
|
|
|
|
|
|
|
connect(m_animGroup, &QParallelAnimationGroup::stateChanged,
|
|
|
|
|
this, &AppDragWidget::onRemoveAnimationStateChanged);
|
2019-01-17 11:00:40 +08:00
|
|
|
|
connect(m_goBackAnim, &QPropertyAnimation::finished, this, &AppDragWidget::hide);
|
2018-06-04 21:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 09:37:39 +08:00
|
|
|
|
void AppDragWidget::initConfigurations()
|
|
|
|
|
{
|
2021-03-05 14:26:28 +08:00
|
|
|
|
if (QGSettings::isSchemaInstalled("com.deepin.dde.dock.distancemultiple")) {
|
|
|
|
|
QGSettings gsetting("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/");
|
|
|
|
|
m_distanceMultiple = gsetting.get("distance-multiple").toDouble();
|
|
|
|
|
} else {
|
|
|
|
|
m_distanceMultiple = 1.5;
|
|
|
|
|
}
|
2020-07-24 09:37:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void AppDragWidget::showRemoveAnimation()
|
|
|
|
|
{
|
|
|
|
|
if (m_animGroup->state() == QParallelAnimationGroup::Running) {
|
|
|
|
|
m_animGroup->stop();
|
|
|
|
|
}
|
|
|
|
|
m_object->resetProperty();
|
|
|
|
|
m_animGroup->start();
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-17 11:00:40 +08:00
|
|
|
|
void AppDragWidget::showGoBackAnimation()
|
|
|
|
|
{
|
|
|
|
|
m_goBackAnim->setDuration(300);
|
|
|
|
|
m_goBackAnim->setStartValue(pos());
|
|
|
|
|
m_goBackAnim->setEndValue(m_originPoint);
|
|
|
|
|
m_goBackAnim->start();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void AppDragWidget::onRemoveAnimationStateChanged(QAbstractAnimation::State newState,
|
2020-06-13 19:19:30 +08:00
|
|
|
|
QAbstractAnimation::State oldState)
|
2018-06-04 21:09:41 +08:00
|
|
|
|
{
|
|
|
|
|
if (newState == QAbstractAnimation::Stopped) {
|
|
|
|
|
hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-05 12:45:46 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 判断图标拖到一定高度后是否可以移除
|
2021-03-05 14:26:28 +08:00
|
|
|
|
* @param curPos 当前鼠标所在位置
|
2021-01-05 12:45:46 +08:00
|
|
|
|
* @return true
|
|
|
|
|
* @return false
|
|
|
|
|
*/
|
2021-03-05 14:26:28 +08:00
|
|
|
|
bool AppDragWidget::isRemoveAble(const QPoint &curPos)
|
2018-06-04 21:09:41 +08:00
|
|
|
|
{
|
2021-03-05 14:26:28 +08:00
|
|
|
|
const QPoint &p = curPos;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
switch (m_dockPosition) {
|
2020-06-13 19:19:30 +08:00
|
|
|
|
case Dock::Position::Left:
|
2020-07-24 09:37:39 +08:00
|
|
|
|
if ((p.x() - m_dockGeometry.topRight().x()) > (m_dockGeometry.width() * m_distanceMultiple)) {
|
2020-06-13 19:19:30 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Dock::Position::Top:
|
2020-07-24 09:37:39 +08:00
|
|
|
|
if ((p.y() - m_dockGeometry.bottomLeft().y()) > (m_dockGeometry.height() * m_distanceMultiple)) {
|
2020-06-13 19:19:30 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Dock::Position::Right:
|
2020-07-24 09:37:39 +08:00
|
|
|
|
if ((m_dockGeometry.topLeft().x() - p.x()) > (m_dockGeometry.width() * m_distanceMultiple)) {
|
2020-06-13 19:19:30 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Dock::Position::Bottom:
|
2020-07-24 09:37:39 +08:00
|
|
|
|
if ((m_dockGeometry.topLeft().y() - p.y()) > (m_dockGeometry.height() * m_distanceMultiple)) {
|
2020-06-13 19:19:30 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-09-07 15:01:27 +08:00
|
|
|
|
|
2021-01-05 12:45:46 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief 判断应用区域图标是否拖出任务栏
|
|
|
|
|
*
|
|
|
|
|
* @return true
|
|
|
|
|
* @return false
|
|
|
|
|
*/
|
|
|
|
|
bool AppDragWidget::isRemoveItem()
|
|
|
|
|
{
|
|
|
|
|
const QPoint &p = QCursor::pos();
|
|
|
|
|
switch (m_dockPosition) {
|
|
|
|
|
case Dock::Position::Left:
|
|
|
|
|
if ((p.x() > m_dockGeometry.topRight().x())) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Dock::Position::Top:
|
|
|
|
|
if ((p.y() > m_dockGeometry.bottomLeft().y())) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Dock::Position::Right:
|
|
|
|
|
if ((m_dockGeometry.topLeft().x() > p.x())) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Dock::Position::Bottom:
|
|
|
|
|
if ((m_dockGeometry.topLeft().y() > p.y())) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-07 15:01:27 +08:00
|
|
|
|
void AppDragWidget::enterEvent(QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (m_goBackAnim->state() != QPropertyAnimation::State::Running
|
|
|
|
|
&& m_animGroup->state() != QParallelAnimationGroup::Running) {
|
|
|
|
|
hide();
|
|
|
|
|
}
|
2020-09-19 21:20:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppDragWidget::showRemoveTips()
|
|
|
|
|
{
|
2021-01-05 12:45:46 +08:00
|
|
|
|
bool model = true;
|
2020-09-19 21:20:35 +08:00
|
|
|
|
Dock::Position pos = Dock::Position::Bottom;
|
|
|
|
|
|
|
|
|
|
DockPopupWindow *popup = m_popupWindow;
|
2021-03-05 14:26:28 +08:00
|
|
|
|
if (isRemoveAble(QCursor::pos())) {
|
2020-09-19 21:20:35 +08:00
|
|
|
|
QWidget *lastContent = popup->getContent();
|
|
|
|
|
if (lastContent)
|
|
|
|
|
lastContent->setVisible(false);
|
|
|
|
|
|
|
|
|
|
switch (pos) {
|
|
|
|
|
case Top: popup->setArrowDirection(DockPopupWindow::ArrowTop); break;
|
|
|
|
|
case Bottom: popup->setArrowDirection(DockPopupWindow::ArrowBottom); break;
|
|
|
|
|
case Left: popup->setArrowDirection(DockPopupWindow::ArrowLeft); break;
|
|
|
|
|
case Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break;
|
|
|
|
|
}
|
|
|
|
|
popup->resize(m_removeTips->sizeHint());
|
|
|
|
|
popup->setContent(m_removeTips);
|
|
|
|
|
|
|
|
|
|
const QPoint p = popupMarkPoint(pos);
|
|
|
|
|
if (!popup->isVisible())
|
|
|
|
|
QMetaObject::invokeMethod(popup, "show", Qt::QueuedConnection, Q_ARG(QPoint, p), Q_ARG(bool, model));
|
|
|
|
|
else
|
|
|
|
|
popup->show(p, model);
|
|
|
|
|
|
|
|
|
|
m_object->setOpacity(0.5);
|
|
|
|
|
m_animOpacity->setStartValue(0.5);
|
|
|
|
|
} else {
|
|
|
|
|
m_object->setOpacity(1.0);
|
|
|
|
|
m_animOpacity->setStartValue(1.0);
|
|
|
|
|
if (popup->isVisible())
|
|
|
|
|
popup->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppDragWidget::moveEvent(QMoveEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(event);
|
|
|
|
|
showRemoveTips();
|
2021-01-05 12:45:46 +08:00
|
|
|
|
}
|