update icon build module and update meson create
This commit is contained in:
parent
4fc78e60d5
commit
52cb7eff18
|
@ -26,6 +26,37 @@ buildWidget::buildWidget(QWidget *parent)
|
|||
connect(thread, &build::progressChanged, this, [=](){
|
||||
if(m_buildProgressBar->value()==100){
|
||||
this->close();
|
||||
//拷贝deb包至用户目录中
|
||||
QString sourceDirPath = QDir::homePath()+"/.cache/theme-build/"+FileProcess::g_date;
|
||||
QDir sourceDir = sourceDirPath;
|
||||
QDir homePath =QDir::homePath();
|
||||
|
||||
QStringList debFiles = sourceDir.entryList(QStringList() << "*.deb", QDir::Files);
|
||||
// 遍历文件列表并复制文件到目标目录
|
||||
foreach (const QString& debFile, debFiles) {
|
||||
QString sourceFilePath = sourceDir.absoluteFilePath(debFile);
|
||||
QString homeFilePath = homePath.absoluteFilePath(debFile);
|
||||
|
||||
// 创建源文件QFile对象
|
||||
QFile sourceFile(sourceFilePath);
|
||||
|
||||
// 创建目标文件QFile对象
|
||||
QFile targetFile(homeFilePath);
|
||||
|
||||
// 检查目标文件是否已存在
|
||||
if (targetFile.exists()) {
|
||||
qDebug() << "Target file already exists:" << debFile;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 使用QFile的copy方法将源文件复制到目标文件
|
||||
if (!sourceFile.copy(homeFilePath)) {
|
||||
qDebug() << "Failed to copy file:" << debFile;
|
||||
continue;
|
||||
}
|
||||
|
||||
qDebug() << "File copied successfully:" << debFile;
|
||||
}
|
||||
//清空日期缓存
|
||||
FileProcess::g_date = nullptr;
|
||||
FileProcess::g_themeENName = nullptr;
|
||||
|
|
|
@ -38,6 +38,7 @@ void buildCheckWidget::buildForGlobal(){
|
|||
//图标打包
|
||||
void buildCheckWidget::buildForIcon(){
|
||||
|
||||
//创建打包目录
|
||||
QString m_imageDirThemePath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/iconTheme/"
|
||||
+ FileProcess::g_themeENName;
|
||||
QDir m_imageDirThemeDir = m_imageDirThemePath;
|
||||
|
@ -53,85 +54,149 @@ void buildCheckWidget::buildForIcon(){
|
|||
m_iconIndexStream << endl << QStringLiteral("Comment=Icon theme for UKUI ,from moka.");
|
||||
m_iconIndexStream << endl << QStringLiteral("Inherits=ukui-icon-theme-default,gnome,hicolor,Adwaita");
|
||||
m_iconIndexStream << endl;
|
||||
m_iconIndexStream << endl << QStringLiteral("# Directory list");
|
||||
m_iconIndexStream << endl << QStringLiteral("Directories=16x16/apps,24x24/apps,32x32/apps,48x48/apps,64x64/apps,96x96/apps,128x128/apps,256x256/apps,scalable/apps");
|
||||
m_iconIndexStream << endl << QStringLiteral("# Applications");
|
||||
m_iconIndexStream << endl << QStringLiteral("[scalable/apps]");
|
||||
m_iconIndexStream << endl << QStringLiteral("Context=Applications");
|
||||
m_iconIndexStream << endl << QStringLiteral("Size=16");
|
||||
m_iconIndexStream << endl << QStringLiteral("MinSize=16");
|
||||
m_iconIndexStream << endl << QStringLiteral("MaxSize=256");
|
||||
m_iconIndexStream << endl << QStringLiteral("Type=Scalable");
|
||||
m_iconIndexStream << endl;
|
||||
|
||||
m_iconIndexStream.flush();
|
||||
m_iconIndex.close();
|
||||
}
|
||||
|
||||
//处理svg转png,获取svg文件
|
||||
QString m_buildIcondirPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/iconTheme/appicon/";
|
||||
QString m_buildAppIconPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/iconTheme/appicon/";
|
||||
QString m_buildSystemIconPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/iconTheme/systemicon/";
|
||||
QDir m_buildAppIconDir = m_buildAppIconPath;
|
||||
QDir m_buildSystemIconDir = m_buildSystemIconPath;
|
||||
|
||||
QDir m_buildIcondir(m_buildIcondirPath);
|
||||
// 设置过滤器,仅获取 .svg 文件
|
||||
QStringList m_appIconNameFilters;
|
||||
m_appIconNameFilters << "*.svg";
|
||||
m_buildAppIconDir.setNameFilters(m_appIconNameFilters);
|
||||
QStringList m_systemIconNameFilters;
|
||||
m_systemIconNameFilters << "*.svg";
|
||||
m_buildSystemIconDir.setNameFilters(m_systemIconNameFilters);
|
||||
|
||||
if (!m_buildIcondir.exists()) {
|
||||
qDebug() << "Directory does not exist.";
|
||||
}
|
||||
// 获取源目录中的文件列表
|
||||
QStringList m_appIconfiles = m_buildAppIconDir.entryList(QDir::Files);
|
||||
QStringList m_systemIconfiles = m_buildSystemIconDir.entryList(QDir::Files);
|
||||
|
||||
QStringList m_svgFilters;
|
||||
m_svgFilters << "*.svg"; // 指定扩展名为 .svg
|
||||
if(!m_appIconfiles.isEmpty()||!m_systemIconfiles.isEmpty()){
|
||||
|
||||
m_buildIcondir.setNameFilters(m_svgFilters);
|
||||
m_buildIcondir.setFilter(QDir::Files | QDir::NoSymLinks);
|
||||
QString m_imageThemeScalablePath = m_imageDirThemePath + "/scalable";
|
||||
QString m_imageThemeScalableAppsPath = m_imageThemeScalablePath + "/apps";
|
||||
QDir m_buildSystemIcondirDir = m_imageThemeScalablePath;
|
||||
QDir m_imageThemeScalableAppsDir = m_imageThemeScalableAppsPath;
|
||||
m_buildSystemIcondirDir.mkdir(m_buildSystemIcondirDir.absolutePath());
|
||||
m_imageThemeScalableAppsDir.mkdir(m_imageThemeScalableAppsDir.absolutePath());
|
||||
//写入icon index.theme文件
|
||||
if (m_iconIndex.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
|
||||
m_iconIndexStream << endl << QStringLiteral("# Directory list");
|
||||
m_iconIndexStream << endl << QStringLiteral("Directories=16x16/apps,24x24/apps,32x32/apps,48x48/apps,64x64/apps,96x96/apps,128x128/apps,256x256/apps,scalable/apps");
|
||||
m_iconIndexStream << endl << QStringLiteral("# Applications");
|
||||
m_iconIndexStream << endl << QStringLiteral("[scalable/apps]");
|
||||
m_iconIndexStream << endl << QStringLiteral("Context=Applications");
|
||||
m_iconIndexStream << endl << QStringLiteral("Size=16");
|
||||
m_iconIndexStream << endl << QStringLiteral("MinSize=16");
|
||||
m_iconIndexStream << endl << QStringLiteral("MaxSize=256");
|
||||
m_iconIndexStream << endl << QStringLiteral("Type=Scalable");
|
||||
m_iconIndexStream << endl;
|
||||
|
||||
QFileInfoList m_svgFileInfoList = m_buildIcondir.entryInfoList();
|
||||
m_iconIndexStream.flush();
|
||||
m_iconIndex.close();
|
||||
}
|
||||
// 遍历文件列表并拷贝到目标目录
|
||||
foreach (const QString &m_appIconFile, m_appIconfiles) {
|
||||
QString sourceFilePath = m_buildAppIconDir.filePath(m_appIconFile);
|
||||
QString destinationFilePath = m_imageThemeScalableAppsDir.filePath(m_appIconFile);
|
||||
|
||||
// 遍历获取文件名
|
||||
foreach (QFileInfo m_svgFileInfo, m_svgFileInfoList) {
|
||||
QString m_fileName = m_svgFileInfo.fileName();
|
||||
QFile sourceFile(sourceFilePath);
|
||||
QFile destinationFile(destinationFilePath);
|
||||
|
||||
//处理svg转png
|
||||
QSvgRenderer m_svgRenderer;
|
||||
m_svgRenderer.load(m_fileName);
|
||||
// 如果源文件可以打开,并且目标文件可以创建
|
||||
if (sourceFile.open(QIODevice::ReadOnly) && destinationFile.open(QIODevice::WriteOnly)) {
|
||||
// 从源文件读取数据
|
||||
QByteArray data = sourceFile.readAll();
|
||||
|
||||
//遍历、创建尺寸目录,并拷贝生成png
|
||||
int array[] = {16, 24, 32, 48, 64, 96, 128, 256};
|
||||
int length = sizeof(array) / sizeof(array[0]);
|
||||
// 将数据写入目标文件
|
||||
destinationFile.write(data);
|
||||
|
||||
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()));
|
||||
|
||||
//生成尺寸目录
|
||||
QString m_imageDirThemeSizePath = m_imageDirThemePath +"/" + QString::number(array[i]) + "x" + QString::number(array[i]);
|
||||
QString m_imageDirThemeAppsPath = m_imageDirThemeSizePath+ "/apps";
|
||||
QDir m_imageThemeSizeDir = m_imageDirThemeSizePath;
|
||||
QDir m_imageDirThemeAppDir = m_imageDirThemeAppsPath;
|
||||
m_imageThemeSizeDir.mkdir(m_imageThemeSizeDir.absolutePath());
|
||||
m_imageDirThemeAppDir.mkdir(m_imageDirThemeAppDir.absolutePath());
|
||||
|
||||
//拷贝图片
|
||||
m_fileName.replace(".svg", ".png");
|
||||
image.save(m_imageDirThemeAppsPath+"/"+m_fileName);
|
||||
|
||||
if (m_iconIndex.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
|
||||
qDebug()<< m_iconIndex;
|
||||
m_iconIndexStream << endl << QStringLiteral("[")+QString::number(array[i])+QStringLiteral("x")+QString::number(array[i])+QStringLiteral("/apps]");
|
||||
m_iconIndexStream << endl << QStringLiteral("Context=Applications");
|
||||
m_iconIndexStream << endl << QStringLiteral("Size=")+QString::number(array[i]);
|
||||
m_iconIndexStream << endl << QStringLiteral("Type=Fixed");
|
||||
m_iconIndexStream << endl;
|
||||
|
||||
m_iconIndexStream.flush();
|
||||
m_iconIndex.close();
|
||||
// 关闭文件
|
||||
sourceFile.close();
|
||||
destinationFile.close();
|
||||
}
|
||||
}
|
||||
foreach (const QString &m_systemIconfile, m_systemIconfiles) {
|
||||
QString sourceFilePath = m_buildAppIconDir.filePath(m_systemIconfile);
|
||||
QString destinationFilePath = m_imageThemeScalableAppsDir.filePath(m_systemIconfile);
|
||||
|
||||
QFile sourceFile(sourceFilePath);
|
||||
QFile destinationFile(destinationFilePath);
|
||||
|
||||
if (sourceFile.open(QIODevice::ReadOnly) && destinationFile.open(QIODevice::WriteOnly)) {
|
||||
QByteArray data = sourceFile.readAll();
|
||||
destinationFile.write(data);
|
||||
sourceFile.close();
|
||||
destinationFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList m_svgFilters;
|
||||
m_svgFilters << "*.svg"; // 指定扩展名为 .svg
|
||||
|
||||
m_imageThemeScalableAppsDir.setNameFilters(m_svgFilters);
|
||||
m_imageThemeScalableAppsDir.setFilter(QDir::Files | QDir::NoSymLinks);
|
||||
|
||||
QFileInfoList m_svgFileInfoList = m_imageThemeScalableAppsDir.entryInfoList();
|
||||
|
||||
// 遍历获取文件名
|
||||
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()));
|
||||
|
||||
//生成尺寸目录
|
||||
QString m_imageDirThemeSizePath = m_imageDirThemePath +"/" + QString::number(array[i]) + "x" + QString::number(array[i]);
|
||||
QString m_imageDirThemeAppsPath = m_imageDirThemeSizePath+ "/apps";
|
||||
QDir m_imageThemeSizeDir = m_imageDirThemeSizePath;
|
||||
QDir m_imageDirThemeAppDir = m_imageDirThemeAppsPath;
|
||||
m_imageThemeSizeDir.mkdir(m_imageThemeSizeDir.absolutePath());
|
||||
m_imageDirThemeAppDir.mkdir(m_imageDirThemeAppDir.absolutePath());
|
||||
|
||||
//拷贝图片
|
||||
m_fileName.replace(".svg", ".png");
|
||||
image.save(m_imageDirThemeAppsPath+"/"+m_fileName);
|
||||
|
||||
if (m_iconIndex.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
|
||||
qDebug()<< m_iconIndex;
|
||||
m_iconIndexStream << endl << QStringLiteral("[")+QString::number(array[i])+QStringLiteral("x")+QString::number(array[i])+QStringLiteral("/apps]");
|
||||
m_iconIndexStream << endl << QStringLiteral("Context=Applications");
|
||||
m_iconIndexStream << endl << QStringLiteral("Size=")+QString::number(array[i]);
|
||||
m_iconIndexStream << endl << QStringLiteral("Type=Fixed");
|
||||
m_iconIndexStream << endl;
|
||||
|
||||
m_iconIndexStream.flush();
|
||||
m_iconIndex.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
qDebug()<<"svg images doesn't exits!!!";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//光标打包
|
||||
|
|
|
@ -345,7 +345,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
|
|||
m_globalMesonStream << QStringLiteral("globaltheme_dir = join_paths(get_option('prefix'), 'share/config/globaltheme/')");
|
||||
m_globalMesonStream << endl << QStringLiteral("platformconfig_dir = join_paths(get_option('prefix'), 'share/qt5-ukui-platformtheme/themeconfig/')");
|
||||
m_globalMesonStream << endl;
|
||||
m_globalMesonStream << endl << QStringLiteral("global_d = ['theme.conf']");
|
||||
m_globalMesonStream << endl << QStringLiteral("global_d = ['theme.conf','preview.png']");
|
||||
m_globalMesonStream << endl;
|
||||
m_globalMesonStream << endl << QStringLiteral("foreach global: global_d");
|
||||
m_globalMesonStream << endl << QStringLiteral(" install_data(global, install_dir: globaltheme_dir/'")+ FileProcess::g_themeENName +QStringLiteral("')");
|
||||
|
|
Loading…
Reference in New Issue