forked from openkylin/ukui-menu
修改最近安装应用蓝点标识刷新逻辑
This commit is contained in:
parent
ccaff26c5a
commit
aa52550d29
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -79,6 +79,9 @@ public:
|
|||
virtual void forceUpdate() = 0;
|
||||
virtual void forceUpdate(QString &key) {};
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void update() {};
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* 数据变化
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue