diff --git a/frame/controller/dockpluginscontroller.cpp b/frame/controller/dockpluginscontroller.cpp index 94a818206..6c7737498 100644 --- a/frame/controller/dockpluginscontroller.cpp +++ b/frame/controller/dockpluginscontroller.cpp @@ -55,11 +55,6 @@ void DockPluginsController::itemRemoved(PluginsItemInterface * const itemInter, item->deleteLater(); } -void DockPluginsController::setDockAutoHide(const bool autoHide) -{ - Q_UNUSED(autoHide); -} - //void DockPluginsController::requestPopupApplet(PluginsItemInterface * const itemInter, const QString &itemKey) //{ // PluginsItem *item = pluginItemAt(itemInter, itemKey); diff --git a/frame/controller/dockpluginscontroller.h b/frame/controller/dockpluginscontroller.h index 6bc54a230..dfc157b85 100644 --- a/frame/controller/dockpluginscontroller.h +++ b/frame/controller/dockpluginscontroller.h @@ -22,7 +22,6 @@ public: void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey); void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey); void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey); - void setDockAutoHide(const bool autoHide); signals: void pluginItemInserted(PluginsItem *pluginItem) const; diff --git a/frame/frame.pro b/frame/frame.pro index c2bf2f4c3..585e43201 100644 --- a/frame/frame.pro +++ b/frame/frame.pro @@ -29,7 +29,8 @@ SOURCES += main.cpp \ dbus/dbusmenu.cpp \ item/pluginsitem.cpp \ controller/dockpluginscontroller.cpp \ - util/imagefactory.cpp + util/imagefactory.cpp \ + util/dockpopupwindow.cpp HEADERS += \ window/mainwindow.h \ @@ -50,7 +51,8 @@ HEADERS += \ dbus/dbusmenu.h \ item/pluginsitem.h \ controller/dockpluginscontroller.h \ - util/imagefactory.h + util/imagefactory.h \ + util/dockpopupwindow.h dbus_service.files += com.deepin.dde.dock.service dbus_service.path = /usr/share/dbus-1/services diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index 59e29c83f..fa59f37c3 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -8,7 +8,7 @@ Position DockItem::DockPosition = Position::Top; DisplayMode DockItem::DockDisplayMode = DisplayMode::Efficient; -std::unique_ptr DockItem::PopupTips(nullptr); +std::unique_ptr DockItem::PopupWindow(nullptr); DockItem::DockItem(const ItemType type, QWidget *parent) : QWidget(parent), @@ -19,17 +19,17 @@ DockItem::DockItem(const ItemType type, QWidget *parent) m_menuManagerInter(new DBusMenuManager(this)) { - if (!PopupTips.get()) + if (!PopupWindow.get()) { - DArrowRectangle *arrowRectangle = new DArrowRectangle(DArrowRectangle::ArrowBottom, nullptr); + DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr); arrowRectangle->setShadowBlurRadius(0); - PopupTips.reset(arrowRectangle); + PopupWindow.reset(arrowRectangle); } m_popupTipsDelayTimer->setInterval(200); m_popupTipsDelayTimer->setSingleShot(true); - connect(m_popupTipsDelayTimer, &QTimer::timeout, this, &DockItem::showPopupTips); + connect(m_popupTipsDelayTimer, &QTimer::timeout, this, &DockItem::showHoverTips); } void DockItem::setDockPosition(const Position side) @@ -80,7 +80,7 @@ void DockItem::leaveEvent(QEvent *e) m_hover = false; m_popupTipsDelayTimer->stop(); - PopupTips->hide(); + PopupWindow->hide(); update(); @@ -141,31 +141,36 @@ void DockItem::showContextMenu() menuInter->ShowMenu(QString(QJsonDocument(menuObject).toJson())); } -void DockItem::showPopupTips() +void DockItem::showHoverTips() { QWidget * const content = popupTips(); if (!content) return; - DArrowRectangle *tips = PopupTips.get(); - QWidget *lastContent = tips->getContent(); + showPopupWindow(content); +} + +void DockItem::showPopupWindow(QWidget *content, const bool model) +{ + DockPopupWindow *popup = PopupWindow.get(); + QWidget *lastContent = popup->getContent(); if (lastContent) lastContent->hide(); switch (DockPosition) { - case Top: tips->setArrowDirection(DArrowRectangle::ArrowTop); break; - case Bottom:tips->setArrowDirection(DArrowRectangle::ArrowBottom); break; - case Left: tips->setArrowDirection(DArrowRectangle::ArrowLeft); break; - case Right: tips->setArrowDirection(DArrowRectangle::ArrowRight); break; + case Top: popup->setArrowDirection(DockPopupWindow::ArrowTop); break; + case Bottom:popup->setArrowDirection(DockPopupWindow::ArrowBottom); break; + case Left: popup->setArrowDirection(DockPopupWindow::ArrowLeft); break; + case Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break; } - tips->setContent(content); - tips->setMargin(5); - tips->setWidth(content->sizeHint().width()); - tips->setHeight(content->sizeHint().height()); + popup->setContent(content); + popup->setMargin(5); + popup->setWidth(content->sizeHint().width()); + popup->setHeight(content->sizeHint().height()); const QPoint p = popupMarkPoint(); - tips->show(p.x(), p.y()); + popup->show(p, model); } void DockItem::invokedMenuItem(const QString &itemId, const bool checked) diff --git a/frame/item/dockitem.h b/frame/item/dockitem.h index 8dd501a2b..8c4fc4abf 100644 --- a/frame/item/dockitem.h +++ b/frame/item/dockitem.h @@ -2,15 +2,12 @@ #define DOCKITEM_H #include "constants.h" +#include "util/dockpopupwindow.h" #include -#include - #include -DWIDGET_USE_NAMESPACE - using namespace Dock; class DBusMenuManager; @@ -48,7 +45,8 @@ protected: const QPoint popupMarkPoint(); void showContextMenu(); - void showPopupTips(); + void showHoverTips(); + void showPopupWindow(QWidget *content, const bool model = false); virtual void invokedMenuItem(const QString &itemId, const bool checked); virtual const QString contextMenu() const; virtual QWidget *popupTips(); @@ -63,7 +61,7 @@ protected: static Position DockPosition; static DisplayMode DockDisplayMode; - static std::unique_ptr PopupTips; + static std::unique_ptr PopupWindow; }; #endif // DOCKITEM_H diff --git a/frame/item/pluginsitem.cpp b/frame/item/pluginsitem.cpp index 2b205ce03..d26832e9f 100644 --- a/frame/item/pluginsitem.cpp +++ b/frame/item/pluginsitem.cpp @@ -135,12 +135,19 @@ void PluginsItem::startDrag() void PluginsItem::mouseClicked() { const QString command = m_pluginInter->itemCommand(m_itemKey); - if (command.isEmpty()) + if (!command.isEmpty()) + { + QProcess *proc = new QProcess(this); + + connect(proc, static_cast(&QProcess::finished), proc, &QProcess::deleteLater); + + proc->startDetached(command); return; + } - QProcess *proc = new QProcess(this); - - connect(proc, static_cast(&QProcess::finished), proc, &QProcess::deleteLater); - - proc->startDetached(command); + // request popup applet + QWidget *w = m_pluginInter->itemPopupApplet(m_itemKey); + qDebug() << w; + if (w) + showPopupWindow(w, true); } diff --git a/frame/util/dockpopupwindow.cpp b/frame/util/dockpopupwindow.cpp new file mode 100644 index 000000000..7d1d328d8 --- /dev/null +++ b/frame/util/dockpopupwindow.cpp @@ -0,0 +1,22 @@ +#include "dockpopupwindow.h" + +DWIDGET_USE_NAMESPACE + +DockPopupWindow::DockPopupWindow(QWidget *parent) + : DArrowRectangle(ArrowBottom, parent), + m_model(false) +{ + +} + +bool DockPopupWindow::model() const +{ + return m_model; +} + +void DockPopupWindow::show(const QPoint &pos, const bool model) +{ + m_model = model; + + DArrowRectangle::show(pos.x(), pos.y()); +} diff --git a/frame/util/dockpopupwindow.h b/frame/util/dockpopupwindow.h new file mode 100644 index 000000000..94f0054a8 --- /dev/null +++ b/frame/util/dockpopupwindow.h @@ -0,0 +1,21 @@ +#ifndef DOCKPOPUPWINDOW_H +#define DOCKPOPUPWINDOW_H + +#include + +class DockPopupWindow : public Dtk::Widget::DArrowRectangle +{ + Q_OBJECT + +public: + explicit DockPopupWindow(QWidget *parent = 0); + + bool model() const; + + void show(const QPoint &pos, const bool model = false); + +private: + bool m_model; +}; + +#endif // DOCKPOPUPWINDOW_H diff --git a/interfaces/pluginproxyinterface.h b/interfaces/pluginproxyinterface.h index 302f7aa11..872a69471 100644 --- a/interfaces/pluginproxyinterface.h +++ b/interfaces/pluginproxyinterface.h @@ -12,7 +12,6 @@ public: virtual void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey) = 0; virtual void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey) = 0; virtual void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey) = 0; - virtual void setDockAutoHide(const bool autoHide) = 0; }; #endif // PLUGINPROXYINTERFACE_H diff --git a/plugins/system-tray/fashiontrayitem.cpp b/plugins/system-tray/fashiontrayitem.cpp index fa4c800ca..ec445bdd1 100644 --- a/plugins/system-tray/fashiontrayitem.cpp +++ b/plugins/system-tray/fashiontrayitem.cpp @@ -67,7 +67,8 @@ void FashionTrayItem::mousePressEvent(QMouseEvent *e) void FashionTrayItem::mouseReleaseEvent(QMouseEvent *e) { - Q_UNUSED(e); + QWidget::mouseReleaseEvent(e); + const QPoint point = e->pos() - m_pressPoint; if (point.manhattanLength() > DRAG_THRESHOLD)