fix some bugs

This commit is contained in:
likehomedream 2023-12-08 16:25:09 +08:00
parent 09a684785e
commit 59021df000
7 changed files with 29 additions and 52 deletions

View File

@ -24,7 +24,7 @@ cursorThemeName=dark-sense
soundThemeName=Light-Seeking
[wallpaper]
wallPaperPath=/usr/share/backgrounds/ubuntukylin-default-settings.jpg
wallPaperPath=/usr/share/backgrounds/1-openkylin.jpg
[effect]
supportBlur=true

View File

@ -72,7 +72,7 @@ void buildCheckWidget::buildForGlobal(){
qDebug() << "Name field not found.";
}
QString m_themeWallpaper = "wallPaperPath=/usr/share/backgrounds/ubuntukylin-default-settings.jpg";
QString m_themeWallpaper = "wallPaperPath=/usr/share/backgrounds/1-openkylin.jpg";
QString m_themeNewWallpaper = "wallPaperPath=/usr/share/config/globaltheme/"+FileProcess::g_themeENName+"/1-openkylin.png";
QDir directory(QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_themeENName + "/src/globalTheme");
QStringList fileList = directory.entryList(QDir::Files);

View File

@ -19,8 +19,8 @@ Bridge *Bridge::getInstance(QObject *parent)
void Bridge::wallpaperPathChanged(QString path)
{
m_wallpaperpath = path;
m_configfilemanager->modifyWallPaperConf(path,QDir::homePath() + "/.cache/theme-build/"
+m_time + "/src/globalTheme/theme.conf");
// m_configfilemanager->modifyWallPaperConf(path,QDir::homePath() + "/.cache/theme-build/"
// +m_time + "/src/globalTheme/theme.conf");
m_configfilemanager->copyPictoCacheDir(m_wallpaperpath,QDir::homePath()+"/.cache/theme-build/"
+m_time+"/src/globalTheme","wallpaper");
}

View File

@ -242,10 +242,13 @@ bool ConfigFileManager::modifyWallPaperConf(QString wallpaperpath,QString confFi
QString content = in.readAll();
file.close();
QFile file1(wallpaperpath);
QFileInfo info(file1);
QString suffix = info.suffix();
// 修改内容
int startIndex = content.indexOf("wallPaperPath=");
int startIndex = content.indexOf("wallPaperPath=/usr/share/backgrounds/1-openkylin.");
if (startIndex != -1) {
QString substr = "wallPaperPath="+wallpaperpath;
QString substr = "wallPaperPath=/usr/share/backgrounds/1-openkylin."+suffix;
content.replace(startIndex, content.indexOf('\n', startIndex) - startIndex, substr);
}

View File

@ -156,37 +156,6 @@ void HistoryInfoLoad::getRadius()
*/
void HistoryInfoLoad::getWallpaper()
{
QString filePath = m_historyInfo.filepath + "/src/globalTheme/theme.conf";
// 读取文件内容
QFile file(filePath);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
qDebug() << "无法打开文件:" << filePath;
return;
}
QTextStream in(&file);
QString content = in.readAll();
file.close();
// 查找 wallPaperPath= 所在行的位置
int startIndex = content.indexOf("wallPaperPath=");
QString configwallpath;
if (startIndex != -1) {
int lineStartIndex = content.lastIndexOf('\n', startIndex) + 1;
int lineEndIndex = content.indexOf('\n', startIndex);
if (lineEndIndex == -1) {
lineEndIndex = content.size();
}
QString lineContent = content.mid(lineStartIndex, lineEndIndex - lineStartIndex).trimmed();
lineContent.remove("wallPaperPath=");
configwallpath = lineContent;
}
QFile file1(configwallpath);
if(!file1.exists()){
QDir folder(m_historyInfo.filepath + "/src/globalTheme");
QStringList filters;
filters << "*.png" << "*.jpg";
@ -200,9 +169,6 @@ void HistoryInfoLoad::getWallpaper()
} else {
qDebug()<<"wallpaper file is null";
}
}else{
m_historyInfo.wallpaperpath = configwallpath;
}
}
/**

View File

@ -142,7 +142,7 @@ void HistoryWidget::updateHistoryDir()
QVBoxLayout *alllayout = qobject_cast<QVBoxLayout*>(this->layout());
if (alllayout) {
// 删除原来的widget
while (QWidget* w = alllayout->takeAt(0)->widget()) { // 从索引0开始因删除了所有的widget
while (QWidget* w = alllayout->takeAt(1)->widget()) { // 从索引0开始因删除了所有的widget
delete w;
}
alllayout->addWidget(widget);

View File

@ -176,10 +176,18 @@ void PlymouthThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
m_preview->updatePlymouth(imagedirpath);
m_preview->showPlymouth();
//加载图像文件,判断是否进行修改
QImage image1(InfoData.filepath+"/src/plymouthTheme/1.png");
QImage image2(":/resource/plymouth/1.png");
if (image1 == image2) {
m_customLabel->setPixmap(QPixmap());
} else {
QPixmap pixmap(InfoData.filepath+"/src/plymouthTheme/40.png");
pixmap = pixmap.scaled(64,64, Qt::KeepAspectRatio);
m_customLabel->setPixmap(pixmap);
}
}
void PlymouthThemeWidget::refresh()
{