forked from openkylin/ukui-menu
修改最近安装应用蓝点标识刷新逻辑
This commit is contained in:
parent
ccaff26c5a
commit
aa52550d29
|
@ -44,15 +44,19 @@ DataProviderManager::DataProviderManager()
|
||||||
void DataProviderManager::initProviders()
|
void DataProviderManager::initProviders()
|
||||||
{
|
{
|
||||||
auto *allProvider = new AllAppDataProvider;
|
auto *allProvider = new AllAppDataProvider;
|
||||||
|
connect(this, &DataProviderManager::toUpdate, allProvider, &AllAppDataProvider::update);
|
||||||
registerProvider(allProvider);
|
registerProvider(allProvider);
|
||||||
|
|
||||||
auto *search = new AppSearchPlugin;
|
auto *search = new AppSearchPlugin;
|
||||||
|
connect(this, &DataProviderManager::toUpdate, search, &AppSearchPlugin::update);
|
||||||
registerProvider(search);
|
registerProvider(search);
|
||||||
|
|
||||||
auto *category = new AppCategoryPlugin;
|
auto *category = new AppCategoryPlugin;
|
||||||
|
connect(this, &DataProviderManager::toUpdate, category, &AppCategoryPlugin::update);
|
||||||
registerProvider(category);
|
registerProvider(category);
|
||||||
|
|
||||||
auto *sort = new AppLetterSortPlugin;
|
auto *sort = new AppLetterSortPlugin;
|
||||||
|
connect(this, &DataProviderManager::toUpdate, sort, &AppLetterSortPlugin::update);
|
||||||
registerProvider(sort);
|
registerProvider(sort);
|
||||||
|
|
||||||
activateProvider(allProvider->id());
|
activateProvider(allProvider->id());
|
||||||
|
|
|
@ -59,6 +59,7 @@ Q_SIGNALS:
|
||||||
void pluginChanged(const QString &id, PluginGroup::Group group);
|
void pluginChanged(const QString &id, PluginGroup::Group group);
|
||||||
void dataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
|
void dataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
|
||||||
void labelChanged();
|
void labelChanged();
|
||||||
|
void toUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DataProviderManager();
|
DataProviderManager();
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
virtual void forceUpdate() = 0;
|
virtual void forceUpdate() = 0;
|
||||||
virtual void forceUpdate(QString &key) {};
|
virtual void forceUpdate(QString &key) {};
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
virtual void update() {};
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* 数据变化
|
* 数据变化
|
||||||
|
|
|
@ -83,6 +83,24 @@ void AllAppDataProvider::forceUpdate()
|
||||||
sendData();
|
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()
|
void AllAppDataProvider::reloadAppData()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
|
|
|
@ -39,6 +39,9 @@ public:
|
||||||
QVector<DataEntity> data() override;
|
QVector<DataEntity> data() override;
|
||||||
void forceUpdate() override;
|
void forceUpdate() override;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void update() override;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onAppAdded(const QList<DataEntity>& apps);
|
void onAppAdded(const QList<DataEntity>& apps);
|
||||||
void onAppDeleted(QStringList idList);
|
void onAppDeleted(QStringList idList);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "items/theme-icon.h"
|
#include "items/theme-icon.h"
|
||||||
#include "app-manager.h"
|
#include "app-manager.h"
|
||||||
#include "menu-manager.h"
|
#include "menu-manager.h"
|
||||||
|
#include "data-provider-manager.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
@ -135,12 +136,16 @@ void UkuiMenuApplication::execCommand(Command command)
|
||||||
case Active: {
|
case Active: {
|
||||||
if (m_mainWindow) {
|
if (m_mainWindow) {
|
||||||
m_mainWindow->setVisible(!m_mainWindow->isVisible());
|
m_mainWindow->setVisible(!m_mainWindow->isVisible());
|
||||||
|
if (m_mainWindow->isVisible()) {
|
||||||
|
DataProviderManager::instance()->toUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Show: {
|
case Show: {
|
||||||
if (m_mainWindow) {
|
if (m_mainWindow) {
|
||||||
m_mainWindow->setVisible(true);
|
m_mainWindow->setVisible(true);
|
||||||
|
DataProviderManager::instance()->toUpdate();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue