add modify icon function

This commit is contained in:
likehomedream 2023-09-12 17:39:53 +08:00
parent 1861e6993e
commit c8b4e386d4
10 changed files with 94 additions and 8 deletions

View File

@ -47,6 +47,7 @@ void Bridge::appIconsMapChanged(QMap<QString, QString> *appiconsmaps)
for (it = appiconsmaps->begin(); it != appiconsmaps->end(); ++it) {
qDebug() << "Key:" << it.key() << "Value:" << it.value();
}
m_appsiconpathmap = appiconsmaps;
}
void Bridge::systemIconsMapChanged(QMap<QString, QString> *systemiconsmaps)
@ -55,6 +56,7 @@ void Bridge::systemIconsMapChanged(QMap<QString, QString> *systemiconsmaps)
for (it = systemiconsmaps->begin(); it != systemiconsmaps->end(); ++it) {
qDebug() << "Key:" << it.key() << "Value:" << it.value();
}
m_systemiconpathmap = systemiconsmaps;
}
void Bridge::cursorMapChanged(QMap<QString, QString> *cursormap)
@ -63,6 +65,7 @@ void Bridge::cursorMapChanged(QMap<QString, QString> *cursormap)
for (it = cursormap->begin(); it != cursormap->end(); ++it) {
qDebug() << "Key:" << it.key() << "Value:" << it.value();
}
m_cursorpathmap = cursormap;
}
void Bridge::timeCursorMapChanged(QMap<QString, QString> *timecursormap)
@ -71,15 +74,36 @@ void Bridge::timeCursorMapChanged(QMap<QString, QString> *timecursormap)
for (it = timecursormap->begin(); it != timecursormap->end(); ++it) {
qDebug() << "Key:" << it.key() << "Value:" << it.value();
}
m_timecursorpathmap = timecursormap;
}
void Bridge::startCopy()
{
m_configfilemanager->copytoCacheDir(m_appsiconpathmap,m_builderappicon);
// m_configfilemanager->copytoCacheDir(m_systemiconpathmap,m_buildersystemicon);
}
void Bridge::createFileManager(QString time)
{
m_time = time;
m_configfilemanager = new ConfigFileManager(time);
createDir();
}
QString Bridge::getTime()
void Bridge::createDir()
{
return m_time;
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" +m_time;
m_builderConfig = m_themePath + "/config";
m_builderappicon = m_themePath + "/iconTheme" + "/appicon";
m_buildersystemicon = m_themePath + "/iconTheme" + "/systemicon";
m_buildercursor = m_themePath + "/cursorTheme" + "/cursor";
m_buildertimecursor = m_themePath + "/cursorTheme" + "/timecursor";
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

@ -14,7 +14,7 @@ class Bridge : public QObject
public:
static Bridge* getInstance(QObject *parent = nullptr);
void createFileManager(QString time);
void createDir();
void wallpaperPathChanged(QString path);
void coverPathChanged(QString path);
void radiusChanged(int radius);
@ -24,8 +24,8 @@ public:
void systemIconsMapChanged(QMap<QString, QString> *systemiconsmaps);
void cursorMapChanged(QMap<QString, QString> *cursormap);
void timeCursorMapChanged(QMap<QString, QString> *timecursormap);
void startCopy();
QString getTime();
signals:
private:
@ -34,6 +34,20 @@ private:
static Bridge* m_instance;
static QMutex m_mutex;
ConfigFileManager *m_configfilemanager;
QMap<QString, QString> *m_appsiconpathmap;
QMap<QString, QString> *m_systemiconpathmap;
QMap<QString, QString> *m_cursorpathmap;
QMap<QString, QString> *m_timecursorpathmap;
QDir m_builderConfig;
QDir m_buildericons;
QDir m_builderappicon;
QDir m_buildersystemicon;
QDir m_buildercursors;
QDir m_buildercursor;
QDir m_buildertimecursor;
};
#endif // BRIDGE_H

View File

