mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add size & pos animation
Change-Id: I584607b89c11d5879da3dda5dc2d90809201cc83
This commit is contained in:
parent
a73854f66c
commit
1178702567
@ -32,7 +32,7 @@ MainPanel::MainPanel(QWidget *parent)
|
||||
connect(m_itemAdjustTimer, &QTimer::timeout, this, &MainPanel::adjustItemSize);
|
||||
|
||||
m_itemAdjustTimer->setSingleShot(true);
|
||||
m_itemAdjustTimer->setInterval(200);
|
||||
m_itemAdjustTimer->setInterval(100);
|
||||
|
||||
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||
for (auto item : itemList)
|
||||
|
@ -12,7 +12,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
m_xcbMisc(XcbMisc::instance()),
|
||||
|
||||
m_positionUpdateTimer(new QTimer(this))
|
||||
m_positionUpdateTimer(new QTimer(this)),
|
||||
m_sizeChangeAni(new QPropertyAnimation(this, "size")),
|
||||
m_posChangeAni(new QPropertyAnimation(this, "pos"))
|
||||
{
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
@ -56,11 +58,37 @@ void MainWindow::keyPressEvent(QKeyEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setFixedSize(const QSize &size)
|
||||
{
|
||||
if (m_sizeChangeAni->state() == QPropertyAnimation::Running)
|
||||
return m_sizeChangeAni->setEndValue(size);
|
||||
|
||||
m_sizeChangeAni->setStartValue(this->size());
|
||||
m_sizeChangeAni->setEndValue(size);
|
||||
m_sizeChangeAni->start();
|
||||
}
|
||||
|
||||
void MainWindow::move(int x, int y)
|
||||
{
|
||||
if (m_posChangeAni->state() == QPropertyAnimation::Running)
|
||||
return m_posChangeAni->setEndValue(QPoint(x, y));
|
||||
|
||||
m_posChangeAni->setStartValue(pos());
|
||||
m_posChangeAni->setEndValue(QPoint(x, y));
|
||||
m_posChangeAni->start();
|
||||
}
|
||||
|
||||
void MainWindow::initComponents()
|
||||
{
|
||||
m_positionUpdateTimer->setSingleShot(true);
|
||||
m_positionUpdateTimer->setInterval(200);
|
||||
m_positionUpdateTimer->start();
|
||||
|
||||
m_sizeChangeAni->setDuration(200);
|
||||
m_sizeChangeAni->setEasingCurve(QEasingCurve::OutCubic);
|
||||
|
||||
m_posChangeAni->setDuration(200);
|
||||
m_posChangeAni->setEasingCurve(QEasingCurve::OutCubic);
|
||||
}
|
||||
|
||||
void MainWindow::initConnections()
|
||||
@ -83,23 +111,25 @@ void MainWindow::updatePosition()
|
||||
|
||||
void MainWindow::updateGeometry()
|
||||
{
|
||||
setFixedSize(m_settings->windowSize());
|
||||
const QSize size = m_settings->windowSize();
|
||||
|
||||
setFixedSize(size);
|
||||
m_mainPanel->updateDockPosition(m_settings->position());
|
||||
m_mainPanel->updateDockDisplayMode(m_settings->displayMode());
|
||||
|
||||
const QRect primaryRect = m_settings->primaryRect();
|
||||
const int offsetX = (primaryRect.width() - width()) / 2;
|
||||
const int offsetY = (primaryRect.height() - height()) / 2;
|
||||
const int offsetX = (primaryRect.width() - size.width()) / 2;
|
||||
const int offsetY = (primaryRect.height() - size.height()) / 2;
|
||||
switch (m_settings->position())
|
||||
{
|
||||
case Top:
|
||||
move(primaryRect.topLeft().x() + offsetX, 0); break;
|
||||
move(primaryRect.topLeft().x() + offsetX, 0); break;
|
||||
case Left:
|
||||
move(primaryRect.topLeft().x(), offsetY); break;
|
||||
move(primaryRect.topLeft().x(), offsetY); break;
|
||||
case Right:
|
||||
move(primaryRect.right() - width(), offsetY); break;
|
||||
move(primaryRect.right() - size.width() + 1, offsetY); break;
|
||||
case Bottom:
|
||||
move(offsetX, primaryRect.bottom() - height() + 1); break;
|
||||
move(offsetX, primaryRect.bottom() - size.height() + 1); break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
@ -125,8 +155,8 @@ void MainWindow::setStrutPartial()
|
||||
uint strutStart;
|
||||
uint strutEnd;
|
||||
|
||||
const QPoint p = pos();
|
||||
const QRect r = rect();
|
||||
const QPoint p = m_posChangeAni->endValue().toPoint();
|
||||
const QRect r = QRect(p, m_settings->windowSize());
|
||||
switch (side)
|
||||
{
|
||||
case Position::Top:
|
||||
|
@ -21,6 +21,8 @@ private:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void setFixedSize(const QSize &size);
|
||||
void move(int x, int y);
|
||||
void initComponents();
|
||||
void initConnections();
|
||||
|
||||
@ -37,6 +39,8 @@ private:
|
||||
XcbMisc *m_xcbMisc;
|
||||
|
||||
QTimer *m_positionUpdateTimer;
|
||||
QPropertyAnimation *m_sizeChangeAni;
|
||||
QPropertyAnimation *m_posChangeAni;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user