mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
optimize dock animation, remove clippath
Change-Id: I192fde120773df8f42d40bf9ce9558c3026c0c6a
This commit is contained in:
parent
69d0262fef
commit
0e1795ba20
Notes:
Deepin Code Review
2017-12-12 15:19:12 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 12 Dec 2017 15:19:12 +0800 Reviewed-on: https://cr.deepin.io/29315 Project: dde/dde-dock Branch: refs/heads/master
@ -35,7 +35,7 @@ DockPluginsController::DockPluginsController(DockItemController *itemControllerI
|
||||
{
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
QTimer::singleShot(1, this, &DockPluginsController::startLoader);
|
||||
QTimer::singleShot(2000, this, &DockPluginsController::startLoader);
|
||||
}
|
||||
|
||||
void DockPluginsController::itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
|
@ -104,13 +104,13 @@ MainPanel::MainPanel(QWidget *parent)
|
||||
connect(m_itemController, &DockItemController::itemUpdated, m_itemAdjustTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
connect(m_itemAdjustTimer, &QTimer::timeout, this, &MainPanel::adjustItemSize, Qt::QueuedConnection);
|
||||
connect(m_updateEffectTimer, &QTimer::timeout, this, &MainPanel::updateBlurEffect, Qt::QueuedConnection);
|
||||
connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &MainPanel::updateBlurEffect, Qt::QueuedConnection);
|
||||
connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, m_updateEffectTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
|
||||
m_itemAdjustTimer->setSingleShot(true);
|
||||
m_itemAdjustTimer->setInterval(100);
|
||||
|
||||
m_updateEffectTimer->setSingleShot(true);
|
||||
m_updateEffectTimer->setInterval(10);
|
||||
m_updateEffectTimer->setInterval(1000 / 25);
|
||||
|
||||
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||
for (auto item : itemList)
|
||||
@ -157,7 +157,6 @@ void MainPanel::updateDockDisplayMode(const DisplayMode displayMode)
|
||||
switch (item->itemType())
|
||||
{
|
||||
case DockItem::Container:
|
||||
case DockItem::Stretch:
|
||||
item->setVisible(displayMode == Dock::Efficient);
|
||||
break;
|
||||
default:;
|
||||
@ -380,6 +379,10 @@ DockItem *MainPanel::itemAt(const QPoint &point)
|
||||
|
||||
void MainPanel::updateBlurEffect() const
|
||||
{
|
||||
Q_ASSERT(sender() == m_updateEffectTimer);
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
if (m_displayMode == Efficient || !m_wmHelper->hasComposite()) {
|
||||
m_effectWidget->setBlurRectXRadius(0);
|
||||
m_effectWidget->setBlurRectYRadius(0);
|
||||
@ -470,7 +473,7 @@ void MainPanel::adjustItemSize()
|
||||
if (m_itemController->itemIsInContainer(item))
|
||||
continue;
|
||||
if (m_displayMode == Fashion &&
|
||||
(itemType == DockItem::Container || itemType == DockItem::Stretch))
|
||||
itemType == DockItem::Container)
|
||||
continue;
|
||||
|
||||
QMetaObject::invokeMethod(item, "setVisible", Qt::QueuedConnection, Q_ARG(bool, true));
|
||||
|
@ -107,7 +107,10 @@ QRect MainWindow::panelGeometry()
|
||||
|
||||
void MainWindow::launch()
|
||||
{
|
||||
setVisible(true);
|
||||
m_updatePanelVisible = false;
|
||||
narrow(m_settings->position());
|
||||
setVisible(false);
|
||||
|
||||
QTimer::singleShot(400, this, [&] {
|
||||
m_launched = true;
|
||||
@ -590,7 +593,7 @@ void MainWindow::expand()
|
||||
void MainWindow::narrow(const Position prevPos)
|
||||
{
|
||||
// qDebug() << "narrow" << prevPos;
|
||||
// const QSize size = m_settings->windowSize();
|
||||
// const QSize size = m_settings->windowSize();
|
||||
const QSize size = m_mainPanel->size();
|
||||
|
||||
QPoint finishPos(0, 0);
|
||||
@ -684,44 +687,47 @@ void MainWindow::adjustShadowMask()
|
||||
if (m_shadowMaskOptimizeTimer->isActive())
|
||||
return;
|
||||
m_shadowMaskOptimizeTimer->start();
|
||||
qApp->processEvents();
|
||||
|
||||
if (m_mainPanel->pos() != QPoint(0, 0) ||
|
||||
m_panelHideAni->state() == QPropertyAnimation::Running ||
|
||||
m_panelShowAni->state() == QPauseAnimation::Running ||
|
||||
!m_wmHelper->hasComposite())
|
||||
{
|
||||
m_platformWindowHandle.setClipPath(QPainterPath());
|
||||
// m_platformWindowHandle.setClipPath(QPainterPath());
|
||||
m_platformWindowHandle.setShadowRadius(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const QRect r = QRect(QPoint(), rect().size());
|
||||
const int radius = 5;
|
||||
|
||||
QPainterPath path;
|
||||
if (m_settings->displayMode() == DisplayMode::Fashion)
|
||||
{
|
||||
switch (m_settings->position())
|
||||
{
|
||||
case Top:
|
||||
path.addRoundedRect(0, -radius, r.width(), r.height() + radius, radius, radius);
|
||||
break;
|
||||
case Bottom:
|
||||
path.addRoundedRect(0, 0, r.width(), r.height() + radius, radius, radius);
|
||||
break;
|
||||
case Left:
|
||||
path.addRoundedRect(-radius, 0, r.width() + radius, r.height(), radius, radius);
|
||||
break;
|
||||
case Right:
|
||||
path.addRoundedRect(0, 0, r.width() + radius, r.height(), radius, radius);
|
||||
default:;
|
||||
}
|
||||
// return;
|
||||
} else {
|
||||
path.addRect(r);
|
||||
m_platformWindowHandle.setShadowRadius(60);
|
||||
}
|
||||
|
||||
m_platformWindowHandle.setClipPath(path);
|
||||
m_platformWindowHandle.setShadowRadius(60);
|
||||
// const QRect r = QRect(QPoint(), rect().size());
|
||||
// const int radius = 5;
|
||||
|
||||
// QPainterPath path;
|
||||
// if (m_settings->displayMode() == DisplayMode::Fashion)
|
||||
// {
|
||||
// switch (m_settings->position())
|
||||
// {
|
||||
// case Top:
|
||||
// path.addRoundedRect(0, -radius, r.width(), r.height() + radius, radius, radius);
|
||||
// break;
|
||||
// case Bottom:
|
||||
// path.addRoundedRect(0, 0, r.width(), r.height() + radius, radius, radius);
|
||||
// break;
|
||||
// case Left:
|
||||
// path.addRoundedRect(-radius, 0, r.width() + radius, r.height(), radius, radius);
|
||||
// break;
|
||||
// case Right:
|
||||
// path.addRoundedRect(0, 0, r.width() + radius, r.height(), radius, radius);
|
||||
// default:;
|
||||
// }
|
||||
// } else {
|
||||
// path.addRect(r);
|
||||
// }
|
||||
|
||||
// m_platformWindowHandle.setClipPath(path);
|
||||
// m_platformWindowHandle.setShadowRadius(60);
|
||||
}
|
||||
|
||||
void MainWindow::positionCheck()
|
||||
|
Loading…
x
Reference in New Issue
Block a user