fix I8US9N
This commit is contained in:
parent
229bc7749f
commit
4b484326a0
|
@ -228,5 +228,6 @@
|
|||
<file>resource/background/grub-background.png</file>
|
||||
<file>resource/config/json.txt</file>
|
||||
<file>resource/blacklist.txt</file>
|
||||
<file>resource/mimetypes/application-x-desktop.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 5.1 KiB |
|
@ -173,34 +173,101 @@ void buildCheckWidget::buildForIcon(){
|
|||
m_systemIconNameFilters << "*.svg";
|
||||
m_buildSystemIconDir.setNameFilters(m_systemIconNameFilters);
|
||||
|
||||
// 拷贝mimetypes文件
|
||||
|
||||
QString m_iconThemeScalablePath = m_buildIconThemePath + "/scalable";
|
||||
QString m_iconThemeScalableMimePath = m_iconThemeScalablePath + "/mimetypes";
|
||||
QDir m_buildSystemIcondirDir = m_iconThemeScalablePath;
|
||||
QDir m_iconThemeScalableMimeDir = m_iconThemeScalableMimePath;
|
||||
m_buildSystemIcondirDir.mkdir(m_buildSystemIcondirDir.absolutePath());
|
||||
m_iconThemeScalableMimeDir.mkdir(m_iconThemeScalableMimeDir.absolutePath());
|
||||
|
||||
QStringList m_mimeIconNameFilters;
|
||||
m_mimeIconNameFilters << "*.svg";
|
||||
m_iconThemeScalableMimeDir.setNameFilters(m_systemIconNameFilters);
|
||||
|
||||
//写入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,16x16/mimetypes,24x24/mimetypes,32x32/mimetypes,48x48/mimetypes,64x64/mimetypes,96x96/mimetypes,128x128/mimetypes,256x256/mimetypes,scalable/mimetypes");
|
||||
m_iconIndexStream << endl;
|
||||
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 << endl << QStringLiteral("[scalable/mimetypes]");
|
||||
m_iconIndexStream << endl << QStringLiteral("Context=Mimetypes");
|
||||
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();
|
||||
}
|
||||
|
||||
QFile::copy(":/resource/mimetypes/application-x-desktop.svg",m_iconThemeScalableMimePath+"/application-x-desktop.svg");
|
||||
QFileInfoList m_svgMimeFileInfoList = m_iconThemeScalableMimeDir.entryInfoList(QDir::Files);
|
||||
foreach (QFileInfo m_svgMimeFileInfo, m_svgMimeFileInfoList) {
|
||||
//处理svg转png
|
||||
//遍历、创建尺寸目录,并拷贝生成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++) {
|
||||
|
||||
// 初始化一个 SVG 渲染器
|
||||
QSvgRenderer svgRenderer(m_svgMimeFileInfo.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_imageDirThemeMimePath = m_imageDirThemeSizePath+ "/mimetypes";
|
||||
QDir m_imageThemeSizeDir = m_imageDirThemeSizePath;
|
||||
QDir m_imageDirThemeMimeDir = m_imageDirThemeMimePath;
|
||||
m_imageThemeSizeDir.mkdir(m_imageThemeSizeDir.absolutePath());
|
||||
m_imageDirThemeMimeDir.mkdir(m_imageDirThemeMimeDir.absolutePath());
|
||||
|
||||
// 将 QImage 对象保存为 PNG 文件
|
||||
QString m_fileName = m_svgMimeFileInfo.baseName();
|
||||
image.save(m_imageDirThemeMimePath+"/"+m_fileName+".png");
|
||||
|
||||
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("/mimetypes]");
|
||||
m_iconIndexStream << endl << QStringLiteral("Context=Mimetypes");
|
||||
m_iconIndexStream << endl << QStringLiteral("Size=")+QString::number(array[i]);
|
||||
m_iconIndexStream << endl << QStringLiteral("Type=Fixed");
|
||||
m_iconIndexStream << endl;
|
||||
|
||||
m_iconIndexStream.flush();
|
||||
m_iconIndex.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取源目录中的文件列表
|
||||
QStringList m_appIconfiles = m_buildAppIconDir.entryList(QDir::Files);
|
||||
QStringList m_systemIconfiles = m_buildSystemIconDir.entryList(QDir::Files);
|
||||
|
||||
if(!m_appIconfiles.isEmpty()||!m_systemIconfiles.isEmpty()){
|
||||
|
||||
QString m_iconThemeScalablePath = m_buildIconThemePath + "/scalable";
|
||||
QString m_iconThemeScalableAppsPath = m_iconThemeScalablePath + "/apps";
|
||||
QDir m_buildSystemIcondirDir = m_iconThemeScalablePath;
|
||||
QDir m_iconThemeScalableAppsDir = m_iconThemeScalableAppsPath;
|
||||
m_buildSystemIcondirDir.mkdir(m_buildSystemIcondirDir.absolutePath());
|
||||
m_iconThemeScalableAppsDir.mkdir(m_iconThemeScalableAppsDir.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;
|
||||
|
||||
m_iconIndexStream.flush();
|
||||
m_iconIndex.close();
|
||||
}
|
||||
// 遍历文件列表并拷贝到目标目录
|
||||
foreach (const QString &m_appIconFile, m_appIconfiles) {
|
||||
QString sourceFilePath = m_buildAppIconDir.filePath(m_appIconFile);
|
||||
|
|
Loading…
Reference in New Issue