mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Make sure the item which was dragged to the dock can be show at once
tower: https://tower.im/projects/715dbdd34f694ea08f6de7888b7ffd7d/todos/b436910ef46f4c19a5b6e3734a3a8520/ Change-Id: I8c12679b29c0ba6dac35d9064a2c1edc6e393b62
This commit is contained in:
parent
6c89c17067
commit
293568b692
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004 Verified+1: <wangyanli@linuxdeepin.com> Code-Review+2: <mr.asianwang@gmail.com> Submitted-by: <mr.asianwang@gmail.com> Submitted-at: Fri, 06 Nov 2015 08:47:48 +0800 Reviewed-on: https://cr.deepin.io/8391 Project: dde/dde-dock Branch: refs/heads/master
@ -11,7 +11,7 @@ void AppManager::initEntries()
|
||||
{
|
||||
|
||||
LauncherItem * lItem = new LauncherItem();
|
||||
emit entryAdded(lItem);
|
||||
emit entryAdded(lItem, false);
|
||||
|
||||
QList<QDBusObjectPath> entryList = m_entryManager->entries();
|
||||
for (int i = 0; i < entryList.count(); i ++)
|
||||
@ -40,12 +40,21 @@ void AppManager::onEntryAdded(const QDBusObjectPath &path)
|
||||
item->deleteLater();
|
||||
}else{
|
||||
qWarning() << "entry add:" << tmpId;
|
||||
bool isTheDropOne = m_dockingItemId != tmpId;
|
||||
m_ids.append(tmpId);
|
||||
emit entryAdded(item);
|
||||
emit entryAdded(item, isTheDropOne);
|
||||
|
||||
if (isTheDropOne)
|
||||
setDockingItemId("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppManager::setDockingItemId(const QString &dockingItemId)
|
||||
{
|
||||
m_dockingItemId = dockingItemId;
|
||||
}
|
||||
|
||||
void AppManager::onEntryRemoved(const QString &id)
|
||||
{
|
||||
qWarning() << "entry remove:" << id;
|
||||
@ -61,10 +70,10 @@ void AppManager::sortItemList()
|
||||
foreach (QString id, dockedList) { //For docked items
|
||||
int index = tmpIds.indexOf(id);
|
||||
if (index != -1)
|
||||
emit entryAdded(m_initItemList.take(tmpIds.at(index)));
|
||||
emit entryAdded(m_initItemList.take(tmpIds.at(index)), false);
|
||||
}
|
||||
tmpIds = m_initItemList.keys();
|
||||
foreach (QString id, tmpIds) { //For undocked items
|
||||
emit entryAdded(m_initItemList.take(id));
|
||||
emit entryAdded(m_initItemList.take(id), false);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,10 @@ public:
|
||||
explicit AppManager(QObject *parent = 0);
|
||||
void initEntries();
|
||||
|
||||
void setDockingItemId(const QString &dockingItemId);
|
||||
|
||||
signals:
|
||||
void entryAdded(AbstractDockItem *item);
|
||||
void entryAdded(AbstractDockItem *item, bool delayShow);
|
||||
void entryRemoved(const QString &id);
|
||||
|
||||
private:
|
||||
@ -27,6 +29,7 @@ private:
|
||||
|
||||
private:
|
||||
QStringList m_ids;
|
||||
QString m_dockingItemId = ""; //drop to the dock one
|
||||
DBusEntryManager *m_entryManager = NULL;
|
||||
DBusDockedAppManager *m_dockAppManager = new DBusDockedAppManager(this);
|
||||
QMap<QString, AbstractDockItem *> m_initItemList; //Juse for initialization <id, item>
|
||||
|
@ -157,6 +157,9 @@ void Panel::initAppManager()
|
||||
m_appManager = new AppManager(this);
|
||||
connect(m_appManager, &AppManager::entryAdded, this, &Panel::onAppItemAdd);
|
||||
connect(m_appManager, &AppManager::entryRemoved, this, &Panel::onAppItemRemove);
|
||||
|
||||
//Make sure the item which was dragged to the dock can be show at once
|
||||
connect(m_appLayout, &DockLayout::itemDocking, m_appManager, &AppManager::setDockingItemId);
|
||||
}
|
||||
|
||||
void Panel::initReflection()
|
||||
@ -260,9 +263,9 @@ void Panel::onLayoutContentsWidthChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void Panel::onAppItemAdd(AbstractDockItem *item)
|
||||
void Panel::onAppItemAdd(AbstractDockItem *item, bool delayShow)
|
||||
{
|
||||
m_appLayout->addItem(item);
|
||||
m_appLayout->addItem(item, delayShow);
|
||||
connect(item, &AbstractDockItem::needPreviewShow, this, &Panel::onNeedPreviewShow);
|
||||
connect(item, &AbstractDockItem::needPreviewHide, this, &Panel::onNeedPreviewHide);
|
||||
connect(item, &AbstractDockItem::needPreviewImmediatelyHide, this, &Panel::onNeedPreviewImmediatelyHide);
|
||||
|
@ -59,7 +59,7 @@ private:
|
||||
void onItemDropped();
|
||||
void onItemDragStarted();
|
||||
void onLayoutContentsWidthChanged();
|
||||
void onAppItemAdd(AbstractDockItem *item);
|
||||
void onAppItemAdd(AbstractDockItem *item, bool delayShow);
|
||||
void onAppItemRemove(const QString &id);
|
||||
void onDockModeChanged(Dock::DockMode newMode, Dock::DockMode);
|
||||
void onHideStateChanged(int dockState);
|
||||
|
@ -10,15 +10,15 @@ DockLayout::DockLayout(QWidget *parent) :
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
void DockLayout::addItem(AbstractDockItem *item)
|
||||
void DockLayout::addItem(AbstractDockItem *item, bool delayShow)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
if (m_lastHoverIndex == -1)
|
||||
insertItem(item,m_appList.count());
|
||||
insertItem(item, m_appList.count(), delayShow);
|
||||
else
|
||||
insertItem(item, m_lastHoverIndex);
|
||||
insertItem(item, m_lastHoverIndex, delayShow);
|
||||
}
|
||||
|
||||
void DockLayout::insertItem(AbstractDockItem *item, int index, bool delayShow)
|
||||
@ -235,8 +235,12 @@ void DockLayout::dropEvent(QDropEvent *event)
|
||||
QJsonObject dataObj = QJsonDocument::fromJson(event->mimeData()->data("RequestDock")).object();
|
||||
if (dataObj.isEmpty() || m_ddam->IsDocked(dataObj.value("appKey").toString()))
|
||||
relayout();
|
||||
else
|
||||
else {
|
||||
m_ddam->ReqeustDock(dataObj.value("appKey").toString(), "", "", "");
|
||||
emit itemDocking(dataObj.value("appKey").toString());
|
||||
|
||||
qWarning() << "App drop to dock: " << dataObj.value("appKey").toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
restoreTmpItem();
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
explicit DockLayout(QWidget *parent = 0);
|
||||
|
||||
void addItem(AbstractDockItem *item);
|
||||
void addItem(AbstractDockItem *item, bool delayShow = true);
|
||||
void insertItem(AbstractDockItem *item, int index, bool delayShow = true);
|
||||
void moveItem(int from, int to);
|
||||
void removeItem(int index);
|
||||
@ -51,6 +51,7 @@ signals:
|
||||
void itemDropped();
|
||||
void contentsWidthChange();
|
||||
void frameUpdate();
|
||||
void itemDocking(QString id);
|
||||
void itemHoverableChange(bool hoverable);
|
||||
|
||||
public slots:
|
||||
|
Loading…
x
Reference in New Issue
Block a user