处理依赖问题;处理开机动画问题;处理重复生成deb未复盖问题;处理重复生成软件包导致开机动画grub光标全局模块出现的问题;处理svg转png问题;处理编译缓存问题

This commit is contained in:
KevinDuan 2024-01-04 13:57:18 +08:00
parent 39d5bf5614
commit 936db7715e
10 changed files with 140 additions and 65 deletions

2
debian/control vendored
View File

@ -26,7 +26,7 @@ Rules-Requires-Root: no
Package: kylin-theme-builder
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends},debhelper-compat (= 13),meson,ninja-build
Depends: ${shlibs:Depends}, ${misc:Depends},debhelper-compat (= 13),meson,ninja-build,devscript,build-essential:native,x11-apps
Description: Kylin Theme Builder is a theme maker.
As the title suggests, this tool is dedicated to helping
people create new theme packages for the kylin system,

View File

@ -115,10 +115,10 @@
<file>resource/time-cursor/watch_9.png</file>
<file>resource/time-cursor/watch_10.png</file>
<file>resource/background/kylin.gif</file>
<file>resource/plymouth/logo.script</file>
<file>resource/plymouth/uk.png</file>
<file>resource/plymouth/password_field.png</file>
<file>resource/plymouth/progress_dot_off.png</file>
<file>resource/plymouth-other/logo.script</file>
<file>resource/plymouth-other/uk.png</file>
<file>resource/plymouth-other/password_field.png</file>
<file>resource/plymouth-other/progress_dot_off.png</file>
<file>resource/plymouth/104.png</file>
<file>resource/plymouth/103.png</file>
<file>resource/plymouth/102.png</file>

View File

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 395 B

View File

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 376 B

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -55,9 +55,9 @@ void build::run()
if(output=="dh clean\n"){
emit progressChanged(20);
}else if(output==" dh_installdocs\n"){
emit progressChanged(80);
emit progressChanged(60);
}else if(output==" dh_builddeb\n"){
emit progressChanged(90);
emit progressChanged(70);
}
}
@ -66,10 +66,23 @@ void build::run()
// 等待debuild进程完成
process2.waitForFinished(-1);
// 完成后更新进度条的值为100
// 完成后更新进度条的值为90
if(!m_iserror){
emit progressChanged(100);
emit progressChanged(90);
}else{
emit progressError(m_errorinfo);
}
// 编译记录清除
QProcess process3;
QString command3 = "debuild";
QStringList arguments3;
arguments3 << "--"<<"clean";
process3.setWorkingDirectory(dir2);
process3.start(command3, arguments3);
// 等待debuild进程完成
process3.waitForFinished(-1);
// 完成后更新进度条的值为100
emit progressChanged(100);
}

View File

