add desktop file

This commit is contained in:
like 2024-05-23 14:38:06 +08:00
parent 8989ff5b6c
commit 790a2bc59a
10 changed files with 113 additions and 9 deletions

View File

@ -256,5 +256,6 @@
<file>resource/places/user-home.png</file>
<file>resource/places/user-trash-full.png</file>
<file>resource/places/user-trash.png</file>
<file>resource/theme.desktop</file>
</qresource>
</RCC>

3
resource/theme.desktop Normal file
View File

@ -0,0 +1,3 @@
[Desktop Entry]
Name=
Type=Application

View File

@ -187,9 +187,6 @@ void Bridge::createConfig()
+m_time+"/src/globalTheme","cover");
m_configfilemanager->copyPictoCacheDir(m_wallpaperpath,QDir::homePath()+"/.cache/theme-build/"
+m_time+"/src/globalTheme","wallpaper");
m_configfilemanager->createSetupConf(QDir::homePath() + "/.cache/theme-build/"
+ m_time + "/src/setupConfig/");
}
void Bridge::createGrub()
@ -209,6 +206,18 @@ void Bridge::createSavePathConfig()
m_configfilemanager->createSavePathConfig();
}
void Bridge::creatDesktop()
{
m_configfilemanager->createDesktop(QDir::homePath()+"/.cache/theme-build/"
+m_time+"/src/application/");
}
void Bridge::createSetupConf()
{
m_configfilemanager->createSetupConf(QDir::homePath() + "/.cache/theme-build/"
+ m_time + "/src/setupConfig/");
}
void Bridge::updateIconCache(QMap<QString, QString> *iconsmaps, QString icontype)
{
if(icontype == "appicon"){
@ -237,6 +246,8 @@ void Bridge::ThemeNameChanged()
{
m_configfilemanager->modifyFocalXml(QDir::homePath() + "/.cache/theme-build/"
+ m_time + "/src/globalTheme/wallpaper/kylin-theme-builder-focal.xml");
m_configfilemanager->modifyDesktop(QDir::homePath() + "/.cache/theme-build/"
+ m_time + "/src/application/"+FileProcess::g_themeENName+".desktop");
}

View File

@ -54,6 +54,8 @@ public:
void createGrub();
void createPlymouth();
void createSavePathConfig();
void creatDesktop();
void createSetupConf();
void updateIconCache(QMap<QString, QString> *iconsmaps,QString icontype);
void ThemeNameChanged();

View File

@ -125,6 +125,23 @@ bool ConfigFileManager::createFocalXml(QDir cachedir)
}
}
bool ConfigFileManager::createDesktop(QDir cachedir)
{
QString m_desktopPath = cachedir.absolutePath();
QString filePath = m_desktopPath + "/theme.desktop";
QDir dir;
if (!dir.exists(m_desktopPath)) {
dir.mkpath(m_desktopPath);
}
if (copyFileContent(":/resource/theme.desktop", filePath)) {
return true;
} else {
return false;
}
}
bool ConfigFileManager::createSetupConf(QDir cachedir)
{
QString m_themePath = cachedir.absolutePath();
@ -526,6 +543,37 @@ bool ConfigFileManager::modifyFocalXml(QString focalXmlPath)
return true;
}
bool ConfigFileManager::modifyDesktop(QString desktop)
{
QString themeName = FileProcess::g_themeENName;
// 读取文件内容
QFile file(desktop);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "无法打开文件:" << desktop;
return false;
}
QTextStream in(&file);
QString content = in.readAll();
file.close();
// 替换文件名
QString newFilename = "Name=" + themeName;
content.replace("Name=", newFilename);
// 写入修改后的内容到文件
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "无法写入文件:" << desktop;
return false;
}
QTextStream out(&file);
out << content;
file.close();
return true;
}
bool ConfigFileManager::modifySavePathConf(QString savePath)
{
QString dirPath = QDir::homePath() + "/.cache/theme-build";

View File

@ -44,6 +44,7 @@ public:
bool createFocalXml(QDir cachedir);
bool createSetupConf(QDir cachedir);
bool createSavePathConfig();
bool createDesktop(QDir cachedir);
bool modifyRadiusJson(int radius,QString jsonFilePath);
bool modifyAccentColorConf(QColor accentcolor,QString confFilePath);
@ -53,6 +54,7 @@ public:
bool modifyTransparencyConf(int transparency,QString confFilePath);
bool modifywindowRadiusConf(int windowradius,QString confFilePath);
bool modifyFocalXml(QString focalXmlPath);
bool modifyDesktop(QString desktop);
bool modifySavePathConf(QString savePath);
bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath);

