让Dock中的窗口预览(Aero Peek的效果)动态更新
Tofloor
poster avatar
quadpixels
deepin
2017-12-05 12:10
Author
本帖最后由 quadpixels 于 2017-12-5 04:30 编辑

大家好啊,啊哈
不知道为何dde-dock的Aero Peek效果不是动态的。但是其实做点小小的修改就能变成动态的。就是以下这样:

目前的效果(版本 4.5.7):
预览中的齿轮不转




改了之后的效果
预览中的齿轮会转


其实只要做一丁点改动就可以了:

1. 在frame/item/appItem.h中添加一个定时器和一个函数

(从第102行起)
   QTimer *m_updateIconGeometryTimer,
       *m_updateSnapshotsTimer;

(从第27行起)
public:
    explicit AppItem(const QDBusObjectPath &entry, QWidget *parent = nullptr);
    ~AppItem();
    const QString appId() const;
    void updateWindowIconGeometries();
    void updateSnapshots();
    static void setIconBaseSize(const int size);
    ...


2. 在frame/item/appItem.cpp中初始化这个定时器,并且让这定时器在showPopup()被调用时启动,在hidePopup()被调用时停用就好了
    (第61行起)
          m_horizontalIndicator(QPixmap(":/indicator/resources/indicator.png")),
          m_verticalIndicator(QPixmap(":/indicator/resources/indicator_ver.png")),
          m_activeHorizontalIndicator(QPixmap(":/indicator/resources/indicator_active.png")),
          m_activeVerticalIndicator(QPixmap(":/indicator/resources/indicator_active_ver.png")),
          m_updateIconGeometryTimer(new QTimer(this)),
          m_updateSnapshotsTimer(new QTimer(this)),

    (第100行起)
        m_updateIconGeometryTimer->setInterval(500);
        m_updateIconGeometryTimer->setSingleShot(true);
        m_updateSnapshotsTimer->setInterval(16);
         connect(m_updateSnapshotsTimer, &QTimer::timeout, this, &AppItem::updateSnapshots,            
           Qt:ueuedConnection);


    (第352行起)
    void AppItem::mousePressEvent(QMouseEvent *e)
    {
        m_updateIconGeometryTimer->stop();
        m_updateSnapshotsTimer->stop();
        hidePopup();


    (第562行起)
        m_appPreviewTips->setWindowInfos(m_titles);
        m_appPreviewTips->updateSnapshots();
        m_appPreviewTips->updateLayoutDirection(DockPosition);
        m_updateSnapshotsTimer->start();
        showPopupWindow(m_appPreviewTips, true);
    }

    void AppItem::cancelAndHidePreview()
    {
        m_updateSnapshotsTimer->stop();
        hidePopup();
        emit requestCancelPreview();
    }

    (加在最末)
    void AppItem::updateSnapshots() {
       if (m_titles.empty()) return;
         m_appPreviewTips->updateSnapshots();
    }




于是就能看见Aero Peek效果中的齿轮也动起来噜 XD
谢谢收看
Reply Favorite View the author
All Replies
avatar
sysop
deepin
2017-12-05 16:32
#1
可能考虑性能吧
动态好看是好看了 可能会卡







    神奇的小尾巴:Mozilla/5.0 (Wayland; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0  (zh-CN)
    ——2017/12/5 上午8:32:39
             
    Reply View the author
    Comments
    quadpixels
    2017-12-05 20:58
    有道理!不过Alt Tab的预览也是实时的说!
    avatar
    justforlxz
    deepin
    2017-12-05 17:16
    #2
      这都被你发现了
    Reply View the author
    avatar
    luxwen
    deepin
    2017-12-05 17:18
    #3
    看视频的时候,在dock上动态预览比较方便
    Reply View the author