@ -31,7 +31,7 @@ buildWidget::buildWidget(QWidget *parent)
QDir sourceDir = sourceDirPath;
QDir homePath = FileProcess::g_debPath;
QStringList debFiles = sourceDir.entryList(QStringList() << "*.deb", QDir::Files);
QStringList debFiles = sourceDir.entryList(QStringList() << FileProcess::g_themeENName+"_*.deb", QDir::Files);
// 遍历文件列表并复制文件到目标目录
foreach (const QString& debFile, debFiles) {
QString sourceFilePath = sourceDir.absoluteFilePath(debFile);
@ -45,8 +45,8 @@ buildWidget::buildWidget(QWidget *parent)
// 检查目标文件是否已存在
if (targetFile.exists()) {
targetFile.remove();
qDebug() << "Target file already exists:" << debFile;
continue;
}
// 使用QFile的copy方法将源文件复制到目标文件

View File

@ -223,7 +223,7 @@ void buildCheckWidget::buildForIcon(){
}
}
foreach (const QString &m_systemIconfile, m_systemIconfiles) {
QString sourceFilePath = m_buildAppIconDir.filePath(m_systemIconfile);
QString sourceFilePath = m_buildSystemIconDir.filePath(m_systemIconfile);
QString destinationFilePath = m_iconThemeScalableAppsDir.filePath(m_systemIconfile);
QFile sourceFile(sourceFilePath);
@ -247,25 +247,25 @@ void buildCheckWidget::buildForIcon(){
// 遍历获取文件名
foreach (QFileInfo m_svgFileInfo, m_svgFileInfoList) {
QString m_fileName = m_svgFileInfo.fileName();
//处理svg转png
QSvgRenderer m_svgRenderer;
m_svgRenderer.load(m_fileName);
//遍历、创建尺寸目录并拷贝生成png
int array[] = {16, 24, 32, 48, 64, 96, 128, 256};
int length = sizeof(array) / sizeof(array[0]);
for (int i = 0; i < length; i++) {
// 创建QImage对象并绘制SVG到不同尺寸的图像上
QSize size(array[i],array[i]);
QImage image(size, QImage::Format_ARGB32);
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing);
m_svgRenderer.render(&painter, QRectF(0, 0, size.width(), size.height()));
// 初始化一个 SVG 渲染器
QSvgRenderer svgRenderer(m_svgFileInfo.absoluteFilePath());
// 创建一个和 SVG 同样大小的 QImage 对象,使用透明背景
QImage image(QSize(array[i],array[i]), QImage::Format_ARGB32);
image.fill(Qt::transparent);
// 创建一个 QPainter 对象,用于在 QImage 对象上绘图
QPainter painter(&image);
// 使用 SVG 渲染器在 QPainter 上渲染图像
svgRenderer.render(&painter, QRectF(0, 0, array[i], array[i]));
//生成尺寸目录
QString m_imageDirThemeSizePath = m_buildIconThemePath +"/" + QString::number(array[i]) + "x" + QString::number(array[i]);
QString m_imageDirThemeAppsPath = m_imageDirThemeSizePath+ "/apps";
@ -274,9 +274,9 @@ void buildCheckWidget::buildForIcon(){
m_imageThemeSizeDir.mkdir(m_imageThemeSizeDir.absolutePath());
m_imageDirThemeAppDir.mkdir(m_imageDirThemeAppDir.absolutePath());
//拷贝图片
m_fileName.replace(".svg", ".png");
image.save(m_imageDirThemeAppsPath+"/"+m_fileName);
// 将 QImage 对象保存为 PNG 文件
QString m_fileName = m_svgFileInfo.baseName();
image.save(m_imageDirThemeAppsPath+"/"+m_fileName+".png");
if (m_iconIndex.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_iconIndex;
@ -334,19 +334,20 @@ void buildCheckWidget::buildForCursor(){
//编写cursor.sh
QFile m_cursorShell(m_buildcursorThemePath+"/cursor.sh");
QTextStream m_cursorShellStream(&m_cursorShell);
if (m_cursorShell.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_cursorShell;
m_cursorShellStream << QStringLiteral("#!/bin/bash");
m_cursorShellStream << endl << QStringLiteral(" mkdir cursors");
if(!m_cursorShell.exists()){
if (m_cursorShell.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_cursorShell;
m_cursorShellStream << QStringLiteral("#!/bin/bash");
m_cursorShellStream << endl << QStringLiteral(" mkdir cursors");
m_cursorIndexStream.flush();
m_cursorShell.close();
m_cursorShell.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner |
QFile::ReadUser | QFile::WriteUser | QFile::ExeUser |
QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup |
QFile::ReadOther | QFile::WriteOther | QFile::ExeOther);
m_cursorIndexStream.flush();
m_cursorShell.close();
m_cursorShell.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner |
QFile::ReadUser | QFile::WriteUser | QFile::ExeUser |
QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup |
QFile::ReadOther | QFile::WriteOther | QFile::ExeOther);
}
}
//处理svg转png获取svg文件
QString m_cursorIconPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/cursorTheme/cursor/";
QString m_timeCursorIconPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/cursorTheme/timecursor/";
@ -417,34 +418,35 @@ void buildCheckWidget::buildForCursor(){
// 遍历获取文件名
foreach (QFileInfo m_svgFileInfo, m_svgFileInfoList) {
QString m_fileName = m_svgFileInfo.fileName();
//处理svg转png
QSvgRenderer m_svgRenderer;
m_svgRenderer.load(m_fileName);
QString m_deleteFileNameConclusion = m_fileName.chopped(4);
QString m_fileNameTimeCursor = m_fileName.left(m_fileName.lastIndexOf('_'));
//遍历、创建尺寸目录并拷贝生成png
int array[] = {24, 32, 48, 64};
int length = sizeof(array) / sizeof(array[0]);
QString m_deleteFileNameConclusion = m_fileName.chopped(4);
QString m_fileNameTimeCursor = m_fileName.left(m_fileName.lastIndexOf('_'));
for (int i = 0; i < length; i++) {
// 创建QImage对象并绘制SVG到不同尺寸的图像上
QSize size(array[i],array[i]);
QImage image(size, QImage::Format_ARGB32);
// 初始化一个 SVG 渲染器
QSvgRenderer svgRenderer(m_svgFileInfo.absoluteFilePath());
// 创建一个和 SVG 同样大小的 QImage 对象,使用透明背景
QImage image(QSize(array[i],array[i]), QImage::Format_ARGB32);
image.fill(Qt::transparent);
// 创建一个 QPainter 对象,用于在 QImage 对象上绘图
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing);
m_svgRenderer.render(&painter, QRectF(0, 0, size.width(), size.height()));
// 使用 SVG 渲染器在 QPainter 上渲染图像
svgRenderer.render(&painter, QRectF(0, 0, array[i], array[i]));
//生成尺寸目录
QString m_imageDirThemeSizePath = m_buildcursorThemePath +"/" + QString::number(array[i]) + "x" + QString::number(array[i]);
QDir m_imageThemeSizeDir = m_imageDirThemeSizePath;
m_imageThemeSizeDir.mkdir(m_imageThemeSizeDir.absolutePath());
//拷贝图片
m_fileName.replace(".svg", ".png");
image.save(m_imageDirThemeSizePath+"/"+m_fileName);
// 将 QImage 对象保存为 PNG 文件
QString m_fileNameBase = m_svgFileInfo.baseName();
image.save(m_imageDirThemeSizePath+"/"+m_fileNameBase+".png");
if(m_fileNameTimeCursor != "watch" && m_fileNameTimeCursor != "left_ptr_watch"){
@ -682,14 +684,14 @@ void buildCheckWidget::buildForCursor(){
//开机动画打包
void buildCheckWidget::buildForPlymouth(){
QString m_buildPlymouthPath = QDir::homePath()+ "/.cache/theme-build/" + FileProcess::g_date + "/src/plymouthTheme/";
QString m_buildPlymouthPath = QDir::homePath()+ "/.cache/theme-build/" + FileProcess::g_date + "/src/plymouthTheme/other/";
QDir m_buildPlymouthThemeDir = m_buildPlymouthPath;
m_buildPlymouthThemeDir.mkdir(m_buildPlymouthThemeDir.absolutePath());
//拷贝文件
QFile::copy(":/resource/plymouth/logo.script", m_buildPlymouthPath + FileProcess::g_themeENName+"-logo.script");
QFile::copy(":/resource/plymouth/uk.png",m_buildPlymouthPath+"/uk.png");
QFile::copy(":/resource/plymouth/password_field.png",m_buildPlymouthPath+"/password_field.png");
QFile::copy(":/resource/plymouth/progress_dot_off.png",m_buildPlymouthPath+"/progress_dot_off.png");
QFile::copy(":/resource/plymouth-other/logo.script", m_buildPlymouthPath + FileProcess::g_themeENName+"-logo.script");
QFile::copy(":/resource/plymouth-other/uk.png",m_buildPlymouthPath+"/uk.png");
QFile::copy(":/resource/plymouth-other/password_field.png",m_buildPlymouthPath+"/password_field.png");
QFile::copy(":/resource/plymouth-other/progress_dot_off.png",m_buildPlymouthPath+"/progress_dot_off.png");
//写入plymouth文件
QFile m_themeplymouth(m_buildPlymouthPath + FileProcess::g_themeENName+"-logo.plymouth");
@ -709,11 +711,33 @@ void buildCheckWidget::buildForPlymouth(){
m_themeplymouth.close();
}
//写入postinst文件
QFile(m_debPath+"/debian/postinst").setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner);
QFile(m_debPath+"/debian/postinst").setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner |
QFile::ReadUser | QFile::WriteUser | QFile::ExeUser |
QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup |
QFile::ReadOther | QFile::WriteOther | QFile::ExeOther);
QFile m_postinst(m_debPath+"/debian/postinst");
// 读取文件内容
QStringList lines;
QTextStream m_plymouthpostinstStream(&m_postinst);
if (m_postinst.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_postinst;
if (m_postinst.open(QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text)) {
//处理多次编译
m_plymouthpostinstStream.seek(0);
while (!m_plymouthpostinstStream.atEnd()) {
QString line = m_plymouthpostinstStream.readLine();
// 如果行不包含特定文本,则添加到新的行列表
if (!line.contains("update-alternatives")) {
lines << line;
}
}
m_postinst.resize(0);
foreach (const QString &line, lines) {
if (line == "#!/bin/sh"){
m_plymouthpostinstStream << line;
} else {
m_plymouthpostinstStream << endl << line;
}
}
m_plymouthpostinstStream << endl << QStringLiteral("update-alternatives --remove-all default.plymouth");
m_plymouthpostinstStream << endl << QStringLiteral("update-alternatives"
" --install /usr/share/plymouth/themes/default.plymouth default.plymouth "
@ -729,15 +753,53 @@ void buildCheckWidget::buildForPlymouth(){
//grub打包
void buildCheckWidget::buildForGrub(){
QString m_buildGrubPath = QDir::homePath()+ "/.cache/theme-build/" + FileProcess::g_date + "/src/grubTheme/";
if(QFile::exists(m_buildGrubPath+"background-"+FileProcess::g_themeENName+".png")){
QFile::remove(m_buildGrubPath+"background-"+FileProcess::g_themeENName+".png");
}
//拷贝grub背景
QFile::copy(m_buildGrubPath+"background.png",m_buildGrubPath+"background-"+FileProcess::g_themeENName+".png");
//写入postinst文件
QFile(m_debPath+"/debian/postinst").setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner);
QFile(m_debPath+"/debian/postinst").setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner |
QFile::ReadUser | QFile::WriteUser | QFile::ExeUser |
QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup |
QFile::ReadOther | QFile::WriteOther | QFile::ExeOther);
QFile m_postinst(m_debPath+"/debian/postinst");
QTextStream m_grubpostinstStream(&m_postinst);
if (m_postinst.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
QStringList lines;
if (m_postinst.open(QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_postinst;
//处理多次编译
m_grubpostinstStream.seek(0);
QStringList linesToRemove; // 用于存储需要移除的行
bool skipNextLines = false; // 标志是否需要跳过接下来的四行
while (!m_grubpostinstStream.atEnd()) {
QString line = m_grubpostinstStream.readLine();
if (skipNextLines) {
// 如果需要跳过接下来的四行则将这四行添加到移除列表中并将标志重置为false
linesToRemove << line;
if (linesToRemove.size() == 5) {
skipNextLines = false;
}
} else if (line.contains("file_path='/usr/share/grub/themes/UKUI/theme.txt'")) {
// 如果当前行包含特定文本,则将这一行和接下来的四行都标记为需要移除
linesToRemove << line;
skipNextLines = true;
} else {
// 如果当前行既不是需要移除的行也不是其后的四行,则添加到新行列表中
lines << line;
}
}
m_postinst.resize(0);
foreach (const QString &line, lines) {
if (line == "#!/bin/sh"){
m_grubpostinstStream << line;
} else {
m_grubpostinstStream << endl << line;
}
}
m_grubpostinstStream << endl << QStringLiteral("file_path='/usr/share/grub/themes/UKUI/theme.txt'");
m_grubpostinstStream << endl << QStringLiteral("line_number=$(grep -n 'desktop-image:' $file_path | cut -d ':' -f 1)");
m_grubpostinstStream << endl << QStringLiteral("if [ -n '$line_number' ]; then");

View File

@ -505,11 +505,11 @@ void InfoCreateWidget::createMeson(const QString &m_date){
QTextStream m_plymouthMesonStream(&m_plymouthMeson);
m_plymouthMesonStream << QStringLiteral("plymouth_dir = join_paths(get_option('prefix'), 'share/plymouth/themes/")
+FileProcess::g_themeENName+QStringLiteral("-logo')");
m_plymouthMesonStream << endl << QStringLiteral("install_data('uk.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('password_field.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('progress_dot_off.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('")+FileProcess::g_themeENName+("-logo.script',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('")+FileProcess::g_themeENName+("-logo.plymouth',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('other/uk.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('other/password_field.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('other/progress_dot_off.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('other/")+FileProcess::g_themeENName+("-logo.script',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('other/")+FileProcess::g_themeENName+("-logo.plymouth',install_dir: plymouth_dir)");
for (int var = 1; var <= 104; ++var) {
m_plymouthMesonStream << endl << QStringLiteral("install_data('")+QString::number(var)+QStringLiteral(".png',install_dir: plymouth_dir)");