!41 add icon globaltheme build

Merge pull request !41 from KevinDuan/2.0
This commit is contained in:
likehomedream 2023-11-08 03:19:07 +00:00 committed by Gitee
commit e79ccbc03e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
32 changed files with 554 additions and 153 deletions

View File

@ -17,8 +17,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
src/build/buildWidget.cpp \
src/build/buildcheck.cpp \
src/build/buildcheckwidget.cpp \
src/build/buildresultwidget.cpp \
src/fileProcess/bridge.cpp \
src/fileProcess/diroperation.cpp \
src/fileProcess/filecheck.cpp \
@ -48,6 +48,7 @@ HEADERS += \
src/build/build.h \
src/build/buildWidget.h \
src/build/buildcheckwidget.h \
src/build/buildresultwidget.h \
src/fileProcess/bridge.h \
src/fileProcess/diroperation.h \
src/fileProcess/filecheck.h \

View File

@ -3,8 +3,8 @@
#include "../fileProcess/fileprocess.h"
#include "../module/infocreatewidget.h"
#include <QProgressBar>
#include <QProgressBar>
#include <QObject>
#include <QCoreApplication>
#include <QThread>

View File

@ -29,6 +29,15 @@ buildWidget::buildWidget(QWidget *parent)
//清空日期缓存
FileProcess::g_date = nullptr;
FileProcess::g_themeENName = nullptr;
FileProcess::g_createThemeType = nullptr;
//完成返回界面
buildResultWidget *m_buildResult = new buildResultWidget();
m_buildResult->show();
connect(m_buildResult,&buildResultWidget::gohomesignals, this,[=](){
//发送返回主界面信号
emit gohomesignals();
});
}
});
}

View File

@ -2,6 +2,7 @@
#define BUILDWIDGET_H
#include "build.h"
#include "buildresultwidget.h"
#include <QObject>
#include <QWidget>
@ -19,10 +20,14 @@ class buildWidget : public QWidget
public:
explicit buildWidget(QWidget *parent = nullptr);
signals:
void gohomesignals();
private:
QVBoxLayout *m_buildLayout;
QLabel *m_buildMessage;
QProgressBar *m_buildProgressBar;
};
#endif // BUILDWIDGET_H

View File

@ -4,15 +4,3 @@ buildCheck::buildCheck()
{
}
QString buildCheck::globalThemeCheck(){
}
QString buildCheck::iconThemeCheck(){
}
QString buildCheck::cursorThemeCheck(){
}

View File

@ -10,9 +10,6 @@ public:
buildCheck();
private:
QString iconThemeCheck();
QString cursorThemeCheck();
QString globalThemeCheck();
};
#endif // BUILDCHECK_H

View File

