fix(notification-ukcc-plugin): 修改启动时导致设置卡顿的问题

This commit is contained in:
youdiansaodongxi 2024-05-30 20:44:47 +08:00
parent 58fd71fec7
commit 2c560d0a29
2 changed files with 11 additions and 12 deletions

View File

@ -26,8 +26,17 @@
#include <QApplication> #include <QApplication>
#include <QTranslator> #include <QTranslator>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <mutex>
#define THEME_QT_SCHEMA "org.ukui.style" #define THEME_QT_SCHEMA "org.ukui.style"
static std::once_flag flag;
static UkuiSearch::ApplicationInfo *s_appInfo = nullptr;
UkuiSearch::ApplicationInfo *appInfo() {
std::call_once(flag, [ & ] {
s_appInfo = new UkuiSearch::ApplicationInfo();
});
return s_appInfo;
}
class ToolButton : public QToolButton class ToolButton : public QToolButton
{ {
@ -59,9 +68,6 @@ Notice::Notice()
if (!m_globalSettings) { if (!m_globalSettings) {
m_globalSettings = new UkuiNotification::NotificationGlobalSettings(); m_globalSettings = new UkuiNotification::NotificationGlobalSettings();
} }
if (!m_appInfo) {
m_appInfo = new UkuiSearch::ApplicationInfo();
}
m_pluginWidget = new QWidget; m_pluginWidget = new QWidget;
m_pluginWidget->setAttribute(Qt::WA_DeleteOnClose); m_pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
@ -79,11 +85,6 @@ Notice::~Notice()
delete m_globalSettings; delete m_globalSettings;
m_globalSettings = nullptr; m_globalSettings = nullptr;
} }
if (m_appInfo) {
delete m_appInfo;
m_appInfo = nullptr;
}
} }
QString Notice::plugini18nName() QString Notice::plugini18nName()
@ -473,7 +474,7 @@ void Notice::initListUI()
connect(this, &Notice::appDataInfo, this, &Notice::addItemUi, Qt::QueuedConnection); connect(this, &Notice::appDataInfo, this, &Notice::addItemUi, Qt::QueuedConnection);
QtConcurrent::run([=](){ QtConcurrent::run([=](){
const UkuiSearch::ApplicationInfoMap& appInfoMap = m_appInfo->getInfo(properties, restrictions); const UkuiSearch::ApplicationInfoMap& appInfoMap = appInfo()->getInfo(properties, restrictions);
Q_EMIT appDataInfo(appInfoMap); Q_EMIT appDataInfo(appInfoMap);
}); });
@ -487,7 +488,7 @@ void Notice::initListUI()
}; };
QtConcurrent::run([=](){ QtConcurrent::run([=](){
UkuiSearch::ApplicationPropertyMap dataMap = m_appInfo->getInfo(desktopEntry, properties); UkuiSearch::ApplicationPropertyMap dataMap = appInfo()->getInfo(desktopEntry, properties);
UkuiSearch::ApplicationInfoMap appInfoMap = {{desktopEntry, dataMap}}; UkuiSearch::ApplicationInfoMap appInfoMap = {{desktopEntry, dataMap}};
Q_EMIT appDataInfo(appInfoMap); Q_EMIT appDataInfo(appInfoMap);
}); });

View File

@ -110,8 +110,6 @@ private:
QVBoxLayout *m_appListVerticalLayout = nullptr; QVBoxLayout *m_appListVerticalLayout = nullptr;
UkuiNotification::NotificationGlobalSettings *m_globalSettings = nullptr; UkuiNotification::NotificationGlobalSettings *m_globalSettings = nullptr;
UkuiSearch::ApplicationInfo *m_appInfo = nullptr;
}; };
#endif // NOTIFICATION_UKCC_PLUGIN_H #endif // NOTIFICATION_UKCC_PLUGIN_H