Skip to content

Commit

Permalink
fix: Dock cannot hide clipboard in non special effects mode
Browse files Browse the repository at this point in the history
The interval between displaying and hiding operations must be greater than 300ms

Issue: linuxdeepin/developer-center#8309
  • Loading branch information
mhduiy committed Apr 29, 2024
1 parent 8b5ef76 commit d781761
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion dde-clipboard/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ MainWindow::MainWindow(QWidget *parent)
, m_widthAni(new QPropertyAnimation(this))
, m_aniGroup(new QSequentialAnimationGroup(this))
, m_wmHelper(DWindowManagerHelper::instance())
, m_trickTimer(new QTimer)
{
initUI();
initAni();
Expand Down Expand Up @@ -94,6 +95,11 @@ void MainWindow::geometryChanged()

void MainWindow::showAni()
{
if (m_trickTimer->isActive()) {
return;
}
m_trickTimer->start();

if (!m_hasComposite) {
move(m_rect.x() + WindowMargin, m_rect.y());
setFixedWidth(m_rect.width());
Expand All @@ -111,6 +117,11 @@ void MainWindow::showAni()

void MainWindow::hideAni()
{
if (m_trickTimer->isActive()) {
return;
}
m_trickTimer->start();

if (m_alwaysShow) {
return;
}
Expand Down Expand Up @@ -165,7 +176,7 @@ void MainWindow::registerMonitor()
}
m_regionMonitor = new DRegionMonitor(this);
m_regionMonitor->registerRegion(QRegion(QRect()));
connect(m_regionMonitor, &DRegionMonitor::buttonPress, this, [ = ](const QPoint &p, const int flag) {
connect(m_regionMonitor, &DRegionMonitor::buttonRelease, this, [ = ](const QPoint &p, const int flag) {
Q_UNUSED(flag);
if (!geometry().contains(p))
if (!isHidden()) {
Expand Down Expand Up @@ -219,6 +230,9 @@ void MainWindow::initUI()

setMaskAlpha(static_cast<int>(this->opacity() * 255));
setFocusPolicy(Qt::NoFocus);

m_trickTimer->setInterval(300);
m_trickTimer->setSingleShot(true);
}

void MainWindow::initAni()
Expand Down
2 changes: 2 additions & 0 deletions dde-clipboard/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ private Q_SLOTS:
QRect m_rect;

DWindowManagerHelper *m_wmHelper;

QTimer *m_trickTimer;

bool m_hasComposite = false;

Expand Down

0 comments on commit d781761

Please sign in to comment.