diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index f0fbc0d9d..f28d19600 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -209,6 +209,15 @@ void DockItem::popupWindowAccept() emit requestWindowAutoHide(true); } +void DockItem::showPopupApplet(QWidget * const applet) +{ + // another model popup window is alread exists + if (PopupWindow->isVisible() && PopupWindow->model()) + return; + + showPopupWindow(applet, true); +} + void DockItem::invokedMenuItem(const QString &itemId, const bool checked) { Q_UNUSED(itemId) diff --git a/frame/item/dockitem.h b/frame/item/dockitem.h index 147ab801c..e282155eb 100644 --- a/frame/item/dockitem.h +++ b/frame/item/dockitem.h @@ -49,12 +49,15 @@ protected: void showContextMenu(); void showHoverTips(); - void showPopupWindow(QWidget * const content, const bool model = false); void popupWindowAccept(); + void showPopupApplet(QWidget * const applet); virtual void invokedMenuItem(const QString &itemId, const bool checked); virtual const QString contextMenu() const; virtual QWidget *popupTips(); +private: + void showPopupWindow(QWidget * const content, const bool model = false); + protected: ItemType m_type; bool m_hover; diff --git a/frame/item/pluginsitem.cpp b/frame/item/pluginsitem.cpp index d264406f7..d20130687 100644 --- a/frame/item/pluginsitem.cpp +++ b/frame/item/pluginsitem.cpp @@ -147,5 +147,5 @@ void PluginsItem::mouseClicked() // request popup applet QWidget *w = m_pluginInter->itemPopupApplet(m_itemKey); if (w) - showPopupWindow(w, true); + showPopupApplet(w); } diff --git a/frame/util/dockpopupwindow.cpp b/frame/util/dockpopupwindow.cpp index 4fe991e2a..5fbd42e20 100644 --- a/frame/util/dockpopupwindow.cpp +++ b/frame/util/dockpopupwindow.cpp @@ -26,9 +26,20 @@ bool DockPopupWindow::model() const return m_model; } +void DockPopupWindow::setContent(QWidget *content) +{ + QWidget *lastWidget = getContent(); + if (lastWidget) + lastWidget->removeEventFilter(this); + content->installEventFilter(this); + + DArrowRectangle::setContent(content); +} + void DockPopupWindow::show(const QPoint &pos, const bool model) { m_model = model; + m_lastPoint = pos; DArrowRectangle::show(pos.x(), pos.y()); @@ -58,7 +69,17 @@ void DockPopupWindow::mousePressEvent(QMouseEvent *e) DArrowRectangle::mousePressEvent(e); // if (e->button() == Qt::LeftButton) -// m_acceptDelayTimer->start(); +// m_acceptDelayTimer->start(); +} + +bool DockPopupWindow::eventFilter(QObject *o, QEvent *e) +{ + if (o != getContent() || e->type() != QEvent::Resize) + return false; + +// show(m_lastPoint, m_model); + QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection, Q_ARG(QPoint, m_lastPoint), Q_ARG(bool, m_model)); + return false; } void DockPopupWindow::globalMouseRelease(int button, int x, int y, const QString &id) diff --git a/frame/util/dockpopupwindow.h b/frame/util/dockpopupwindow.h index 226c03a3d..5eca8fff4 100644 --- a/frame/util/dockpopupwindow.h +++ b/frame/util/dockpopupwindow.h @@ -15,6 +15,8 @@ public: bool model() const; + void setContent(QWidget *content); + public slots: void show(const QPoint &pos, const bool model = false); void hide(); @@ -24,12 +26,14 @@ signals: protected: void mousePressEvent(QMouseEvent *e); + bool eventFilter(QObject *o, QEvent *e); private slots: void globalMouseRelease(int button, int x, int y, const QString &id); private: bool m_model; + QPoint m_lastPoint; QString m_mouseAreaKey; QTimer *m_acceptDelayTimer; diff --git a/plugins/network/item/applet/accesspoint.h b/plugins/network/item/applet/accesspoint.h index d65442436..6c2442f22 100644 --- a/plugins/network/item/applet/accesspoint.h +++ b/plugins/network/item/applet/accesspoint.h @@ -10,8 +10,8 @@ class AccessPoint : public QObject public: explicit AccessPoint(const QJsonObject &apInfo); + explicit AccessPoint(const QString &info); AccessPoint(const AccessPoint &ap); - AccessPoint(const QString &info); bool operator==(const AccessPoint &ap) const; bool operator>(const AccessPoint &ap) const; AccessPoint &operator=(const AccessPoint &ap);