修改最近安装应用蓝点标识刷新逻辑

This commit is contained in:
youdiansaodongxi 2023-06-05 10:23:13 +08:00 committed by He Sir
parent ccaff26c5a
commit aa52550d29
6 changed files with 34 additions and 0 deletions

View File

@ -44,15 +44,19 @@ DataProviderManager::DataProviderManager()
void DataProviderManager::initProviders()
{
auto *allProvider = new AllAppDataProvider;
connect(this, &DataProviderManager::toUpdate, allProvider, &AllAppDataProvider::update);
registerProvider(allProvider);
auto *search = new AppSearchPlugin;
connect(this, &DataProviderManager::toUpdate, search, &AppSearchPlugin::update);
registerProvider(search);
auto *category = new AppCategoryPlugin;
connect(this, &DataProviderManager::toUpdate, category, &AppCategoryPlugin::update);
registerProvider(category);
auto *sort = new AppLetterSortPlugin;
connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update);
registerProvider(sort);
activateProvider(allProvider->id());

View File

@ -59,6 +59,7 @@ Q_SIGNALS:
void pluginChanged(const QString &id, PluginGroup::Group group);
void dataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
void labelChanged();
void toUpdate();
private:
DataProviderManager();

View File

@ -79,6 +79,9 @@ public:
virtual void forceUpdate() = 0;
virtual void forceUpdate(QString &key) {};
public Q_SLOTS:
virtual void update() {};
Q_SIGNALS:
/**
*

View File

@ -83,6 +83,24 @@ void AllAppDataProvider::forceUpdate()
sendData();
}
void AllAppDataProvider::update()
{
bool isRecentDataChanged = false;
{
QMutexLocker locker(&m_mutex);
for (DataEntity & appdata : m_appData) {
bool info = appdata.isRecentInstall();
setRecentState(appdata);
if (appdata.isRecentInstall() != info) {
isRecentDataChanged = true;
}
}
}
if (isRecentDataChanged) {
sendData();
}
}
void AllAppDataProvider::reloadAppData()
{
QMutexLocker locker(&m_mutex);

View File

@ -39,6 +39,9 @@ public:
QVector<DataEntity> data() override;
void forceUpdate() override;
public Q_SLOTS:
void update() override;
private Q_SLOTS:
void onAppAdded(const QList<DataEntity>& apps);
void onAppDeleted(QStringList idList);

View File

@ -30,6 +30,7 @@
#include "items/theme-icon.h"
#include "app-manager.h"
#include "menu-manager.h"
#include "data-provider-manager.h"
#include <QCoreApplication>
#include <QCommandLineParser>
@ -135,12 +136,16 @@ void UkuiMenuApplication::execCommand(Command command)
case Active: {
if (m_mainWindow) {
m_mainWindow->setVisible(!m_mainWindow->isVisible());
if (m_mainWindow->isVisible()) {
DataProviderManager::instance()->toUpdate();
}
}
break;
}
case Show: {
if (m_mainWindow) {
m_mainWindow->setVisible(true);
DataProviderManager::instance()->toUpdate();
}
break;
}