feat: 修复通知中心插件启动时UI卡顿问题
This commit is contained in:
parent
a62ee9d2eb
commit
6da03fd58e
|
@ -159,9 +159,12 @@ void SettingsManagerPrivate::updateSettingsFile()
|
|||
|
||||
QStringList SettingsManagerPrivate::getAppInfo()
|
||||
{
|
||||
// 过滤掉不需要显示的应用
|
||||
UkuiSearch::ApplicationPropertyMap restrictions = {
|
||||
{UkuiSearch::ApplicationProperty::DontDisplay, 0}
|
||||
};
|
||||
|
||||
return m_applicationInfo->getInfo(UkuiSearch::ApplicationProperties{},
|
||||
UkuiSearch::ApplicationPropertyMap{{UkuiSearch::ApplicationProperty::AutoStart, 0}}).keys();
|
||||
return m_applicationInfo->getInfo(UkuiSearch::ApplicationProperties{}, restrictions).keys();
|
||||
}
|
||||
|
||||
void SettingsManagerPrivate::initSettingsData(QJsonObject &data)
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include <QFileSystemWatcher>
|
||||
#include <QSettings>
|
||||
#include <QToolButton>
|
||||
#include <QThread>
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
#define THEME_QT_SCHEMA "org.ukui.style"
|
||||
|
||||
|
@ -459,18 +459,43 @@ void Notice::initNoticeStatus()
|
|||
|
||||
void Notice::initListUI()
|
||||
{
|
||||
UkuiNotification::ApplicationsSettingsMap appDataMap = UkuiNotification::ApplicationsSettings::self()->getAllApplicationsSettings();
|
||||
UkuiNotification::ApplicationsSettingsMap::const_iterator i = appDataMap.constBegin();
|
||||
while(i != appDataMap.constEnd()) {
|
||||
initItemUi(i.key(), i.value());
|
||||
++i;
|
||||
}
|
||||
const UkuiSearch::ApplicationProperties& properties = {
|
||||
UkuiSearch::ApplicationProperty::LocalName,
|
||||
UkuiSearch::ApplicationProperty::Icon
|
||||
};
|
||||
|
||||
const UkuiSearch::ApplicationPropertyMap& restrictions = {
|
||||
{UkuiSearch::ApplicationProperty::DontDisplay, 0}
|
||||
};
|
||||
|
||||
const UkuiSearch::ApplicationInfoMap& appInfoMap = m_appInfo->getInfo(properties, restrictions);
|
||||
|
||||
connect(this, &Notice::appDataInfo, this, [=](UkuiNotification::ApplicationsSettingsMap dataMap){
|
||||
UkuiNotification::ApplicationsSettingsMap appDataMap = dataMap;
|
||||
UkuiNotification::ApplicationsSettingsMap::const_iterator i = appDataMap.constBegin();
|
||||
while(i != appDataMap.constEnd()) {
|
||||
const QString& desktopPath = i.key();
|
||||
|
||||
if (!appInfoMap.contains(desktopPath)) {
|
||||
qWarning() << "Can't find application info for: " << desktopPath;
|
||||
continue;
|
||||
} else {
|
||||
initItemUi(desktopPath, appInfoMap[desktopPath], i.value());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
QtConcurrent::run([=](){
|
||||
UkuiNotification::ApplicationsSettingsMap dataMap = UkuiNotification::ApplicationsSettings::self()->getAllApplicationsSettings();
|
||||
Q_EMIT appDataInfo(dataMap);
|
||||
});
|
||||
}
|
||||
|
||||
void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleApplicationSettings *settings)
|
||||
void Notice::initItemUi(const QString &desktopPath, const UkuiSearch::ApplicationPropertyMap& properties, UkuiNotification::SingleApplicationSettings *settings)
|
||||
{
|
||||
QString localName = m_appInfo->getInfo(desktopPath, UkuiSearch::ApplicationProperty::LocalName).toString();
|
||||
QString iconName = m_appInfo->getInfo(desktopPath, UkuiSearch::ApplicationProperty::Icon).toString();
|
||||
QString localName = properties[UkuiSearch::ApplicationProperty::LocalName].toString();
|
||||
QString iconName = properties[UkuiSearch::ApplicationProperty::Icon].toString();
|
||||
QString fileName = desktopPath.left(desktopPath.indexOf(QLatin1Char('.')));
|
||||
|
||||
QFrame *baseWidget = new QFrame(m_noticeAppFrame);
|
||||
|
|
|
@ -66,9 +66,14 @@ public:
|
|||
void initConnection();
|
||||
void initNoticeStatus();
|
||||
void initListUI();
|
||||
void initItemUi(const QString &desktopPath, UkuiNotification::SingleApplicationSettings *settings);
|
||||
void initItemUi(const QString &desktopPath,
|
||||
const UkuiSearch::ApplicationPropertyMap& properties,
|
||||
UkuiNotification::SingleApplicationSettings *settings);
|
||||
void setAppIcon(QLabel *iconlabel, const QString &icon);
|
||||
|
||||
Q_SIGNALS:
|
||||
void appDataInfo(UkuiNotification::ApplicationsSettingsMap appDataMap);
|
||||
|
||||
private:
|
||||
void setHiddenNoticeApp(bool status);
|
||||
void setComBoxStatus(bool status);
|
||||
|
|
Loading…
Reference in New Issue