fix wallpaper error

This commit is contained in:
likehomedream 2023-12-08 14:43:05 +08:00
parent 9a499cde87
commit 09a684785e
1 changed files with 20 additions and 1 deletions

View File

@ -170,6 +170,7 @@ void HistoryInfoLoad::getWallpaper()
// 查找 wallPaperPath= 所在行的位置
int startIndex = content.indexOf("wallPaperPath=");
QString configwallpath;
if (startIndex != -1) {
int lineStartIndex = content.lastIndexOf('\n', startIndex) + 1;
int lineEndIndex = content.indexOf('\n', startIndex);
@ -181,9 +182,27 @@ void HistoryInfoLoad::getWallpaper()
QString lineContent = content.mid(lineStartIndex, lineEndIndex - lineStartIndex).trimmed();
lineContent.remove("wallPaperPath=");
m_historyInfo.wallpaperpath = lineContent;
configwallpath = lineContent;
}
QFile file1(configwallpath);
if(!file1.exists()){
QDir folder(m_historyInfo.filepath + "/src/globalTheme");
QStringList filters;
filters << "*.png" << "*.jpg";
folder.setNameFilters(filters);
QStringList fileList = folder.entryList();
if(fileList.contains("1-openkylin.png")){
m_historyInfo.wallpaperpath = m_historyInfo.filepath + "/src/globalTheme/1-openkylin.png";
} else if (fileList.contains("1-openkylin.jpg")){
m_historyInfo.wallpaperpath = m_historyInfo.filepath + "/src/globalTheme/1-openkylin.jpg";
} else {
qDebug()<<"wallpaper file is null";
}
}else{
m_historyInfo.wallpaperpath = configwallpath;
}
}
/**