mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add popup window
Change-Id: I27dbba9bfb4823a530499aa65cbad7e6d181c055
This commit is contained in:
parent
b5543494ba
commit
6372853152
@ -80,7 +80,9 @@ void DockItem::leaveEvent(QEvent *e)
|
||||
m_hover = false;
|
||||
m_popupTipsDelayTimer->stop();
|
||||
|
||||
PopupWindow->hide();
|
||||
// auto hide if popup is not model window
|
||||
if (!PopupWindow->model())
|
||||
PopupWindow->hide();
|
||||
|
||||
update();
|
||||
|
||||
@ -135,7 +137,7 @@ void DockItem::showContextMenu()
|
||||
DBusMenu *menuInter = new DBusMenu(path.path(), this);
|
||||
|
||||
connect(menuInter, &DBusMenu::ItemInvoked, this, &DockItem::invokedMenuItem);
|
||||
connect(menuInter, &DBusMenu::MenuUnregistered, this, &DockItem::menuUnregistered);
|
||||
connect(menuInter, &DBusMenu::MenuUnregistered, this, &DockItem::requestRefershWindowVisible);
|
||||
connect(menuInter, &DBusMenu::MenuUnregistered, menuInter, &DBusMenu::deleteLater, Qt::QueuedConnection);
|
||||
|
||||
menuInter->ShowMenu(QString(QJsonDocument(menuObject).toJson()));
|
||||
@ -143,6 +145,10 @@ void DockItem::showContextMenu()
|
||||
|
||||
void DockItem::showHoverTips()
|
||||
{
|
||||
// another model popup window is alread exists
|
||||
if (PopupWindow->isVisible() && PopupWindow->model())
|
||||
return;
|
||||
|
||||
QWidget * const content = popupTips();
|
||||
if (!content)
|
||||
return;
|
||||
@ -150,8 +156,11 @@ void DockItem::showHoverTips()
|
||||
showPopupWindow(content);
|
||||
}
|
||||
|
||||
void DockItem::showPopupWindow(QWidget *content, const bool model)
|
||||
void DockItem::showPopupWindow(QWidget * const content, const bool model)
|
||||
{
|
||||
if (model)
|
||||
emit requestWindowAutoHide(false);
|
||||
|
||||
DockPopupWindow *popup = PopupWindow.get();
|
||||
QWidget *lastContent = popup->getContent();
|
||||
if (lastContent)
|
||||
@ -173,6 +182,16 @@ void DockItem::showPopupWindow(QWidget *content, const bool model)
|
||||
popup->show(p, model);
|
||||
}
|
||||
|
||||
void DockItem::popupWindowAccept()
|
||||
{
|
||||
if (!PopupWindow->isVisible())
|
||||
return;
|
||||
|
||||
PopupWindow->hide();
|
||||
|
||||
emit requestWindowAutoHide(true);
|
||||
}
|
||||
|
||||
void DockItem::invokedMenuItem(const QString &itemId, const bool checked)
|
||||
{
|
||||
Q_UNUSED(itemId)
|
||||
|
@ -32,7 +32,8 @@ public:
|
||||
|
||||
signals:
|
||||
void dragStarted() const;
|
||||
void menuUnregistered() const;
|
||||
void requestWindowAutoHide(const bool autoHide) const;
|
||||
void requestRefershWindowVisible() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
@ -46,7 +47,8 @@ protected:
|
||||
|
||||
void showContextMenu();
|
||||
void showHoverTips();
|
||||
void showPopupWindow(QWidget *content, const bool model = false);
|
||||
void showPopupWindow(QWidget * const content, const bool model = false);
|
||||
void popupWindowAccept();
|
||||
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
||||
virtual const QString contextMenu() const;
|
||||
virtual QWidget *popupTips();
|
||||
|
@ -147,7 +147,6 @@ void PluginsItem::mouseClicked()
|
||||
|
||||
// request popup applet
|
||||
QWidget *w = m_pluginInter->itemPopupApplet(m_itemKey);
|
||||
qDebug() << w;
|
||||
if (w)
|
||||
showPopupWindow(w, true);
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ void MainPanel::dropEvent(QDropEvent *e)
|
||||
void MainPanel::initItemConnection(DockItem *item)
|
||||
{
|
||||
connect(item, &DockItem::dragStarted, this, &MainPanel::itemDragStarted);
|
||||
connect(item, &DockItem::menuUnregistered, this, &MainPanel::requestRefershWindowVisible);
|
||||
connect(item, &DockItem::requestRefershWindowVisible, this, &MainPanel::requestRefershWindowVisible);
|
||||
connect(item, &DockItem::requestWindowAutoHide, this, &MainPanel::requestWindowAutoHide);
|
||||
}
|
||||
|
||||
DockItem *MainPanel::itemAt(const QPoint &point)
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
int position();
|
||||
|
||||
signals:
|
||||
void requestWindowAutoHide(const bool autoHide) const;
|
||||
void requestRefershWindowVisible() const;
|
||||
|
||||
private:
|
||||
|
@ -125,6 +125,7 @@ void MainWindow::initConnections()
|
||||
connect(m_settings, &DockSettings::autoHideChanged, this, &MainWindow::updatePanelVisible);
|
||||
|
||||
connect(m_mainPanel, &MainPanel::requestRefershWindowVisible, this, &MainWindow::updatePanelVisible, Qt::QueuedConnection);
|
||||
connect(m_mainPanel, &MainPanel::requestWindowAutoHide, m_settings, &DockSettings::setAutoHide);
|
||||
|
||||
connect(m_positionUpdateTimer, &QTimer::timeout, this, &MainWindow::updatePosition, Qt::QueuedConnection);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user