View File

@ -75,11 +75,13 @@ void FileProcess::FileCreate(const QString &m_themeType){
QDir m_builderSrc = m_builderPathSrc;
QDir m_builderDeb = m_builderPathSrc + "/debian";
QDir m_themeTypePath = m_builderPathSrc + "/" + m_themeType;
QDir appPath = m_builderPathSrc+ "/application";
m_builderTime.mkdir(m_builderTime.absolutePath());
m_builderSrc.mkdir(m_builderSrc.absolutePath());
m_builderDeb.mkdir(m_builderDeb.absolutePath());
m_themeTypePath.mkdir(m_themeTypePath.absolutePath());
appPath.mkdir(appPath.absolutePath());
QDir iconPath = m_builderPathSrc+ "/iconTheme";
QDir cursorPath = m_builderPathSrc+ "/cursorTheme";

View File

@ -299,9 +299,11 @@ void MainWindow::initUI()
m_bridge->updateIconCache(m_maininterface->getTimeCurosrMap(),"timecursor");
m_bridge->createConfig();
m_bridge->createGrub();
m_bridge->createPlymouth();
m_bridge->creatDesktop();
m_bridge->createSetupConf();
m_maininterface->refresh("global");
m_maininterface->refresh("icon");
m_maininterface->refresh("cursor");
@ -322,7 +324,8 @@ void MainWindow::initUI()
m_maininterface->refresh("icon");
m_maininterface->hideNavigation(false);
m_maininterface->setBuildBtnText(false);
m_bridge->creatDesktop();
m_bridge->createSetupConf();
} else if (button == m_cursorbtn) {
DataCollect::sendMainWindowKdkDataAsync(DataCollect::m_CursorTheme);
m_maininterface->setCursorTheme();
@ -333,7 +336,8 @@ void MainWindow::initUI()
m_maininterface->refresh("cursor");
m_maininterface->hideNavigation(false);
m_maininterface->setBuildBtnText(false);
m_bridge->creatDesktop();
m_bridge->createSetupConf();
}else if (button == m_plymouthbtn) {
DataCollect::sendMainWindowKdkDataAsync(DataCollect::m_PlymouthTheme);
m_maininterface->setPlymouthTheme();
@ -344,7 +348,8 @@ void MainWindow::initUI()
m_maininterface->refresh("plymouth");
m_maininterface->hideNavigation(false);
m_maininterface->setBuildBtnText(false);
m_bridge->creatDesktop();
m_bridge->createSetupConf();
}else if (button == m_grubbtn) {
DataCollect::sendMainWindowKdkDataAsync(DataCollect::m_GrubTheme);
m_maininterface->setGrubTheme();
@ -354,7 +359,8 @@ void MainWindow::initUI()
m_maininterface->refresh("grub");
m_maininterface->hideNavigation(false);
m_maininterface->setBuildBtnText(false);
m_bridge->creatDesktop();
m_bridge->createSetupConf();
}
if (false == m_historywidget->isVisible()) {

View File

@ -424,6 +424,15 @@ void InfoCreateWidget::InitDefaultInstallment()
});
}
void InfoCreateWidget::renameDesktop()
{
QString m_date= FileProcess::g_date;
//修改desktop文件名为theme-name.desktop
QFile m_desktop(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/application/theme.desktop");
m_desktop.rename(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/application/"+FileProcess::g_themeENName+".desktop");
}
void InfoCreateWidget::createControlChangelog(const QString &m_date){
//点击生成制作主题包按钮时m_date将设为空
qDebug()<<m_date;
@ -476,7 +485,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
qDebug()<< m_meson;
QTextStream m_mesonStream(&m_meson);
m_mesonStream << QStringLiteral("project('")+ FileProcess::g_themeENName +QStringLiteral("','c',default_options: ['prefix=/usr/'])");
m_mesonStream << endl << QStringLiteral("components_d = ['globalTheme', 'iconTheme', 'cursorTheme','plymouthTheme','grubTheme','setupConfig']");
m_mesonStream << endl << QStringLiteral("components_d = ['globalTheme', 'iconTheme', 'cursorTheme','plymouthTheme','grubTheme','setupConfig','application']");
m_mesonStream << endl;
m_mesonStream << endl << QStringLiteral("foreach component: components_d");
m_mesonStream << endl << QStringLiteral("if get_option(component)");
@ -498,6 +507,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: true, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: true, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: true, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "iconTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: true, description:'build ukui icons theme')");
@ -505,6 +515,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: false, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: false, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: true, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "cursorTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: false, description:'build ukui icons theme')");
@ -512,6 +523,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: false, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: false, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: true, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "plymouthTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: false, description:'build ukui icons theme')");
@ -519,6 +531,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: true, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: false, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: true, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "grubTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: false, description:'build ukui icons theme')");
@ -526,6 +539,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: false, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: true, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: true, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else {
qDebug() << FileProcess::g_createThemeType;
}
@ -537,6 +551,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: true, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: true, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: false, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "iconTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: true, description:'build ukui icons theme')");
@ -544,6 +559,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: false, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: false, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: false, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "cursorTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: false, description:'build ukui icons theme')");
@ -551,6 +567,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: false, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: false, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: false, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "plymouthTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: false, description:'build ukui icons theme')");
@ -558,6 +575,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: true, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: false, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: false, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else if(FileProcess::g_createThemeType == "grubTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: false, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: false, description:'build ukui icons theme')");
@ -565,6 +583,7 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_mesonOptionStream << endl << QStringLiteral("option('plymouthTheme', type: 'boolean', value: false, description:'build ukui plymouth theme')");
m_mesonOptionStream << endl << QStringLiteral("option('grubTheme', type: 'boolean', value: true, description:'build ukui grub theme')");
m_mesonOptionStream << endl << QStringLiteral("option('setupConfig', type: 'boolean', value: false, description:'Set to default during installation')");
m_mesonOptionStream << endl << QStringLiteral("option('application', type: 'boolean', value: true, description:'theme desktop')");
} else {
qDebug() << FileProcess::g_createThemeType;
}
@ -687,6 +706,15 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_setupMesonStream << endl << QStringLiteral("install_data('theme-builder-change.conf', install_dir: setupconf_dir)");
m_setupMesonStream << endl << QStringLiteral("install_data('40_kylin-theme-builder.gschema.override', install_dir: setupschemas_dir)");
}
renameDesktop();
QFile m_applicationMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/application/meson.build");
if (m_applicationMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_applicationStream(&m_applicationMeson);
m_applicationStream << endl << QStringLiteral("app_dir = join_paths('/usr/share/kylin-theme-builder/desktops/')");
m_applicationStream << endl << QStringLiteral("install_data('")+FileProcess::g_themeENName+(".desktop', install_dir: app_dir)");
}
this->close();
}
}

View File

@ -39,6 +39,7 @@ public:
void InfoCreateBtn();
void InitDefaultInstallment();
void renameDesktop();
QString m_builderMail;
QString m_builderName;