diff --git a/src/bridge.cpp b/src/bridge.cpp index 17bbb98..1aa2815 100644 --- a/src/bridge.cpp +++ b/src/bridge.cpp @@ -47,6 +47,7 @@ void Bridge::appIconsMapChanged(QMap *appiconsmaps) for (it = appiconsmaps->begin(); it != appiconsmaps->end(); ++it) { qDebug() << "Key:" << it.key() << "Value:" << it.value(); } + m_appsiconpathmap = appiconsmaps; } void Bridge::systemIconsMapChanged(QMap *systemiconsmaps) @@ -55,6 +56,7 @@ void Bridge::systemIconsMapChanged(QMap *systemiconsmaps) for (it = systemiconsmaps->begin(); it != systemiconsmaps->end(); ++it) { qDebug() << "Key:" << it.key() << "Value:" << it.value(); } + m_systemiconpathmap = systemiconsmaps; } void Bridge::cursorMapChanged(QMap *cursormap) @@ -63,6 +65,7 @@ void Bridge::cursorMapChanged(QMap *cursormap) for (it = cursormap->begin(); it != cursormap->end(); ++it) { qDebug() << "Key:" << it.key() << "Value:" << it.value(); } + m_cursorpathmap = cursormap; } void Bridge::timeCursorMapChanged(QMap *timecursormap) @@ -71,15 +74,36 @@ void Bridge::timeCursorMapChanged(QMap *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()); } diff --git a/src/bridge.h b/src/bridge.h index 4ee57b0..e197dbf 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -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 *systemiconsmaps); void cursorMapChanged(QMap *cursormap); void timeCursorMapChanged(QMap *timecursormap); + void startCopy(); - QString getTime(); signals: private: @@ -34,6 +34,20 @@ private: static Bridge* m_instance; static QMutex m_mutex; ConfigFileManager *m_configfilemanager; + + QMap *m_appsiconpathmap; + QMap *m_systemiconpathmap; + QMap *m_cursorpathmap; + QMap *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 diff --git a/src/configfilemanager.cpp b/src/configfilemanager.cpp index 061878e..ba78a13 100644 --- a/src/configfilemanager.cpp +++ b/src/configfilemanager.cpp @@ -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 *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; +} + diff --git a/src/configfilemanager.h b/src/configfilemanager.h index 4096d13..d4907e6 100644 --- a/src/configfilemanager.h +++ b/src/configfilemanager.h @@ -5,12 +5,14 @@ #include #include #include +#include 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 *map,QDir cachedir); signals: private: QString m_time; QString jsonFilePath; QString confFilePath; + }; #endif // CONFIGFILEMANAGER_H diff --git a/src/fileprocess.cpp b/src/fileprocess.cpp index 2411ffc..1a91d96 100644 --- a/src/fileprocess.cpp +++ b/src/fileprocess.cpp @@ -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; diff --git a/src/infocreatewidget.cpp b/src/infocreatewidget.cpp index ad50823..8f37eeb 100644 --- a/src/infocreatewidget.cpp +++ b/src/infocreatewidget.cpp @@ -242,6 +242,8 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){ createControlChangelog(FileProcess::g_date); //清空日期缓存 FileProcess::g_date = nullptr; + //发送文件复制信号 + emit readytoBuild(); }); } diff --git a/src/infocreatewidget.h b/src/infocreatewidget.h index 8ceec49..94e5dc6 100644 --- a/src/infocreatewidget.h +++ b/src/infocreatewidget.h @@ -41,6 +41,7 @@ public: void createControlChangelog(const QString &m_date); void getFileInfo(const QMap &m_packageInfo); signals: + void readytoBuild(); private: QLabel *m_warningMessage; QLabel *m_warningMessage2; diff --git a/src/maininterface.cpp b/src/maininterface.cpp index 3a6c994..446ef54 100644 --- a/src/maininterface.cpp +++ b/src/maininterface.cpp @@ -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); }); } diff --git a/src/maininterface.h b/src/maininterface.h index 1c48347..d8678b0 100644 --- a/src/maininterface.h +++ b/src/maininterface.h @@ -42,6 +42,7 @@ signals: void systemIconsMapChanged(QMap *systemiconsmap); void cursorMapChanged(QMap *appiconsmap); void timeCursorMapChanged(QMap *systemiconsmap); + void startCopy(); private: void init(); void initLeftBar(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 76b5cfd..f660950 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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()