mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
support preview
Change-Id: I425bb6d6fe98d9b0f8906a5289fe1dafc9121cc7
This commit is contained in:
parent
aaf0dcb997
commit
4c4e0a0fb0
Notes:
Deepin Code Review
2017-04-27 14:47:52 +08:00
Code-Review+2: 石博文 <sbw@sbw.so> Verified+1: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Thu, 27 Apr 2017 14:47:48 +0800 Reviewed-on: https://cr.deepin.io/22545 Project: dde/dde-dock Branch: refs/heads/master
@ -182,6 +182,8 @@ DockItemController::DockItemController(QObject *parent)
|
||||
AppItem *it = new AppItem(entry);
|
||||
|
||||
connect(it, &AppItem::requestActivateWindow, m_appInter, &DBusDock::ActivateWindow);
|
||||
connect(it, &AppItem::requestPreviewWindow, m_appInter, &DBusDock::PreviewWindow);
|
||||
connect(it, &AppItem::requestCancelPreview, m_appInter, &DBusDock::CancelPreviewWindow);
|
||||
|
||||
m_itemList.append(it);
|
||||
}
|
||||
|
@ -110,12 +110,25 @@ public Q_SLOTS: // METHODS
|
||||
return asyncCallWithArgumentList(QStringLiteral("CloseWindow"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> PreviewWindow(uint in0)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(in0);
|
||||
return asyncCallWithArgumentList(QStringLiteral("PreviewWindow"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<QStringList> GetEntryIDs()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("GetEntryIDs"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<QStringList> CancelPreviewWindow()
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
return asyncCallWithArgumentList(QStringLiteral("CancelPreviewWindow"), argumentList);
|
||||
}
|
||||
|
||||
inline QDBusPendingReply<> MoveEntry(const int oldIndex, const int newIndex)
|
||||
{
|
||||
QList<QVariant> args;
|
||||
|
@ -64,12 +64,16 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
m_updateIconGeometryTimer->setInterval(500);
|
||||
m_updateIconGeometryTimer->setSingleShot(true);
|
||||
|
||||
m_appPreviewTips->setVisible(false);
|
||||
|
||||
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, &AppItem::activeChanged);
|
||||
connect(m_itemEntry, &DBusDockEntry::TitlesChanged, this, &AppItem::updateTitle);
|
||||
connect(m_itemEntry, &DBusDockEntry::IconChanged, this, &AppItem::refershIcon);
|
||||
connect(m_itemEntry, &DBusDockEntry::ActiveChanged, this, static_cast<void (AppItem::*)()>(&AppItem::update));
|
||||
|
||||
connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, this, &AppItem::requestActivateWindow);
|
||||
connect(m_appPreviewTips, &PreviewContainer::requestActivateWindow, this, &AppItem::requestActivateWindow, Qt::QueuedConnection);
|
||||
connect(m_appPreviewTips, &PreviewContainer::requestPreviewWindow, this, &AppItem::requestPreviewWindow, Qt::QueuedConnection);
|
||||
connect(m_appPreviewTips, &PreviewContainer::requestCancelPreview, this, &AppItem::requestCancelPreview, Qt::QueuedConnection);
|
||||
|
||||
updateTitle();
|
||||
refershIcon();
|
||||
@ -349,6 +353,17 @@ void AppItem::dragEnterEvent(QDragEnterEvent *e)
|
||||
e->accept();
|
||||
}
|
||||
|
||||
void AppItem::dragMoveEvent(QDragMoveEvent *e)
|
||||
{
|
||||
DockItem::dragMoveEvent(e);
|
||||
|
||||
if (m_titles.isEmpty())
|
||||
return;
|
||||
|
||||
if (!PopupWindow->isVisible() || PopupWindow->getContent() != m_appPreviewTips)
|
||||
showPreview();
|
||||
}
|
||||
|
||||
void AppItem::dropEvent(QDropEvent *e)
|
||||
{
|
||||
QStringList uriList;
|
||||
@ -436,6 +451,8 @@ void AppItem::updateTitle()
|
||||
{
|
||||
m_titles = m_itemEntry->titles();
|
||||
|
||||
m_appPreviewTips->setWindowInfos(m_titles);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@ -467,7 +484,7 @@ void AppItem::showPreview()
|
||||
// return hidePopup();
|
||||
|
||||
m_appPreviewTips->updateLayoutDirection(DockPosition);
|
||||
m_appPreviewTips->setWindowInfos(m_titles);
|
||||
// m_appPreviewTips->setWindowInfos(m_titles);
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
|
||||
signals:
|
||||
void requestActivateWindow(const WId wid) const;
|
||||
void requestPreviewWindow(const WId wid) const;
|
||||
void requestCancelPreview() const;
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
@ -37,6 +39,7 @@ private:
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void dragEnterEvent(QDragEnterEvent *e);
|
||||
void dragMoveEvent(QDragMoveEvent *e);
|
||||
void dropEvent(QDropEvent *e);
|
||||
|
||||
void showHoverTips();
|
||||
|
@ -13,6 +13,7 @@ PreviewContainer::PreviewContainer(QWidget *parent)
|
||||
m_windowListLayout->setSpacing(3);
|
||||
|
||||
setLayout(m_windowListLayout);
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void PreviewContainer::setWindowInfos(const WindowDict &infos)
|
||||
@ -30,6 +31,8 @@ void PreviewContainer::setWindowInfos(const WindowDict &infos)
|
||||
w->setTitle(it.value());
|
||||
|
||||
connect(w, &PreviewWidget::requestActivateWindow, this, &PreviewContainer::requestActivateWindow);
|
||||
connect(w, &PreviewWidget::requestPreviewWindow, this, &PreviewContainer::requestPreviewWindow);
|
||||
connect(w, &PreviewWidget::requestCancelPreview, this, &PreviewContainer::requestCancelPreview);
|
||||
|
||||
m_windowListLayout->addWidget(w);
|
||||
}
|
||||
@ -50,3 +53,18 @@ void PreviewContainer::updateLayoutDirection(const Dock::Position dockPos)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewContainer::leaveEvent(QEvent *e)
|
||||
{
|
||||
QWidget::leaveEvent(e);
|
||||
|
||||
QTimer::singleShot(1, this, &PreviewContainer::onMouseLeave);
|
||||
}
|
||||
|
||||
void PreviewContainer::onMouseLeave()
|
||||
{
|
||||
if (rect().contains(mapFromGlobal(QCursor::pos())))
|
||||
return;
|
||||
|
||||
emit requestCancelPreview();
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
|
||||
signals:
|
||||
void requestActivateWindow(const WId wid) const;
|
||||
void requestPreviewWindow(const WId wid) const;
|
||||
void requestCancelPreview() const;
|
||||
|
||||
public:
|
||||
void setWindowInfos(const WindowDict &infos);
|
||||
@ -23,6 +25,12 @@ public:
|
||||
public slots:
|
||||
void updateLayoutDirection(const Dock::Position dockPos);
|
||||
|
||||
protected:
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void onMouseLeave();
|
||||
|
||||
private:
|
||||
QBoxLayout *m_windowListLayout;
|
||||
};
|
||||
|
@ -32,10 +32,9 @@ PreviewWidget::PreviewWidget(const WId wid, QWidget *parent)
|
||||
|
||||
setFixedSize(W + M * 2, H + M * 2);
|
||||
setLayout(centralLayout);
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(m_closeButton, &QPushButton::clicked, this, &PreviewWidget::closeWindow);
|
||||
|
||||
QTimer::singleShot(1, this, &PreviewWidget::refershImage);
|
||||
}
|
||||
|
||||
void PreviewWidget::setTitle(const QString &title)
|
||||
@ -69,6 +68,14 @@ void PreviewWidget::closeWindow()
|
||||
XFlush(display);
|
||||
}
|
||||
|
||||
void PreviewWidget::setVisible(const bool visible)
|
||||
{
|
||||
QWidget::setVisible(visible);
|
||||
|
||||
if (visible)
|
||||
QTimer::singleShot(1, this, &PreviewWidget::refershImage);
|
||||
}
|
||||
|
||||
void PreviewWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
const QRect r = rect().marginsRemoved(QMargins(M, M, M, M));
|
||||
@ -112,6 +119,8 @@ void PreviewWidget::enterEvent(QEvent *e)
|
||||
update();
|
||||
|
||||
QWidget::enterEvent(e);
|
||||
|
||||
emit requestPreviewWindow(m_wid);
|
||||
}
|
||||
|
||||
void PreviewWidget::leaveEvent(QEvent *e)
|
||||
@ -128,5 +137,14 @@ void PreviewWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mouseReleaseEvent(e);
|
||||
|
||||
emit requestHidePopup();
|
||||
emit requestCancelPreview();
|
||||
emit requestActivateWindow(m_wid);
|
||||
}
|
||||
|
||||
void PreviewWidget::dragEnterEvent(QDragEnterEvent *e)
|
||||
{
|
||||
QWidget::dragEnterEvent(e);
|
||||
|
||||
emit requestActivateWindow(m_wid);
|
||||
}
|
||||
|
@ -15,16 +15,21 @@ public:
|
||||
|
||||
signals:
|
||||
void requestActivateWindow(const WId wid) const;
|
||||
void requestPreviewWindow(const WId wid) const;
|
||||
void requestCancelPreview() const;
|
||||
void requestHidePopup() const;
|
||||
|
||||
private slots:
|
||||
void refershImage();
|
||||
void closeWindow();
|
||||
void setVisible(const bool visible);
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void enterEvent(QEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void dragEnterEvent(QDragEnterEvent *e);
|
||||
|
||||
private:
|
||||
const WId m_wid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user