add dir watch of desktop

This commit is contained in:
sunfengsheng 2021-02-27 00:57:47 +08:00
parent 883de524e3
commit 723a79c221
2 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,13 @@ AppMatch::AppMatch(QObject *parent) : QObject(parent)
{ {
this->getDesktopFilePath(); this->getDesktopFilePath();
m_watchAppDir=new QFileSystemWatcher(this);
m_watchAppDir->addPath("/usr/share/applications/");
connect(m_watchAppDir,&QFileSystemWatcher::directoryChanged,[this](){
this->getDesktopFilePath();
});
qDBusRegisterMetaType<QMap<QString,QString>>(); qDBusRegisterMetaType<QMap<QString,QString>>();
qDBusRegisterMetaType<QList<QMap<QString,QString>>>(); qDBusRegisterMetaType<QList<QMap<QString,QString>>>();
m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults", m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults",
@ -41,6 +48,10 @@ AppMatch::~AppMatch(){
delete m_interFace; delete m_interFace;
m_interFace=NULL; m_interFace=NULL;
} }
if(m_watchAppDir){
delete m_watchAppDir;
m_watchAppDir=NULL;
}
} }
QStringList AppMatch::startMatchApp(QString input){ QStringList AppMatch::startMatchApp(QString input){

View File

@ -55,6 +55,7 @@ private:
QStringList m_returnResult; QStringList m_returnResult;
QDBusInterface *m_interFace=nullptr; QDBusInterface *m_interFace=nullptr;
QFileSystemWatcher *m_watchAppDir=nullptr;
QMap<QString,QList<QString>> m_softWareCenterMap; QMap<QString,QList<QString>> m_softWareCenterMap;
QMap<QString,QList<QString>> m_installAppMap; QMap<QString,QList<QString>> m_installAppMap;
QMap<QString,QList<QString>> m_filterInstallAppMap; QMap<QString,QList<QString>> m_filterInstallAppMap;