@ -5,6 +5,7 @@ buildCheckWidget::buildCheckWidget(QWidget *parent)
{
}
// 编译前拷贝必须文件
void buildCheckWidget::buildCopy(){
m_debSourceFormat = ":/resource/debian/source/format";
@ -26,65 +27,227 @@ void buildCheckWidget::buildCopy(){
qDebug()<<QFile::copy(m_debRules,m_debPath+"/debian/rules") ;
qDebug()<<QFile::copy(m_debCopyRight,m_debPath+"/debian/copyright");
}
}
void buildCheckWidget::buildCheck(QDir m_buildIconPath){
void buildCheckWidget::buildForGlobal(){
buildForIcon();
buildForCursor();
}
bool buildCheckState = true;
// // 设置过滤器,只获取文件和目录
// m_buildIconPath.setFilter(QDir::Files|QDir::Dirs| QDir::NoDotAndDotDot);
//图标打包
void buildCheckWidget::buildForIcon(){
// // 获取目录下的所有文件和目录
// QFileInfoList fileList = m_buildIconPath.entryInfoList();
// qDebug()<<fileList;
// // 遍历文件和目录
// foreach(const QFileInfo& fileInfo, fileList)
// {
// qDebug()<<fileInfo;
// if (fileInfo.isFile()){
// if(FileCheck::isLegalIconFile(fileInfo.absoluteFilePath())){
// qDebug() << fileInfo.absoluteFilePath();
// } else {
// qDebug() << "warning:" << fileInfo.absoluteFilePath();
// buildCheckState = false;
// }
// } else if (fileInfo.isDir()){
// qDebug() << fileInfo.absoluteFilePath();
// buildCheck(QDir(fileInfo.absoluteFilePath()));
// } else {
// qDebug() << "warning:" << fileInfo.absoluteFilePath();
// buildCheckState = false;
// }
QString m_imageDirThemePath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/iconTheme/"
+ FileProcess::g_themeENName;
QDir m_imageDirThemeDir = m_imageDirThemePath;
m_imageDirThemeDir.mkdir(m_imageDirThemeDir.absolutePath());
QFile m_iconIndex(m_imageDirThemePath+"/index.theme");
QTextStream m_iconIndexStream(&m_iconIndex);
//写入icon index.theme文件
if (m_iconIndex.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
qDebug()<< m_iconIndex;
m_iconIndexStream << QStringLiteral("[Icon Theme]");
m_iconIndexStream << endl << QStringLiteral("Name=")+ FileProcess::g_themeENName;
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/";
QDir m_buildIcondir(m_buildIcondirPath);
if (!m_buildIcondir.exists()) {
qDebug() << "Directory does not exist.";
}
QStringList m_svgFilters;
m_svgFilters << "*.svg"; // 指定扩展名为 .svg
m_buildIcondir.setNameFilters(m_svgFilters);
m_buildIcondir.setFilter(QDir::Files | QDir::NoSymLinks);
QFileInfoList m_svgFileInfoList = m_buildIcondir.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();
}
}
}
}
//光标打包
void buildCheckWidget::buildForCursor(){
}
//编译检查
void buildCheckWidget::buildCheck(QDir m_buildPath){
//获取基础资源文件
// QDir appicons = ":/resource/appicons/";
// QDir systemIcons = ":/resource/systemicons";
// QCryptographicHash hash(QCryptographicHash::Md5);
// QStringList appIconFiles = appicons.entryList(QDir::Files);
// foreach(QString appIconFile, appIconFiles){
// appIconInfo[appIconFile] = appIconInfoID;
// appIconInfoID++;
// }
// QStringList systemIconFiles = systemIcons.entryList(QDir::Files);
// foreach(QString systemIconFile, systemIconFiles){
// systemIconInfo[systemIconFile] = systemIconInfoID;
// systemIconInfoID++;
// }
if(buildCheckState){
buildCopy();
buildWidget *m_buildWidget = new buildWidget();
m_buildWidget->show();
} else {
this->setFixedSize(424,480);
this->setWindowModality(Qt::ApplicationModal);
// if (m_buildPath.exists()) {
// qDebug() << "开始遍历目录:" << m_buildPath.absolutePath();
// buildCheckResult(m_buildPath);
m_buildCheckWidget = new QVBoxLayout();
m_buildWarningMessage = new QLabel();
m_buildWarningMessage->setText("导出时检测到以下问题,请调整后重新导出:");
m_warningMessageList = new QLabel();
m_warningMessageList->setText("以下内容有错误");
// for (auto it = appIconInfo.begin(); it != appIconInfo.end(); ++it) {
// const QString appIconInfo = it.key();
m_buildCheckBtnWidget = new QHBoxLayout();
m_buildBtn = new QPushButton();
m_buildBtn->setText("继续导出");
m_exitBuildBtn = new QPushButton();
m_exitBuildBtn->setText("返回");
// // 检查是否 keyA 存在于 QMap B 中
// if (!cacheIconInfo.contains(keyA)) {
// // 如果 keyA 不存在于 QMap B 中,将其添加到 result
// warning[keyA] = it.value();
// }
// }
m_buildCheckBtnWidget->addWidget(m_buildBtn);
m_buildCheckBtnWidget->addWidget(m_exitBuildBtn);
m_buildCheckWidget->addWidget(m_buildWarningMessage);
m_buildCheckWidget->addWidget(m_warningMessageList);
m_buildCheckWidget->addLayout(m_buildCheckBtnWidget);
// if(buildCheckState == 0){
buildCopy();
this->setLayout(m_buildCheckWidget);
this->show();
if(FileProcess::g_createThemeType == "globalTheme"){
buildForGlobal();
} else if(FileProcess::g_createThemeType == "iconTheme"){
buildForIcon();
} else if(FileProcess::g_createThemeType == "cursorTheme"){
buildForCursor();
}
buildWidget *m_buildWidget = new buildWidget();
m_buildWidget->show();
connect(m_buildWidget, &buildWidget::gohomesignals, this,[=](){
//发送返回主界面信号
emit gohomesignals();
});
// } else {
// this->setFixedSize(424,480);
// this->setWindowModality(Qt::ApplicationModal);
// m_buildCheckWidget = new QVBoxLayout();
// m_buildWarningMessage = new QLabel();
// m_buildWarningMessage->setText("导出时检测到以下问题,请调整后重新导出:");
// m_warningMessageList = new QLabel();
// m_warningMessageList->setText("缺少以下素材:");
// m_buildCheckBtnWidget = new QHBoxLayout();
// m_buildBtn = new QPushButton();
// m_buildBtn->setText("继续导出");
// m_exitBuildBtn = new QPushButton();
// m_exitBuildBtn->setText("返回");
// m_buildCheckBtnWidget->addWidget(m_buildBtn);
// m_buildCheckBtnWidget->addWidget(m_exitBuildBtn);
// m_buildCheckWidget->addWidget(m_buildWarningMessage);
// m_buildCheckWidget->addWidget(m_warningMessageList);
// m_buildCheckWidget->addLayout(m_buildCheckBtnWidget);
// this->setLayout(m_buildCheckWidget);
// this->show();
// }
// } else {
// qDebug() << "目录不存在:" << m_buildPath.absolutePath();
// }
}
void buildCheckWidget::buildCheckResult(QDir m_buildPath){
QString path = m_buildPath.absolutePath();
QDir m_buildThemePath = path + "/" + FileProcess::g_createThemeType;
// 设置过滤器,只获取文件和目录
m_buildThemePath.setFilter(QDir::Files|QDir::Dirs| QDir::NoDotAndDotDot);
// 获取目录下的所有文件和目录
QFileInfoList fileList = m_buildThemePath.entryInfoList();
qDebug()<<fileList;
// 遍历文件和目录
foreach(const QFileInfo& fileInfo, fileList)
{
qDebug()<<fileInfo;
if (fileInfo.isFile()){
if(FileCheck::isLegalIconFile(fileInfo.absoluteFilePath())){
// cacheIconInfo[fileInfo] = cacheIconInfoID;
// cacheIconInfoID++;
} else {
qDebug() << "warning:" << fileInfo.absoluteFilePath();
buildCheckState--;
}
} else if (fileInfo.isDir()){
buildCheckResult(QDir(fileInfo.absoluteFilePath()));
} else {
qDebug() << "warning:" << fileInfo.absoluteFilePath();
buildCheckState--;
}
}
}

View File

@ -11,6 +11,7 @@
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCryptographicHash>
class buildCheckWidget : public QWidget
{
@ -18,7 +19,12 @@ class buildCheckWidget : public QWidget
public:
explicit buildCheckWidget(QWidget *parent = nullptr);
void buildCheck(QDir m_buildIconPath);
void buildCheck(QDir m_buildPath);
void buildCheckResult(QDir m_buildPath);
signals:
void gohomesignals();
private:
QVBoxLayout *m_buildCheckWidget;
QLabel *m_buildWarningMessage;
@ -31,7 +37,18 @@ private:
QString m_debRules;
QString m_debCopyRight;
int buildCheckState = 0;
void buildCopy();
void buildForGlobal();
void buildForIcon();
void buildForCursor();
QMap <QString ,int> appIconInfo;
int appIconInfoID = 1;
QMap <QString ,int> systemIconInfo;
int systemIconInfoID = 1;
QMap <QString ,int> cacheIconInfo;
int cacheIconInfoID = 1;
};
#endif // BUILDCHECKWIDGET_H

View File

@ -0,0 +1,25 @@
#include "buildresultwidget.h"
buildResultWidget::buildResultWidget(QWidget *parent)
: QWidget(parent)
{
this->setFixedSize(424,170);
this->setWindowModality(Qt::ApplicationModal);
this->setWindowFlags(Qt::FramelessWindowHint);
m_buildResultLayout = new QVBoxLayout;
m_buildResult = new QLabel;
m_buildResult->setText("主题制作完成!");
m_backHomeBtn = new QPushButton();
m_backHomeBtn->setText("确认");
m_buildResultLayout->addWidget(m_buildResult);
m_buildResultLayout->addWidget(m_backHomeBtn);
this->setLayout(m_buildResultLayout);
connect(m_backHomeBtn, &QPushButton::clicked, this,[=](){
//发送返回主界面信号
emit gohomesignals();
this->close();
});
}

View File

@ -0,0 +1,28 @@
#ifndef BUILDRESULTWIDGET_H
#define BUILDRESULTWIDGET_H
#include <QMainWindow>
#include <QObject>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
#include <QPushButton>
#include <QDebug>
class buildResultWidget : public QWidget
{
Q_OBJECT
public:
explicit buildResultWidget(QWidget *parent = nullptr);
signals:
void gohomesignals();
private:
QVBoxLayout *m_buildResultLayout;
QLabel *m_buildResult;
QPushButton *m_backHomeBtn;
};
#endif // BUILDRESULTWIDGET_H

View File

@ -24,7 +24,8 @@ void Bridge::wallpaperPathChanged(QString path)
void Bridge::coverPathChanged(QString path)
{
m_coverpath = path;
m_configfilemanager->copyCovertoCacheDir(m_coverpath,m_builderConfig);
m_configfilemanager->copyCovertoCacheDir(m_coverpath,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/globalTheme");
}
void Bridge::radiusChanged(int radius)
@ -94,53 +95,58 @@ void Bridge::timeCursorMapChanged(QMap<QString, QString> *timecursormap)
void Bridge::startCopy()
{
if(m_appsiconpathmap){
m_configfilemanager->copyIcontoCacheDir(m_appsiconpathmap,m_builderappicon);
m_configfilemanager->copyIcontoCacheDir(m_appsiconpathmap,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/iconTheme/appicon");
}
if(m_systemiconpathmap){
m_configfilemanager->copyIcontoCacheDir(m_systemiconpathmap,m_buildersystemicon);
m_configfilemanager->copyIcontoCacheDir(m_appsiconpathmap,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/iconTheme/systemicon");
}
if(m_cursorpathmap){
m_configfilemanager->copyIcontoCacheDir(m_cursorpathmap,m_buildercursor);
m_configfilemanager->copyIcontoCacheDir(m_cursorpathmap,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/cursorTheme/cursor");
}
if(m_timecursorpathmap){
m_configfilemanager->copyIcontoCacheDir(m_timecursorpathmap,m_buildertimecursor);
m_configfilemanager->copyIcontoCacheDir(m_timecursorpathmap,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/cursorTheme/timecursor");
}
m_configfilemanager->copyCovertoCacheDir(m_coverpath,m_builderConfig);
m_configfilemanager->copyCovertoCacheDir(m_coverpath,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/globalTheme");
}
void Bridge::updateIconCache(QMap<QString, QString> *appiconsmaps, QString icontype)
{
if(icontype == "appicon"){
m_configfilemanager->copyIcontoCacheDir(appiconsmaps,m_builderappicon);
m_configfilemanager->copyIcontoCacheDir(appiconsmaps,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/iconTheme/appicon");
}
}
void Bridge::createFileManager(bool ishistory,QString time)
{
m_time = time;
m_configfilemanager = new ConfigFileManager(ishistory,time);
createDir();
// createDir();
connect(m_configfilemanager,&ConfigFileManager::updateInfo,this,&Bridge::updateInfo);
}
void Bridge::createDir()
{
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" +m_time;
QString m_themePathSrc = m_themePath + "/src";
QDir m_themePathSrcDir = m_themePathSrc;
m_builderConfig = m_themePathSrc + "/config";
m_builderappicon = m_themePathSrc + "/iconTheme" + "/appicon";
m_buildersystemicon = m_themePathSrc + "/iconTheme" + "/systemicon";
m_buildercursor = m_themePathSrc + "/cursorTheme" + "/cursor";
m_buildertimecursor = m_themePathSrc + "/cursorTheme" + "/timecursor";
//void Bridge::createDir()
//{
// QString m_themePath = QDir::homePath() + "/.cache/theme-build/" +m_time;
// QString m_themePathSrc = m_themePath + "/src";
// QDir m_themePathSrcDir = m_themePathSrc;
//// m_builderConfig = m_themePathSrc + "/config";
// m_builderappicon = m_themePathSrc + "/iconTheme" + "/appicon";
// m_buildersystemicon = m_themePathSrc + "/iconTheme" + "/systemicon";
// m_buildercursor = m_themePathSrc + "/cursorTheme" + "/cursor";
// m_buildertimecursor = m_themePathSrc + "/cursorTheme" + "/timecursor";
m_themePathSrcDir.mkdir(m_themePathSrcDir.absolutePath());
m_builderConfig.mkdir(m_builderConfig.absolutePath());
m_buildericons.mkdir(m_buildericons.absolutePath());
m_builderappicon.mkdir(m_builderappicon.absolutePath());
m_buildersystemicon.mkdir(m_buildersystemicon.absolutePath());
m_buildercursors.mkdir(m_buildercursors.absolutePath());
m_buildercursor.mkdir(m_buildercursor.absolutePath());
m_buildertimecursor.mkdir(m_buildertimecursor.absolutePath());
}
// m_themePathSrcDir.mkdir(m_themePathSrcDir.absolutePath());
// m_builderConfig.mkdir(m_builderConfig.absolutePath());
// m_buildericons.mkdir(m_buildericons.absolutePath());
// m_builderappicon.mkdir(m_builderappicon.absolutePath());
// m_buildersystemicon.mkdir(m_buildersystemicon.absolutePath());
// m_buildercursors.mkdir(m_buildercursors.absolutePath());
// m_buildercursor.mkdir(m_buildercursor.absolutePath());
// m_buildertimecursor.mkdir(m_buildertimecursor.absolutePath());
//}

View File

@ -45,13 +45,13 @@ private:
QString m_wallpaperpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
QString m_coverpath = ":/resource/background/background-light.png";
QDir m_builderConfig;
QDir m_buildericons;
QDir m_builderappicon;
QDir m_buildersystemicon;
QDir m_buildercursors;
QDir m_buildercursor;
QDir m_buildertimecursor;
// QDir m_builderConfig;
// QDir m_buildericons;
// QDir m_builderappicon;
// QDir m_buildersystemicon;
// QDir m_buildercursors;
// QDir m_buildercursor;
// QDir m_buildertimecursor;
};

View File

@ -4,23 +4,24 @@
ConfigFileManager::ConfigFileManager(bool ishistory, const QString& time, QObject *parent) : QObject(parent)
{
//创建json、conf文件到指定目录在这个类里进行修改。
if(!ishistory){
m_time = time;
createConf();
createJson();
}else{
m_time = time;
jsonFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/config/"+ "default.json";
confFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/config/"+ "theme.conf";
qDebug()<<"have";
if(FileProcess::g_createThemeType == "globalTheme"){
if(!ishistory){
m_time = time;
createConf();
createJson();
}else{
m_time = time;
jsonFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/globalTheme/"+ "default.json";
confFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/globalTheme/"+ "theme.conf";
qDebug()<<"have";
}
}
}
bool ConfigFileManager::createJson()
{
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/config/";
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/globalTheme/";
QString filePath = m_themePath + "default.json";
jsonFilePath = filePath;
@ -41,7 +42,7 @@ bool ConfigFileManager::createJson()
bool ConfigFileManager::createConf()
{
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/config/";
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/globalTheme/";
QString filePath = m_themePath + "theme.conf";
confFilePath = filePath;

View File

@ -1,6 +1,8 @@
#ifndef CONFIGFILEMANAGER_H
#define CONFIGFILEMANAGER_H
#include "../fileProcess/fileprocess.h"
#include <QObject>
#include <QColor>
#include <QJsonDocument>

View File

@ -2,6 +2,8 @@
#define DIROPERATION_H
#include <QObject>
#include <QDebug>
#include <QDir>
class DirOperation : public QObject
{
@ -9,6 +11,7 @@ class DirOperation : public QObject
public:
explicit DirOperation(QObject *parent = nullptr);
void DeleteHistoryDir(const QString& date);
signals:
};

View File

@ -2,6 +2,7 @@
QString FileProcess::g_date;
QString FileProcess::g_themeENName;
QString FileProcess::g_createThemeType;
FileProcess::FileProcess()
{
//创建缓存目录
@ -66,17 +67,38 @@ QString FileProcess::FileCreate(const QString &m_themeType){
QDir m_builderDeb = m_builderPathSrc + "/debian";
QDir m_themeTypePath = m_builderPathSrc + "/" + m_themeType;
m_builderTime.mkdir(m_builderTime.absolutePath());
m_builderSrc.mkdir(m_builderSrc.absolutePath());
m_builderDeb.mkdir(m_builderDeb.absolutePath());
m_themeTypePath.mkdir(m_themeTypePath.absolutePath());
QDir iconPath = m_builderPathSrc+ "/iconTheme";
QDir cursorPath = m_builderPathSrc+ "/cursorTheme";
QDir appiconPath = m_builderPathSrc + "/iconTheme" + "/appicon";
QDir systemiconPath = m_builderPathSrc + "/iconTheme" + "/systemicon";
QDir cursorIconPath = m_builderPathSrc + "/cursorTheme" + "/cursor";
QDir timecursorPath = m_builderPathSrc + "/cursorTheme" + "/timecursor";
if(m_themeType == "globalTheme"){
QDir iconPath = m_builderPathSrc+ "/iconTheme";
QDir cursorPath = m_builderPathSrc+ "/cursorTheme";
iconPath.mkdir(iconPath.absolutePath());
cursorPath.mkdir(cursorPath.absolutePath());
appiconPath.mkdir(appiconPath.absolutePath());
systemiconPath.mkdir(systemiconPath.absolutePath());
cursorIconPath.mkdir(cursorIconPath.absolutePath());
timecursorPath.mkdir(timecursorPath.absolutePath());
} else if (m_themeType == "iconTheme"){
iconPath.mkdir(iconPath.absolutePath());
appiconPath.mkdir(appiconPath.absolutePath());
systemiconPath.mkdir(systemiconPath.absolutePath());
} else if (m_themeType == "cursorTheme"){
cursorPath.mkdir(cursorPath.absolutePath());
cursorIconPath.mkdir(cursorIconPath.absolutePath());
timecursorPath.mkdir(timecursorPath.absolutePath());
}
m_themeTypePath.mkdir(m_themeTypePath.absolutePath());
FileProcess::g_createThemeType = m_themeType;
return g_date;
}

View File

@ -20,9 +20,11 @@ public:
static QString g_date;
static QString g_themeENName;
static QString g_createThemeType;
private:
QDir m_builder;
};
#endif // FILEPROCESS_H

View File

@ -112,7 +112,7 @@ void HistoryInfoLoad::getRadius()
void HistoryInfoLoad::getWallpaper()
{
QString filePath = m_historyInfo.filepath + "/src/config/theme.conf";
QString filePath = m_historyInfo.filepath + "/src/globalTheme/theme.conf";
// 读取文件内容
QFile file(filePath);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
@ -144,7 +144,7 @@ void HistoryInfoLoad::getWallpaper()
void HistoryInfoLoad::getAccentColor()
{
QString filePath = m_historyInfo.filepath + "/src/config/theme.conf";
QString filePath = m_historyInfo.filepath + "/src/globalTheme/theme.conf";
// 读取文件内容
QFile file(filePath);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
@ -174,7 +174,7 @@ void HistoryInfoLoad::getAccentColor()
void HistoryInfoLoad::getTransparency()
{
QString filePath = m_historyInfo.filepath + "/src/config/theme.conf";
QString filePath = m_historyInfo.filepath + "/src/globalTheme/theme.conf";
// 读取文件内容
QFile file(filePath);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
@ -210,7 +210,7 @@ void HistoryInfoLoad::getTransparency()
void HistoryInfoLoad::getWindowRadius()
{
QString filePath = m_historyInfo.filepath + "/src/config/theme.conf";
QString filePath = m_historyInfo.filepath + "/src/globalTheme/theme.conf";
QFile file(filePath);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
qDebug() << "无法打开文件:" << filePath;

View File

@ -109,8 +109,8 @@ void MainInterface::init()
info->getFileInfo(getInfo.FileSearch(FileProcess::g_date));
info->show();
connect(info,&InfoCreateWidget::readytoBuild,this,&MainInterface::startCopy);
connect(info,&InfoCreateWidget::backtoHome,this,[=](){
emit backtoHome();
connect(info,&InfoCreateWidget::gohomesignals,this,[=](){
emit gohomesignals();
});
});
@ -166,18 +166,26 @@ void MainInterface::setGlobalTheme()
{
m_themestackedwidget->setCurrentIndex(0);
m_globalbtn->setChecked(true);
FileProcess::g_createThemeType = "globalTheme";
}
void MainInterface::setIconTheme()
{
m_themestackedwidget->setCurrentIndex(1);
m_iconbtn->setChecked(true);
m_globalbtn->setEnabled(false);
m_cursorbtn->setEnabled(false);
FileProcess::g_createThemeType = "iconTheme";
}
void MainInterface::setCursorTheme()
{
m_themestackedwidget->setCurrentIndex(2);
m_cursorbtn->setChecked(true);
m_globalbtn->setEnabled(false);
m_iconbtn->setEnabled(false);
FileProcess::g_createThemeType = "cursorTheme";
}
void MainInterface::setPlymouthTheme()

View File

@ -56,7 +56,7 @@ signals:
void cursorMapChanged(QMap<QString, QString> *appiconsmap);
void timeCursorMapChanged(QMap<QString, QString> *systemiconsmap);
void startCopy();
void backtoHome();
void gohomesignals();
private:
void init();
void initLeftBar();

View File

@ -35,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(m_maininterface, &MainInterface::timeCursorMapChanged, m_bridge, &Bridge::timeCursorMapChanged);
// connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy);
connect(m_bridge,&Bridge::updateInfo,m_historywidget,&HistoryWidget::updateInfo);
connect(m_maininterface, &MainInterface::gohomesignals, this, &MainWindow::onGoHomeClicked);
}
MainWindow::~MainWindow()

View File

@ -83,5 +83,6 @@ private:
HistoryInfo *m_infodata;
QWidget *m_guideWidget;
bool m_isHistoryDirUpdated = false;
buildResultWidget *m_buildResult;
};
#endif // MAINWINDOW_H

View File

@ -1,6 +1,8 @@
#ifndef CACHECONFIRMEDWIDGET_H
#define CACHECONFIRMEDWIDGET_H
#include "../fileProcess/fileprocess.h"
#include <QObject>
#include <QWidget>
#include <QLabel>
@ -8,8 +10,6 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "../fileProcess/fileprocess.h"
class cacheConfirmedWidget : public QWidget
{
Q_OBJECT
@ -19,13 +19,14 @@ public:
signals:
void cacheSave();
void cacheClean();
private:
private:
QVBoxLayout *m_cacheConfirmedWidget;
QLabel *m_questionMessage;
QHBoxLayout *m_cacheConfirmedBtn;
QPushButton *m_saveCache;
QPushButton *m_cleanCache;
};
#endif // CACHECONFIRMEDWIDGET_H

View File

@ -1,9 +1,6 @@
#include "cursorthemefeature.h"
#include "cursorthemewidget.h"
#include <QGraphicsPixmapItem>
#include <QVBoxLayout>
#include <QPixmap>
#include <QGraphicsBlurEffect>
CursorThemeFeature::CursorThemeFeature(QWidget *parent, const QMap<QString, QString> *iconMap) : QWidget(parent)
{
CursorImageWidget* cursorImageWidget = new CursorImageWidget(this, iconMap);

View File

@ -24,8 +24,11 @@
#include <QWheelEvent>
#include <QtMath>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include <QGraphicsBlurEffect>
class CursorCustomLabel : public QLabel {
class CursorCustomLabel : public QLabel
{
public:
explicit CursorCustomLabel(QWidget* parent = nullptr);
@ -36,6 +39,7 @@ protected:
private:
QPixmap pixmap;
};
class CursorEditWidget : public QWidget
@ -49,7 +53,6 @@ public:
QPushButton *m_addiconbutton;
private:
QHBoxLayout *m_iconwidgetlayout;
QLabel *m_icondefaultlabel;
CursorCustomLabel *m_icondecustomlabel;
@ -57,25 +60,30 @@ private:
};
class CursorGraphicsView : public QGraphicsView {
class CursorGraphicsView : public QGraphicsView
{
public:
explicit CursorGraphicsView(QGraphicsScene* scene);
protected:
void wheelEvent(QWheelEvent* event) override;
};
class CursorImageWidget : public QWidget {
class CursorImageWidget : public QWidget
{
public:
CursorImageWidget(QWidget *parent = nullptr, const QMap<QString,QString>* iconMap = nullptr);
void updateIcon(const QString& widgetName, const QString& newFilePath);
void updateImage(const QString& imagePath);
void setIconMap(QMap<QString,QString>*);
private:
const QMap<QString,QString>* m_iconMap;
CursorGraphicsView* graphicsView;
QString m_coverFilePath;
};

View File

@ -1,5 +1,6 @@
#ifndef CURSORTHEMEWIDGET_H
#define CURSORTHEMEWIDGET_H
#include "cursorthemefeature.h"
#include <QObject>
@ -16,6 +17,7 @@
#include <QStackedWidget>
#include <QObject>
#include <QWidget>
class CursorThemeWidget : public QWidget
{
Q_OBJECT
@ -26,6 +28,7 @@ signals:
void wallpaperupdate(const QString& filePath);
void newCursorMap(QMap<QString, QString> *cursormap);
void newTimeCursorMap(QMap<QString, QString> *timecursormap);
private:
void initPreviewWidget();
void initMaps();

View File

@ -1,5 +1,8 @@
#ifndef HISTORYWIDGET_H
#define HISTORYWIDGET_H
#include "../fileProcess/historyinfoload.h"
#include <QObject>
#include <QWidget>
#include <QDir>
@ -11,7 +14,6 @@
#include <QMenu>
#include <QAction>
#include <QMouseEvent>
#include "../fileProcess/historyinfoload.h"
class HistoryButton : public QPushButton
{
@ -23,14 +25,17 @@ public:
void setThemeName(const QString &themeName);
void setThemeType(const QString &themeType);
void initUI();
signals:
void updateHistoryRequested();
private:
QString m_historytime = nullptr;
QString m_coverpath = nullptr;
QString m_themename = nullptr;
QString m_themetype = nullptr;
QMenu *m_menu;
};
@ -40,13 +45,14 @@ class HistoryWidget : public QWidget
public:
explicit HistoryWidget(QWidget *parent = nullptr);
void updateHistoryDir();
public slots:
void handleButtonClick();
signals:
void startSecondEdit(const HistoryInfo &InfoData);
void updateInfo();
};
#endif // HISTORYWIDGET_H

View File

@ -1,6 +1,5 @@
#include "infocreatefeature.h"
//theme info proecessing
InfoCreateFeature::InfoCreateFeature()
{

View File

@ -1,13 +1,13 @@
#ifndef INFOCREATEFEATURE_H
#define INFOCREATEFEATURE_H
#include "infocreatewidget.h"
#include <QObject>
#include <QDir>
#include <QDateTime>
#include <QDebug>
#include "infocreatewidget.h"
class InfoCreateFeature
{

View File

@ -163,7 +163,7 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){
QRegExp englishRegexp("[A-Za-z0-9]+$");
if(m_themeNameENLineEdit != nullptr){
if (englishRegexp.exactMatch(m_builderName)){
m_warningMessage3->setText("Input is empty!");
m_warningMessage3->setText("");
m_builderNameState = true;
if (m_themeENNameState && m_builderMailState && m_builderNameState){
m_recogniseBtn->setEnabled(true);
@ -176,7 +176,7 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){
QPalette m_fontqpe;
m_fontqpe.setColor(QPalette::WindowText,Qt::red);
m_warningMessage3->setPalette(m_fontqpe);
m_warningMessage3->setText("Input format error!");
m_warningMessage3->setText(tr("Input format error!"));
m_builderNameState = false;
m_recogniseBtn->setEnabled(false);
m_createDebBtn->setEnabled(false);
@ -211,7 +211,7 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){
QPalette m_fontqpe;
m_fontqpe.setColor(QPalette::WindowText,Qt::red);
m_warningMessage4->setPalette(m_fontqpe);
m_warningMessage4->setText("Input format error!");
m_warningMessage4->setText(tr("Input format error!"));
m_builderMailState = false;
m_recogniseBtn->setEnabled(false);
m_createDebBtn->setEnabled(false);
@ -220,7 +220,7 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){
QPalette m_fontqpe;
m_fontqpe.setColor(QPalette::WindowText,Qt::red);
m_warningMessage4->setPalette(m_fontqpe);
m_warningMessage4->setText("Input is empty!");
m_warningMessage4->setText(tr("Input is empty!"));
m_builderMailState = false;
m_recogniseBtn->setEnabled(false);
m_createDebBtn->setEnabled(false);
@ -235,21 +235,23 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){
//创建control/changelog文件
connect(m_recogniseBtn, &QPushButton::clicked,this,[=](){
createControlChangelog(m_date);
createMeson(m_date);
});
//获取已输入信息,再次确认后开始编译
connect(m_createDebBtn,&QPushButton::clicked,this,[=](){
createControlChangelog(FileProcess::g_date);
createMeson(FileProcess::g_date);
//发送文件复制信号
emit readytoBuild();
//编包前检查
buildCheckWidget *m_buildCheckWidget = new buildCheckWidget();
m_buildCheckWidget->buildCheck(QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src");
//清空日期缓存
// FileProcess::g_date = nullptr;
// FileProcess::g_themeENName = nullptr;
//发送返回主界面信号
emit backtoHome();
connect(m_buildCheckWidget, &buildCheckWidget::gohomesignals, this,[=](){
//发送返回主界面信号
emit gohomesignals();
});
});
}
@ -267,7 +269,7 @@ void InfoCreateWidget::createControlChangelog(const QString &m_date){
m_controlStream << endl << QStringLiteral("Section: misc");
m_controlStream << endl << QStringLiteral("Priority: optional");
m_controlStream << endl << QStringLiteral("Maintainer: ") + m_builderName + QStringLiteral(" <") + m_builderMail + QStringLiteral(">");
m_controlStream << endl << QStringLiteral("Build-Depends: debhelper-compat (= 13)");
m_controlStream << endl << QStringLiteral("Build-Depends: debhelper-compat (= 13),meson,ninja-build");
m_controlStream << endl << QStringLiteral("Standards-Version: 4.6.0");
m_controlStream << endl << QStringLiteral("Rules-Requires-Root: no");
m_controlStream << endl;
@ -293,6 +295,108 @@ void InfoCreateWidget::createControlChangelog(const QString &m_date){
}
}
//创建meson相关文件
void InfoCreateWidget::createMeson(const QString &m_date){
//点击生成制作主题包按钮时m_date将设为空
qDebug()<<m_date;
if(m_date != nullptr){
QFile m_meson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/meson.build");
if (m_meson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
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']");
m_mesonStream << endl;
m_mesonStream << endl << QStringLiteral("foreach component: components_d");
m_mesonStream << endl << QStringLiteral("if get_option(component)");
m_mesonStream << endl << QStringLiteral("subdir(component)");
m_mesonStream << endl << QStringLiteral("endif");
m_mesonStream << endl << QStringLiteral("endforeach");
}
QFile m_mesonOption(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/meson_options.txt");
if (m_mesonOption.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_mesonOptionStream(&m_mesonOption);
if(FileProcess::g_createThemeType == "globalTheme"){
m_mesonOptionStream << QStringLiteral("option('globalTheme', type: 'boolean', value: true, description:'build ukui gtk theme')");
m_mesonOptionStream << endl << QStringLiteral("option('iconTheme', type: 'boolean', value: true, description:'build ukui icons theme')");
m_mesonOptionStream << endl << QStringLiteral("option('cursorTheme', type: 'boolean', value: true, description:'build ukui sounds theme')");
} 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')");
m_mesonOptionStream << endl << QStringLiteral("option('cursorTheme', type: 'boolean', value: false, description:'build ukui sounds theme')");
} 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')");
m_mesonOptionStream << endl << QStringLiteral("option('cursorTheme', type: 'boolean', value: true, description:'build ukui sounds theme')");
}
}
if(FileProcess::g_createThemeType == "globalTheme"){
QFile m_globalMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/globalTheme/meson.build");
if (m_globalMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_globalMesonStream(&m_globalMeson);
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;
m_globalMesonStream << endl << QStringLiteral("foreach global: global_d");
m_globalMesonStream << endl << QStringLiteral(" install_data(global, install_dir: globaltheme_dir/'")+ FileProcess::g_themeENName +QStringLiteral("')");
m_globalMesonStream << endl << QStringLiteral("endforeach");
m_globalMesonStream << endl;
m_globalMesonStream << endl << QStringLiteral("install_data('default.json', install_dir: platformconfig_dir)");
}
}
if (FileProcess::g_createThemeType == "globalTheme" || FileProcess::g_createThemeType == "iconTheme"){
QFile m_iconMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/iconTheme/meson.build");
if (m_iconMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_iconMesonStream(&m_iconMeson);
m_iconMesonStream << QStringLiteral("icons_dir = join_paths(get_option('prefix'), 'share/icons')");
m_iconMesonStream << endl;
// m_iconMesonStream << endl << QStringLiteral("data_d = ['systemicon','appicon']");
// m_iconMesonStream << endl;
// m_iconMesonStream << endl << QStringLiteral("foreach data: data_d");
m_iconMesonStream << endl << QStringLiteral(" install_subdir(");
m_iconMesonStream << endl << QStringLiteral(" '")+FileProcess::g_themeENName+QStringLiteral("',");
m_iconMesonStream << endl << QStringLiteral(" install_dir: icons_dir/'")+ FileProcess::g_themeENName +QStringLiteral("',");
m_iconMesonStream << endl << QStringLiteral(" strip_directory: true");
m_iconMesonStream << endl << QStringLiteral(" )");
// m_iconMesonStream << endl << QStringLiteral("endforeach");
}
}
if(FileProcess::g_createThemeType == "globalTheme" || FileProcess::g_createThemeType == "cursorTheme"){
QFile m_cursorMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/cursorTheme/meson.build");
if (m_cursorMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_cursorMesonStream(&m_cursorMeson);
m_cursorMesonStream << QStringLiteral("icons_dir = join_paths(get_option('prefix'), 'share/icons')");
m_cursorMesonStream << endl;
m_cursorMesonStream << endl << QStringLiteral("data_d = ['cursor','timecursor']");
m_cursorMesonStream << endl;
m_cursorMesonStream << endl << QStringLiteral("foreach data: data_d");
m_cursorMesonStream << endl << QStringLiteral(" install_subdir(");
m_cursorMesonStream << endl << QStringLiteral(" data,");
m_cursorMesonStream << endl << QStringLiteral(" install_dir: icons_dir/'")+ FileProcess::g_themeENName +QStringLiteral("-cursor/cursors',");
m_cursorMesonStream << endl << QStringLiteral(" strip_directory: true");
m_cursorMesonStream << endl << QStringLiteral(" )");
m_cursorMesonStream << endl << QStringLiteral("endforeach");
}
}
this->close();
}
}
void InfoCreateWidget::getFileInfo(const QMap<QString, QVariant> &m_packageInfo){
m_themeNameENLineEdit->setText(m_packageInfo.value("key1").toString());
m_builderNameLineEdit->setText(m_packageInfo.value("key2").toString());

View File

@ -39,12 +39,14 @@ public:
QString m_builderName;
void createControlChangelog(const QString &m_date);
void createMeson(const QString &m_date);
void getFileInfo(const QMap<QString, QVariant> &m_packageInfo);
signals:
void readytoBuild();
void buildPackage();
void backtoHome();
void gohomesignals();
private:
QLabel *m_warningMessage;
QLabel *m_warningMessage2;

View File

@ -18,16 +18,18 @@ public:
explicit TitleBar(QWidget *parent = nullptr);
void toggleMaximize();
QPushButton *m_gohomebtn = nullptr;
signals:
void gohomesignal(); // 声明自定义信号
private:
private:
bool m_ismaximized;
QToolButton *m_optionbtn = nullptr; // 菜单选项
QPushButton *m_minimumbtn = nullptr;
QPushButton *m_maximumbtn = nullptr;
QPushButton *recoverNormalSizeBtn = nullptr;
QPushButton *m_closebtn = nullptr;
};
#endif // TITLEBAR_H