diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index 38034b36b..a22a97cab 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -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(); +} diff --git a/frame/item/dockitem.h b/frame/item/dockitem.h index 2cb87b5af..a085c2c5b 100644 --- a/frame/item/dockitem.h +++ b/frame/item/dockitem.h @@ -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); diff --git a/frame/util/dockpopupwindow.cpp b/frame/util/dockpopupwindow.cpp index 58d52bcba..96b3ce346 100644 --- a/frame/util/dockpopupwindow.cpp +++ b/frame/util/dockpopupwindow.cpp @@ -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(); +} diff --git a/frame/util/dockpopupwindow.h b/frame/util/dockpopupwindow.h index 9cd02913f..ff7deb566 100644 --- a/frame/util/dockpopupwindow.h +++ b/frame/util/dockpopupwindow.h @@ -58,6 +58,7 @@ protected: private slots: void onGlobMouseRelease(const QPoint &mousePos, const int flag); void compositeChanged(); + void ensureRaised(); private: bool m_model; diff --git a/frame/window/mainwindow.cpp b/frame/window/mainwindow.cpp index 5cc16e1ca..7ada00446 100644 --- a/frame/window/mainwindow.cpp +++ b/frame/window/mainwindow.cpp @@ -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() diff --git a/plugins/shutdown/pluginwidget.cpp b/plugins/shutdown/pluginwidget.cpp index d264287a3..e1172aac8 100644 --- a/plugins/shutdown/pluginwidget.cpp +++ b/plugins/shutdown/pluginwidget.cpp @@ -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; } diff --git a/plugins/shutdown/pluginwidget.h b/plugins/shutdown/pluginwidget.h index 327d6c561..24fdf710b 100644 --- a/plugins/shutdown/pluginwidget.h +++ b/plugins/shutdown/pluginwidget.h @@ -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;