fix popup not hide

Change-Id: I78cc458c991ac121ce27f80bcada02a3db627f57
This commit is contained in:
石博文 2017-12-15 16:47:16 +08:00 committed by Deepin Code Review
parent 587c74a069
commit 4a9b0a1ae4
Notes: Deepin Code Review 2017-12-19 10:35:45 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Tue, 19 Dec 2017 10:35:41 +0800
Reviewed-on: https://cr.deepin.io/29462
Project: dde/dde-dock
Branch: refs/heads/master
7 changed files with 27 additions and 62 deletions

View File

@ -103,15 +103,11 @@ void DockItem::moveEvent(QMoveEvent *e)
m_popupAdjustDelayTimer->start();
}
//void DockItem::mouseMoveEvent(QMouseEvent *e)
//{
// QWidget::mouseMoveEvent(e);
// m_popupTipsDelayTimer->start();
//}
void DockItem::mousePressEvent(QMouseEvent *e)
{
m_popupTipsDelayTimer->stop();
hideNonModel();
if (e->button() == Qt::RightButton)
return showContextMenu();
}
@ -322,3 +318,10 @@ void DockItem::hidePopup()
emit PopupWindow->accept();
emit requestWindowAutoHide(true);
}
void DockItem::hideNonModel()
{
// auto hide if popup is not model window
if (m_popupShown && !PopupWindow->model())
hidePopup();
}

View File

@ -67,7 +67,6 @@ signals:
protected:
void paintEvent(QPaintEvent *e);
void moveEvent(QMoveEvent *e);
// void mouseMoveEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
@ -77,6 +76,7 @@ protected:
const QPoint topleftPoint() const;
void hidePopup();
void hideNonModel();
void popupWindowAccept();
void showPopupApplet(QWidget * const applet);
virtual void showPopupWindow(QWidget * const content, const bool model = false);

View File

@ -46,7 +46,6 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
setBackgroundColor(DBlurEffectWidget::DarkColor);
setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
setAttribute(Qt::WA_InputMethodEnabled, false);
setFocusPolicy(Qt::StrongFocus);
connect(m_acceptDelayTimer, &QTimer::timeout, this, &DockPopupWindow::accept);
connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &DockPopupWindow::compositeChanged);
@ -107,24 +106,14 @@ void DockPopupWindow::showEvent(QShowEvent *e)
{
DArrowRectangle::showEvent(e);
QTimer::singleShot(1, this, [&] {
raise();
if (!m_model)
return;
activateWindow();
setFocus(Qt::ActiveWindowFocusReason);
});
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
}
void DockPopupWindow::enterEvent(QEvent *e)
{
DArrowRectangle::enterEvent(e);
raise();
if (!m_model)
return;
activateWindow();
setFocus(Qt::ActiveWindowFocusReason);
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
}
bool DockPopupWindow::eventFilter(QObject *o, QEvent *e)
@ -159,3 +148,9 @@ void DockPopupWindow::compositeChanged()
else
setBorderColor(QColor("#2C3238"));
}
void DockPopupWindow::ensureRaised()
{
if (isVisible())
raise();
}

View File

@ -58,6 +58,7 @@ protected:
private slots:
void onGlobMouseRelease(const QPoint &mousePos, const int flag);
void compositeChanged();
void ensureRaised();
private:
bool m_model;

View File

@ -558,7 +558,7 @@ void MainWindow::setStrutPartial()
void MainWindow::expand()
{
qDebug() << "expand";
// qDebug() << "expand";
const QPoint finishPos(0, 0);
const int epsilon = std::round(devicePixelRatioF()) - 1;
@ -651,8 +651,6 @@ void MainWindow::resetPanelEnvironment(const bool visible)
void MainWindow::updatePanelVisible()
{
// qDebug() << m_updatePanelVisible;
if (!m_updatePanelVisible)
return;
if (m_settings->hideMode() == KeepShowing)
@ -660,8 +658,6 @@ void MainWindow::updatePanelVisible()
const Dock::HideState state = m_settings->hideState();
// qDebug() << state;
do
{
if (state != Hide)
@ -695,42 +691,10 @@ void MainWindow::adjustShadowMask()
m_panelShowAni->state() == QPauseAnimation::Running ||
!m_wmHelper->hasComposite())
{
// m_platformWindowHandle.setClipPath(QPainterPath());
m_platformWindowHandle.setShadowRadius(0);
// return;
} else {
m_platformWindowHandle.setShadowRadius(60);
}
qDebug() << Q_FUNC_INFO;
// 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()

View File

@ -111,13 +111,15 @@ void PluginWidget::mousePressEvent(QMouseEvent *e)
return QWidget::mousePressEvent(e);
}
void PluginWidget::enterEvent(QEvent *)
void PluginWidget::enterEvent(QEvent *e)
{
e->accept();
m_hover = true;
}
void PluginWidget::leaveEvent(QEvent *)
void PluginWidget::leaveEvent(QEvent *e)
{
e->accept();
m_hover = false;
}

View File

@ -44,8 +44,8 @@ protected:
QSize sizeHint() const;
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
private:
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;