mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: dock hide problem and remove old imp
efficient dock still hide in auto/smart hide mode while applet of plugins is showing and mouse leaved https://github.com/linuxdeepin/developer-center/issues/707 Change-Id: I373ce94e802f79e1430a636d5019b24fdbaa650b
This commit is contained in:
parent
90e2e29aa6
commit
091b52bccd
Notes:
gerrit
2018-12-05 11:40:54 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Wed, 05 Dec 2018 11:40:54 +0800 Reviewed-on: https://cr.deepin.io/40234 Project: dde/dde-dock Branch: refs/heads/dev/fix-dock-hidden
@ -94,19 +94,6 @@ void DockPluginsController::itemRemoved(PluginsItemInterface * const itemInter,
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
//void DockPluginsController::requestRefershWindowVisible()
|
||||
//{
|
||||
// for (auto list : m_pluginList.values())
|
||||
// {
|
||||
// for (auto item : list.values())
|
||||
// {
|
||||
// Q_ASSERT(item);
|
||||
// emit item->requestRefershWindowVisible();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void DockPluginsController::requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
@ -115,13 +102,21 @@ void DockPluginsController::requestContextMenu(PluginsItemInterface * const item
|
||||
item->showContextMenu();
|
||||
}
|
||||
|
||||
//void DockPluginsController::requestPopupApplet(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
//{
|
||||
// PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
void DockPluginsController::requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
// Q_ASSERT(item);
|
||||
// item->showPopupApplet();
|
||||
//}
|
||||
Q_EMIT item->requestWindowAutoHide(autoHide);
|
||||
}
|
||||
|
||||
void DockPluginsController::requestRefershWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
PluginsItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
Q_EMIT item->requestRefershWindowVisible();
|
||||
}
|
||||
|
||||
void DockPluginsController::startLoader()
|
||||
{
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) Q_DECL_OVERRIDE;
|
||||
void requestRefershWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void saveValue(PluginsItemInterface *const itemInter, const QString &itemKey, const QVariant &value);
|
||||
const QVariant getValue(PluginsItemInterface *const itemInter, const QString &itemKey, const QVariant& failback = QVariant());
|
||||
|
||||
|
@ -51,10 +51,6 @@ bool TrayPluginItem::eventFilter(QObject *watched, QEvent *e)
|
||||
const QString &propertyName = static_cast<QDynamicPropertyChangeEvent *>(e)->propertyName();
|
||||
if (propertyName == "FashionTraySize") {
|
||||
Q_EMIT fashionTraySizeChanged(watched->property("FashionTraySize").toSize());
|
||||
} else if (propertyName == "RequestWindowAutoHide") {
|
||||
Q_EMIT requestWindowAutoHide(watched->property("RequestWindowAutoHide").toBool());
|
||||
} else if (propertyName == "RequestRefershWindowVisible") {
|
||||
Q_EMIT requestRefershWindowVisible();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,9 @@ public:
|
||||
///
|
||||
virtual void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
|
||||
virtual void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) = 0;
|
||||
virtual void requestRefershWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) = 0;
|
||||
|
||||
///
|
||||
/// \brief saveValue
|
||||
/// save module config to .config/deepin/dde-dock.conf
|
||||
|
@ -46,6 +46,8 @@ Q_SIGNALS:
|
||||
void iconChanged();
|
||||
void clicked();
|
||||
void needAttention();
|
||||
void requestWindowAutoHide(const bool autoHide);
|
||||
void requestRefershWindowVisible();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
@ -122,12 +122,6 @@ void FashionTrayItem::trayWidgetAdded(const QString &itemKey, AbstractTrayWidget
|
||||
connect(wrapper, &FashionTrayWidgetWrapper::dragStop, this, &FashionTrayItem::onItemDragStop, Qt::UniqueConnection);
|
||||
connect(wrapper, &FashionTrayWidgetWrapper::requestSwapWithDragging, this, &FashionTrayItem::onItemRequestSwapWithDragging, Qt::UniqueConnection);
|
||||
|
||||
if (trayWidget->trayTyep() == AbstractTrayWidget::TrayType::SystemTray) {
|
||||
SystemTrayItem * sysTrayWidget = static_cast<SystemTrayItem *>(trayWidget);
|
||||
connect(sysTrayWidget, &SystemTrayItem::requestWindowAutoHide, this, &FashionTrayItem::requestWindowAutoHide, Qt::UniqueConnection);
|
||||
connect(sysTrayWidget, &SystemTrayItem::requestRefershWindowVisible, this, &FashionTrayItem::requestRefershWindowVisible, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
requestResize();
|
||||
}
|
||||
|
||||
@ -604,22 +598,6 @@ void FashionTrayItem::switchAttionTray(FashionTrayWidgetWrapper *attentionWrappe
|
||||
m_currentAttentionTray = attentionWrapper;
|
||||
}
|
||||
|
||||
void FashionTrayItem::requestWindowAutoHide(const bool autoHide)
|
||||
{
|
||||
// reset property "RequestWindowAutoHide" to EMIT the signal of DockItem
|
||||
// TODO: 考虑新增插件接口
|
||||
|
||||
setProperty("RequestWindowAutoHide", autoHide);
|
||||
}
|
||||
|
||||
void FashionTrayItem::requestRefershWindowVisible()
|
||||
{
|
||||
// reset property "RequestRefershWindowVisible" to EMIT the signal of DockItem
|
||||
// TODO: 考虑新增插件接口
|
||||
|
||||
setProperty("RequestRefershWindowVisible", !property("RequestRefershWindowVisible").toBool());
|
||||
}
|
||||
|
||||
void FashionTrayItem::refreshTraysVisible()
|
||||
{
|
||||
const bool expand = m_controlWidget->expanded();
|
||||
|
@ -77,8 +77,6 @@ private Q_SLOTS:
|
||||
void moveOutAttionTray();
|
||||
void moveInAttionTray();
|
||||
void switchAttionTray(FashionTrayWidgetWrapper *attentionWrapper);
|
||||
void requestWindowAutoHide(const bool autoHide);
|
||||
void requestRefershWindowVisible();
|
||||
void refreshTraysVisible();
|
||||
void onItemDragStart();
|
||||
void onItemDragStop();
|
||||
|
@ -54,9 +54,9 @@ public:
|
||||
QWidget *centralWidget() const;
|
||||
void detachPluginWidget();
|
||||
|
||||
Q_SIGNALS:
|
||||
void requestWindowAutoHide(const bool autoHide) const;
|
||||
void requestRefershWindowVisible() const;
|
||||
//Q_SIGNALS:
|
||||
// void requestWindowAutoHide(const bool autoHide) const;
|
||||
// void requestRefershWindowVisible() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
@ -88,7 +88,23 @@ void SystemTraysController::requestContextMenu(PluginsItemInterface * const item
|
||||
SystemTrayItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
// item->showContextMenu();
|
||||
// item->showContextMenu();
|
||||
}
|
||||
|
||||
void SystemTraysController::requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide)
|
||||
{
|
||||
SystemTrayItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
Q_EMIT item->requestWindowAutoHide(autoHide);
|
||||
}
|
||||
|
||||
void SystemTraysController::requestRefershWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
SystemTrayItem *item = pluginItemAt(itemInter, itemKey);
|
||||
Q_ASSERT(item);
|
||||
|
||||
Q_EMIT item->requestRefershWindowVisible();
|
||||
}
|
||||
|
||||
void SystemTraysController::startLoader()
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
void itemUpdate(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void itemRemoved(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void requestContextMenu(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
void requestWindowAutoHide(PluginsItemInterface * const itemInter, const QString &itemKey, const bool autoHide) Q_DECL_OVERRIDE;
|
||||
void requestRefershWindowVisible(PluginsItemInterface * const itemInter, const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void saveValue(PluginsItemInterface *const itemInter, const QString &key, const QVariant &value);
|
||||
const QVariant getValue(PluginsItemInterface *const itemInter, const QString &key, const QVariant& failback = QVariant());
|
||||
|
||||
|
@ -246,6 +246,19 @@ bool TrayPlugin::isSystemTrayItem(const QString &itemKey)
|
||||
return false;
|
||||
}
|
||||
|
||||
QString TrayPlugin::itemKeyOfTrayWidget(AbstractTrayWidget *trayWidget)
|
||||
{
|
||||
QString itemKey;
|
||||
|
||||
if (displayMode() == Dock::DisplayMode::Fashion) {
|
||||
itemKey = FASHION_MODE_ITEM;
|
||||
} else {
|
||||
itemKey = m_trayMap.key(trayWidget);
|
||||
}
|
||||
|
||||
return itemKey;
|
||||
}
|
||||
|
||||
void TrayPlugin::sniItemsChanged()
|
||||
{
|
||||
const QStringList &itemServicePaths = m_sniWatcher->RegisteredStatusNotifierItems();
|
||||
@ -289,6 +302,15 @@ void TrayPlugin::addTrayWidget(const QString &itemKey, AbstractTrayWidget *trayW
|
||||
return;
|
||||
}
|
||||
|
||||
connect(trayWidget, &AbstractTrayWidget::requestWindowAutoHide, this, [=](const bool autoHide) {
|
||||
const QString &key = displayMode() == Dock::DisplayMode::Fashion ? FASHION_MODE_ITEM : itemKey;
|
||||
m_proxyInter->requestWindowAutoHide(this, key, autoHide);
|
||||
}, Qt::UniqueConnection);
|
||||
connect(trayWidget, &AbstractTrayWidget::requestRefershWindowVisible, this, [=] {
|
||||
const QString &key = displayMode() == Dock::DisplayMode::Fashion ? FASHION_MODE_ITEM : itemKey;
|
||||
m_proxyInter->requestRefershWindowVisible(this, key);
|
||||
}, Qt::UniqueConnection);
|
||||
|
||||
if (!m_trayMap.values().contains(trayWidget)) {
|
||||
m_trayMap.insert(itemKey, trayWidget);
|
||||
}
|
||||
@ -403,6 +425,28 @@ void TrayPlugin::switchToMode(const Dock::DisplayMode mode)
|
||||
}
|
||||
}
|
||||
|
||||
void TrayPlugin::onRequestWindowAutoHide(const bool autoHide)
|
||||
{
|
||||
const QString &itemKey = itemKeyOfTrayWidget(static_cast<AbstractTrayWidget *>(sender()));
|
||||
|
||||
if (itemKey.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_proxyInter->requestWindowAutoHide(this, itemKey, autoHide);
|
||||
}
|
||||
|
||||
void TrayPlugin::onRequestRefershWindowVisible()
|
||||
{
|
||||
const QString &itemKey = itemKeyOfTrayWidget(static_cast<AbstractTrayWidget *>(sender()));
|
||||
|
||||
if (itemKey.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_proxyInter->requestRefershWindowVisible(this, itemKey);
|
||||
}
|
||||
|
||||
void TrayPlugin::loadIndicator()
|
||||
{
|
||||
QDir indicatorConfDir("/etc/dde-dock/indicator");
|
||||
|
@ -69,6 +69,7 @@ private:
|
||||
void loadIndicator();
|
||||
const QString getWindowClass(quint32 winId);
|
||||
bool isSystemTrayItem(const QString &itemKey);
|
||||
QString itemKeyOfTrayWidget(AbstractTrayWidget *trayWidget);
|
||||
|
||||
private slots:
|
||||
void addTrayWidget(const QString &itemKey, AbstractTrayWidget *trayWidget);
|
||||
@ -79,6 +80,8 @@ private slots:
|
||||
void trayChanged(quint32 winId);
|
||||
void sniItemIconChanged();
|
||||
void switchToMode(const Dock::DisplayMode mode);
|
||||
void onRequestWindowAutoHide(const bool autoHide);
|
||||
void onRequestRefershWindowVisible();
|
||||
|
||||
private:
|
||||
DBusTrayManager *m_trayInter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user