@ -10,9 +10,10 @@ ConfigFileManager::ConfigFileManager(const QString& time,QObject *parent) : QObj
m_time = time;
createConf();
createJson();
}
bool ConfigFileManager::createJson()
{
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/";
@ -199,3 +200,33 @@ bool ConfigFileManager::copyFileContent(const QString &sourceFilePath, const QSt
return true;
}
bool ConfigFileManager::copytoCacheDir(QMap<QString, QString> *map, QDir cachedir)
{
bool success = true;
for (auto it = map->begin(); it != map->end(); ++it)
{
QString key = it.key();
QString value = it.value();
if (value.startsWith(":/resource")){
continue;
}
QFile inputFile(value);
QFileInfo fileInfo(inputFile.fileName());
QString destinationPath = cachedir.filePath(key + "." + fileInfo.completeSuffix());
if (!inputFile.exists()){
success = false;
continue;
}
if (!inputFile.copy(destinationPath)){
success = false;
}
}
return success;
}

View File

@ -5,12 +5,14 @@
#include <QColor>
#include <QJsonDocument>
#include <QJsonObject>
#include <QDir>
class ConfigFileManager : public QObject
{
Q_OBJECT
public:
explicit ConfigFileManager(const QString& time,QObject *parent = nullptr);
bool createJson();
bool createConf();
bool modifyRadiusJson(int radius);
@ -20,11 +22,13 @@ public:
bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath);
bool copytoCacheDir(QMap<QString, QString> *map,QDir cachedir);
signals:
private:
QString m_time;
QString jsonFilePath;
QString confFilePath;
};
#endif // CONFIGFILEMANAGER_H

View File

@ -61,11 +61,17 @@ QString FileProcess::FileCreate(const QString &m_themeType){
QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + g_date;
QDir m_builderTime = m_themePath;
QDir m_builderDeb = m_themePath + "/debian";
QDir m_builderConfig = m_themePath + "/config";
QDir m_themeTypePath = m_themePath + "/" + m_themeType;
m_builderTime.mkdir(m_builderTime.absolutePath());
m_builderTime.mkdir(m_builderDeb.absolutePath());
m_builderTime.mkdir(m_builderConfig.absolutePath());
m_builderDeb.mkdir(m_builderDeb.absolutePath());
if(m_themeType == "globalTheme"){
QDir iconPath = m_themePath+ "/iconTheme";
QDir cursorPath = m_themePath+ "/cursorTheme";
iconPath.mkdir(iconPath.absolutePath());
cursorPath.mkdir(cursorPath.absolutePath());
}
m_themeTypePath.mkdir(m_themeTypePath.absolutePath());
return g_date;

View File

@ -242,6 +242,8 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){
createControlChangelog(FileProcess::g_date);
//清空日期缓存
FileProcess::g_date = nullptr;
//发送文件复制信号
emit readytoBuild();
});
}

View File

@ -41,6 +41,7 @@ public:
void createControlChangelog(const QString &m_date);
void getFileInfo(const QMap<QString, QVariant> &m_packageInfo);
signals:
void readytoBuild();
private:
QLabel *m_warningMessage;
QLabel *m_warningMessage2;

View File

@ -83,6 +83,7 @@ void MainInterface::init()
FileProcess getInfo;
info->getFileInfo(getInfo.FileSearch(FileProcess::g_date));
info->show();
connect(info,&InfoCreateWidget::readytoBuild,this,&MainInterface::startCopy);
});
}

View File

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

View File

@ -27,6 +27,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(m_maininterface, &MainInterface::appIconsMapChanged, m_bridge, &Bridge::appIconsMapChanged);
connect(m_maininterface, &MainInterface::systemIconsMapChanged, m_bridge, &Bridge::systemIconsMapChanged);
connect(m_maininterface, &MainInterface::cursorMapChanged, m_bridge, &Bridge::systemIconsMapChanged);
connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy);
}
MainWindow::~MainWindow()