diff --git a/src/appdata/data-provider-manager.cpp b/src/appdata/data-provider-manager.cpp index 3a9ea2b..3e8bff4 100644 --- a/src/appdata/data-provider-manager.cpp +++ b/src/appdata/data-provider-manager.cpp @@ -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()); diff --git a/src/appdata/data-provider-manager.h b/src/appdata/data-provider-manager.h index 10afb18..2a22665 100644 --- a/src/appdata/data-provider-manager.h +++ b/src/appdata/data-provider-manager.h @@ -59,6 +59,7 @@ Q_SIGNALS: void pluginChanged(const QString &id, PluginGroup::Group group); void dataChanged(QVector data, DataUpdateMode::Mode mode, quint32 index); void labelChanged(); + void toUpdate(); private: DataProviderManager(); diff --git a/src/appdata/data-provider-plugin-iface.h b/src/appdata/data-provider-plugin-iface.h index f075b9a..3b28c1e 100644 --- a/src/appdata/data-provider-plugin-iface.h +++ b/src/appdata/data-provider-plugin-iface.h @@ -79,6 +79,9 @@ public: virtual void forceUpdate() = 0; virtual void forceUpdate(QString &key) {}; +public Q_SLOTS: + virtual void update() {}; + Q_SIGNALS: /** * 数据变化 diff --git a/src/appdata/plugin/all-app-data-provider.cpp b/src/appdata/plugin/all-app-data-provider.cpp index 1dab92e..a9e2ead 100644 --- a/src/appdata/plugin/all-app-data-provider.cpp +++ b/src/appdata/plugin/all-app-data-provider.cpp @@ -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); diff --git a/src/appdata/plugin/all-app-data-provider.h b/src/appdata/plugin/all-app-data-provider.h index 083d174..f6b3ccd 100644 --- a/src/appdata/plugin/all-app-data-provider.h +++ b/src/appdata/plugin/all-app-data-provider.h @@ -39,6 +39,9 @@ public: QVector data() override; void forceUpdate() override; +public Q_SLOTS: + void update() override; + private Q_SLOTS: void onAppAdded(const QList& apps); void onAppDeleted(QStringList idList); diff --git a/src/ukui-menu-application.cpp b/src/ukui-menu-application.cpp index 1284136..1195efc 100644 --- a/src/ukui-menu-application.cpp +++ b/src/ukui-menu-application.cpp @@ -30,6 +30,7 @@ #include "items/theme-icon.h" #include "app-manager.h" #include "menu-manager.h" +#include "data-provider-manager.h" #include #include @@ -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; }