mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: 修复从托盘拖动应用到任务栏上面图标显示异常的问题
将图标从托盘拖动到任务栏上面的时候,会将信息保存到DConfig配置,触发任务栏上多次添加图标的功能,引起图标重复 Log: 修复从托盘拖动应用到任务栏上图标显示异常 Influence: 将安全中心等图标从托盘拖动到任务栏,观察图标是否重复 Bug: https://pms.uniontech.com/bug-view-171493.html Change-Id: I15b85b8192e7e7cca0f563f9ecc6381cd616f0ee
This commit is contained in:
parent
9abab8ed1b
commit
e98f1df2f5
@ -30,7 +30,6 @@
|
|||||||
#define ICON_SIZE 16
|
#define ICON_SIZE 16
|
||||||
#define ITEM_SPACING 5
|
#define ITEM_SPACING 5
|
||||||
|
|
||||||
struct WinInfo;
|
|
||||||
class ExpandIconWidget;
|
class ExpandIconWidget;
|
||||||
class QListView;
|
class QListView;
|
||||||
class PluginsItemInterface;
|
class PluginsItemInterface;
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "tray_gridview.h"
|
#include "tray_gridview.h"
|
||||||
#include "settingconfig.h"
|
#include "settingconfig.h"
|
||||||
|
#include "expandiconwidget.h"
|
||||||
|
#include "tray_model.h"
|
||||||
|
#include "basetraywidget.h"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
@ -33,9 +36,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "tray_model.h"
|
|
||||||
#include "basetraywidget.h"
|
|
||||||
|
|
||||||
TrayGridView::TrayGridView(QWidget *parent)
|
TrayGridView::TrayGridView(QWidget *parent)
|
||||||
: DListView(parent)
|
: DListView(parent)
|
||||||
, m_aniCurveType(QEasingCurve::Linear)
|
, m_aniCurveType(QEasingCurve::Linear)
|
||||||
@ -516,6 +516,14 @@ bool TrayGridView::beginDrag(Qt::DropActions supportedActions)
|
|||||||
} else {
|
} else {
|
||||||
listModel->setDragKey(QString());
|
listModel->setDragKey(QString());
|
||||||
clearDragModelIndex();
|
clearDragModelIndex();
|
||||||
|
if (listModel->isIconTray()) {
|
||||||
|
// 如果当前是从托盘移动到任务栏,则根据托盘内部是否有应用来决定是否显示展开图标
|
||||||
|
bool hasIcon = (listModel->rowCount() > 0);
|
||||||
|
TrayModel::getDockModel()->setExpandVisible(hasIcon, hasIcon);
|
||||||
|
// 如果没有图标,则隐藏托盘图标
|
||||||
|
if (!hasIcon)
|
||||||
|
ExpandIconWidget::popupTrayView()->hide();
|
||||||
|
}
|
||||||
|
|
||||||
m_dropPos = QPoint();
|
m_dropPos = QPoint();
|
||||||
m_dragPos = QPoint();
|
m_dragPos = QPoint();
|
||||||
|
@ -148,9 +148,11 @@ void TrayModel::setExpandVisible(bool visible, bool openExpand)
|
|||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
// 如果展开图标已经存在,则不添加,
|
// 如果展开图标已经存在,则不添加,
|
||||||
for (const WinInfo &winInfo : m_winInfos) {
|
for (WinInfo &winInfo : m_winInfos) {
|
||||||
if (winInfo.type == TrayIconType::ExpandIcon)
|
if (winInfo.type == TrayIconType::ExpandIcon) {
|
||||||
|
winInfo.expand = openExpand;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 如果是任务栏图标,则添加托盘展开图标
|
// 如果是任务栏图标,则添加托盘展开图标
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
@ -431,14 +433,24 @@ bool TrayModel::isTypeWriting(const QString &servicePath) const
|
|||||||
|
|
||||||
void TrayModel::saveConfig(int index, const WinInfo &winInfo)
|
void TrayModel::saveConfig(int index, const WinInfo &winInfo)
|
||||||
{
|
{
|
||||||
if (m_fixedTrayNames.contains(winInfo.itemKey))
|
if (m_isTrayIcon) {
|
||||||
return;
|
// 如果是从任务栏将图标移动到托盘,就从配置中移除
|
||||||
|
if (!m_fixedTrayNames.contains(winInfo.itemKey))
|
||||||
|
return;
|
||||||
|
|
||||||
if (index >= 0 && index < m_fixedTrayNames.size()) {
|
m_fixedTrayNames.removeOne(winInfo.itemKey);
|
||||||
m_fixedTrayNames.insert(index, winInfo.itemKey);
|
|
||||||
} else {
|
} else {
|
||||||
m_fixedTrayNames << winInfo.itemKey;
|
// 如果是将图标从托盘移到任务栏上面,就增加到配置中
|
||||||
|
if (m_fixedTrayNames.contains(winInfo.itemKey))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (index >= 0 && index < m_fixedTrayNames.size()) {
|
||||||
|
m_fixedTrayNames.insert(index, winInfo.itemKey);
|
||||||
|
} else {
|
||||||
|
m_fixedTrayNames << winInfo.itemKey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTINGCONFIG->setValue(DOCKQUICKTRAYNAME, m_fixedTrayNames);
|
SETTINGCONFIG->setValue(DOCKQUICKTRAYNAME, m_fixedTrayNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,6 +550,11 @@ void TrayModel::onSniTrayAdded(const QString &servicePath)
|
|||||||
if (!sniCanExport(servicePath))
|
if (!sniCanExport(servicePath))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (const WinInfo &winInfo : m_winInfos) {
|
||||||
|
if (winInfo.servicePath == servicePath)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool typeWriting = isTypeWriting(servicePath);
|
bool typeWriting = isTypeWriting(servicePath);
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
@ -704,6 +721,13 @@ void TrayModel::onSettingChanged(const QString &key, const QVariant &value)
|
|||||||
|
|
||||||
QStringList indicators = m_monitor->indicatorNames();
|
QStringList indicators = m_monitor->indicatorNames();
|
||||||
for (const QString &indicatorName : indicators) {
|
for (const QString &indicatorName : indicators) {
|
||||||
|
if (!m_indicatorMap.contains(indicatorName))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
IndicatorPlugin *plugin = m_indicatorMap[indicatorName];
|
||||||
|
if (!plugin->isLoaded())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (indicatorCanExport(indicatorName))
|
if (indicatorCanExport(indicatorName))
|
||||||
onIndicatorAdded(indicatorName);
|
onIndicatorAdded(indicatorName);
|
||||||
else
|
else
|
||||||
|
@ -169,9 +169,11 @@ void IndicatorPluginPrivate::initDBus(const QString &indicatorName)
|
|||||||
if (data.contains("text")) {
|
if (data.contains("text")) {
|
||||||
featData("text", data, SLOT(textPropertyChanged(QDBusMessage)), [ = ](QVariant v) {
|
featData("text", data, SLOT(textPropertyChanged(QDBusMessage)), [ = ](QVariant v) {
|
||||||
if (v.toString().isEmpty()) {
|
if (v.toString().isEmpty()) {
|
||||||
|
q->m_isLoaded = false;
|
||||||
Q_EMIT q->removed();
|
Q_EMIT q->removed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
q->m_isLoaded = true;
|
||||||
Q_EMIT q->delayLoaded();
|
Q_EMIT q->delayLoaded();
|
||||||
indicatorTrayWidget->setText(v.toString());
|
indicatorTrayWidget->setText(v.toString());
|
||||||
updateContent();
|
updateContent();
|
||||||
@ -181,9 +183,11 @@ void IndicatorPluginPrivate::initDBus(const QString &indicatorName)
|
|||||||
if (data.contains("icon")) {
|
if (data.contains("icon")) {
|
||||||
featData("icon", data, SLOT(iconPropertyChanged(QDBusMessage)), [ = ](QVariant v) {
|
featData("icon", data, SLOT(iconPropertyChanged(QDBusMessage)), [ = ](QVariant v) {
|
||||||
if (v.toByteArray().isEmpty()) {
|
if (v.toByteArray().isEmpty()) {
|
||||||
|
q->m_isLoaded = false;
|
||||||
Q_EMIT q->removed();
|
Q_EMIT q->removed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
q->m_isLoaded = true;
|
||||||
Q_EMIT q->delayLoaded();
|
Q_EMIT q->delayLoaded();
|
||||||
indicatorTrayWidget->setPixmapData(v.toByteArray());
|
indicatorTrayWidget->setPixmapData(v.toByteArray());
|
||||||
updateContent();
|
updateContent();
|
||||||
@ -214,6 +218,7 @@ void IndicatorPluginPrivate::initDBus(const QString &indicatorName)
|
|||||||
IndicatorPlugin::IndicatorPlugin(const QString &indicatorName, QObject *parent)
|
IndicatorPlugin::IndicatorPlugin(const QString &indicatorName, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, d_ptr(new IndicatorPluginPrivate(this))
|
, d_ptr(new IndicatorPluginPrivate(this))
|
||||||
|
, m_isLoaded(false)
|
||||||
{
|
{
|
||||||
Q_D(IndicatorPlugin);
|
Q_D(IndicatorPlugin);
|
||||||
|
|
||||||
@ -244,12 +249,18 @@ void IndicatorPlugin::removeWidget()
|
|||||||
d->indicatorTrayWidget = nullptr;
|
d->indicatorTrayWidget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IndicatorPlugin::isLoaded()
|
||||||
|
{
|
||||||
|
return m_isLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
void IndicatorPlugin::textPropertyChanged(const QDBusMessage &message)
|
void IndicatorPlugin::textPropertyChanged(const QDBusMessage &message)
|
||||||
{
|
{
|
||||||
Q_D(IndicatorPlugin);
|
Q_D(IndicatorPlugin);
|
||||||
|
|
||||||
d->propertyChanged("text", message, [=] (const QVariant &value) {
|
d->propertyChanged("text", message, [ = ] (const QVariant &value) {
|
||||||
if (value.toString().isEmpty()) {
|
if (value.toString().isEmpty()) {
|
||||||
|
m_isLoaded = false;
|
||||||
Q_EMIT removed();
|
Q_EMIT removed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -266,8 +277,9 @@ void IndicatorPlugin::iconPropertyChanged(const QDBusMessage &message)
|
|||||||
{
|
{
|
||||||
Q_D(IndicatorPlugin);
|
Q_D(IndicatorPlugin);
|
||||||
|
|
||||||
d->propertyChanged("icon", message, [=] (const QVariant &value) {
|
d->propertyChanged("icon", message, [ = ] (const QVariant &value) {
|
||||||
if (value.toByteArray().isEmpty()) {
|
if (value.toByteArray().isEmpty()) {
|
||||||
|
m_isLoaded = false;
|
||||||
Q_EMIT removed();
|
Q_EMIT removed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ public:
|
|||||||
|
|
||||||
void removeWidget();
|
void removeWidget();
|
||||||
|
|
||||||
|
bool isLoaded();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void delayLoaded();
|
void delayLoaded();
|
||||||
void removed();
|
void removed();
|
||||||
@ -47,5 +49,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<IndicatorPluginPrivate> d_ptr;
|
QScopedPointer<IndicatorPluginPrivate> d_ptr;
|
||||||
|
bool m_isLoaded;
|
||||||
Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), IndicatorPlugin)
|
Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), IndicatorPlugin)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user