!22 add modify cover and icons function

Merge pull request !22 from likehomedream/my-2.0-devel
This commit is contained in:
KevinDuan 2023-09-14 01:54:45 +00:00 committed by Gitee
commit cc6d8fd617
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 129 additions and 10 deletions

View File

@ -23,7 +23,7 @@ void Bridge::wallpaperPathChanged(QString path)
void Bridge::coverPathChanged(QString path)
{
m_coverpath = path;
}
void Bridge::radiusChanged(int radius)
@ -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,8 @@ 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;
qDebug()<< "cursorMapChanged";
}
void Bridge::timeCursorMapChanged(QMap<QString, QString> *timecursormap)
@ -71,15 +75,48 @@ 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;
qDebug()<< "timeCursorMapChanged";
}
void Bridge::startCopy()
{
if(m_appsiconpathmap){
m_configfilemanager->copyIcontoCacheDir(m_appsiconpathmap,m_builderappicon);
}
if(m_systemiconpathmap){
m_configfilemanager->copyIcontoCacheDir(m_systemiconpathmap,m_buildersystemicon);
}
if(m_cursorpathmap){
m_configfilemanager->copyIcontoCacheDir(m_cursorpathmap,m_buildercursor);
}
if(m_timecursorpathmap){
m_configfilemanager->copyIcontoCacheDir(m_timecursorpathmap,m_buildertimecursor);
}
m_configfilemanager->copyCovertoCacheDir(m_coverpath,m_builderConfig);
}
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,22 @@ private:
static Bridge* m_instance;
static QMutex m_mutex;
ConfigFileManager *m_configfilemanager;
QMap<QString, QString> *m_appsiconpathmap = nullptr;
QMap<QString, QString> *m_systemiconpathmap = nullptr;
QMap<QString, QString> *m_cursorpathmap = nullptr;
QMap<QString, QString> *m_timecursorpathmap = nullptr;
QString m_wallpaperpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
QString m_coverpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
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,48 @@ bool ConfigFileManager::copyFileContent(const QString &sourceFilePath, const QSt
return true;
}
bool ConfigFileManager::copyIcontoCacheDir(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;
}
void ConfigFileManager::copyCovertoCacheDir(const QString &destinationFilePath, QDir cachedir)
{
QString sourceFilePath = destinationFilePath;
QString sourceFileExt = QFileInfo(sourceFilePath).suffix();
QString targetFileName = "preview." + sourceFileExt;
QString targetFilePath = cachedir.filePath(targetFileName);
if (!QFile::copy(sourceFilePath, targetFilePath))
{
qDebug() << "Failed to copy file";
return;
}
qDebug() << "File copied successfully";
}

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,15 @@ public:
bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath);
bool copyIcontoCacheDir(QMap<QString, QString> *map,QDir cachedir);
void copyCovertoCacheDir(const QString& destinationFilePath,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

@ -26,7 +26,10 @@ MainWindow::MainWindow(QWidget *parent)
connect(m_maininterface, &MainInterface::exteriorChanged, m_bridge, &Bridge::exteriorChanged);
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::cursorMapChanged, m_bridge, &Bridge::cursorMapChanged);
connect(m_maininterface, &MainInterface::timeCursorMapChanged, m_bridge, &Bridge::timeCursorMapChanged);
connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy);
}
MainWindow::~MainWindow()