From 50d31c82fa88f22b4d516266c0aea5833f627487 Mon Sep 17 00:00:00 2001 From: KevinDuan Date: Thu, 19 Oct 2023 15:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kylin-theme-builder.pro | 8 +- resource.qrc | 3 + src/bridge.cpp | 122 ---------- src/bridge.h | 55 ----- src/build/build.cpp | 6 + src/build/build.h | 80 ++++++ src/build/buildWidget.cpp | 34 +++ src/build/buildWidget.h | 28 +++ src/build/buildcheckwidget.cpp | 86 ++++++- src/build/buildcheckwidget.h | 17 +- src/cacheconfirmedwidget.cpp | 35 --- src/cacheconfirmedwidget.h | 31 --- src/configfilemanager.cpp | 247 ------------------- src/configfilemanager.h | 36 --- src/cursorthemefeature.cpp | 270 --------------------- src/cursorthemefeature.h | 92 ------- src/cursorthemewidget.cpp | 144 ----------- src/cursorthemewidget.h | 60 ----- src/fileProcess/bridge.cpp | 13 +- src/fileProcess/configfilemanager.cpp | 8 +- src/fileProcess/fileprocess.cpp | 14 +- src/fileProcess/fileprocess.h | 1 + src/filecheck.cpp | 57 ----- src/filecheck.h | 18 -- src/fileprocess.cpp | 83 ------- src/fileprocess.h | 27 --- src/globalthemefeature.cpp | 203 ---------------- src/globalthemefeature.h | 74 ------ src/globalthemewidget.cpp | 302 ----------------------- src/globalthemewidget.h | 63 ----- src/iconthemewidget.cpp | 257 -------------------- src/iconthemewidget.h | 62 ----- src/iconwidgetfeature.cpp | 336 -------------------------- src/iconwidgetfeature.h | 95 -------- src/infocreatefeature.cpp | 7 - src/infocreatefeature.h | 20 -- src/infocreatewidget.cpp | 295 ---------------------- src/infocreatewidget.h | 77 ------ src/module/infocreatewidget.cpp | 31 +-- src/module/infocreatewidget.h | 1 - 40 files changed, 290 insertions(+), 3108 deletions(-) delete mode 100644 src/bridge.cpp delete mode 100644 src/bridge.h create mode 100644 src/build/build.cpp create mode 100644 src/build/build.h create mode 100644 src/build/buildWidget.cpp create mode 100644 src/build/buildWidget.h delete mode 100644 src/cacheconfirmedwidget.cpp delete mode 100644 src/cacheconfirmedwidget.h delete mode 100644 src/configfilemanager.cpp delete mode 100644 src/configfilemanager.h delete mode 100644 src/cursorthemefeature.cpp delete mode 100644 src/cursorthemefeature.h delete mode 100644 src/cursorthemewidget.cpp delete mode 100644 src/cursorthemewidget.h delete mode 100644 src/filecheck.cpp delete mode 100644 src/filecheck.h delete mode 100644 src/fileprocess.cpp delete mode 100644 src/fileprocess.h delete mode 100644 src/globalthemefeature.cpp delete mode 100644 src/globalthemefeature.h delete mode 100644 src/globalthemewidget.cpp delete mode 100644 src/globalthemewidget.h delete mode 100644 src/iconthemewidget.cpp delete mode 100644 src/iconthemewidget.h delete mode 100644 src/iconwidgetfeature.cpp delete mode 100644 src/iconwidgetfeature.h delete mode 100644 src/infocreatefeature.cpp delete mode 100644 src/infocreatefeature.h delete mode 100644 src/infocreatewidget.cpp delete mode 100644 src/infocreatewidget.h diff --git a/kylin-theme-builder.pro b/kylin-theme-builder.pro index 1d71eab..4fecb92 100644 --- a/kylin-theme-builder.pro +++ b/kylin-theme-builder.pro @@ -16,13 +16,14 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + src/build/buildWidget.cpp \ src/build/buildcheck.cpp \ + src/build/buildcheckwidget.cpp \ src/fileProcess/bridge.cpp \ src/fileProcess/diroperation.cpp \ src/fileProcess/filecheck.cpp \ src/fileProcess/fileprocess.cpp \ src/fileProcess/configfilemanager.cpp \ - src/build/buildcheckwidget.cpp \ src/fileProcess/historyinfoload.cpp \ src/module/cacheconfirmedwidget.cpp \ src/module/cursorthemefeature.cpp \ @@ -40,13 +41,14 @@ SOURCES += \ src/titlebar.cpp HEADERS += \ - src/build/buildcheck.h \ + src/build/build.h \ + src/build/buildWidget.h \ + src/build/buildcheckwidget.h \ src/fileProcess/bridge.h \ src/fileProcess/diroperation.h \ src/fileProcess/filecheck.h \ src/fileProcess/fileprocess.h \ src/fileProcess/configfilemanager.h \ - src/build/buildcheckwidget.h \ src/fileProcess/historyinfoload.h \ src/module/cacheconfirmedwidget.h \ src/module/cursorthemefeature.h \ diff --git a/resource.qrc b/resource.qrc index 7db0c24..96c8140 100644 --- a/resource.qrc +++ b/resource.qrc @@ -127,5 +127,8 @@ resource/systemicons/kylin-settings-commoninfo.png resource/config/defualt.json resource/config/theme.conf + resource/debian/rules + resource/debian/copyright + resource/debian/source/format diff --git a/src/bridge.cpp b/src/bridge.cpp deleted file mode 100644 index ff2dab3..0000000 --- a/src/bridge.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "bridge.h" -Bridge* Bridge::m_instance = nullptr; -QMutex Bridge::m_mutex; -Bridge::Bridge(QObject *parent) : QObject(parent) -{ -} - -Bridge *Bridge::getInstance(QObject *parent) -{ - if (m_instance == nullptr) { - QMutexLocker locker(&m_mutex); - if (m_instance == nullptr) { - m_instance = new Bridge(parent); - } - } - return m_instance; -} - -void Bridge::wallpaperPathChanged(QString path) -{ - m_configfilemanager->modifyWallPaperConf(path); -} - -void Bridge::coverPathChanged(QString path) -{ - m_coverpath = path; -} - -void Bridge::radiusChanged(int radius) -{ - m_configfilemanager->modifyRadiusJson(radius); -} - -void Bridge::accentColorChanged(QColor accentcolor) -{ - m_configfilemanager->modifyAccentColorConf(accentcolor); -} - -void Bridge::exteriorChanged(QColor accentcolor) -{ - -} - -void Bridge::appIconsMapChanged(QMap *appiconsmaps) -{ - QMap::const_iterator it; - for (it = appiconsmaps->begin(); it != appiconsmaps->end(); ++it) { - qDebug() << "Key:" << it.key() << "Value:" << it.value(); - } - m_appsiconpathmap = appiconsmaps; -} - -void Bridge::systemIconsMapChanged(QMap *systemiconsmaps) -{ - QMap::const_iterator it; - for (it = systemiconsmaps->begin(); it != systemiconsmaps->end(); ++it) { - qDebug() << "Key:" << it.key() << "Value:" << it.value(); - } - m_systemiconpathmap = systemiconsmaps; -} - -void Bridge::cursorMapChanged(QMap *cursormap) -{ - QMap::const_iterator it; - for (it = cursormap->begin(); it != cursormap->end(); ++it) { - qDebug() << "Key:" << it.key() << "Value:" << it.value(); - } - m_cursorpathmap = cursormap; - qDebug()<< "cursorMapChanged"; -} - -void Bridge::timeCursorMapChanged(QMap *timecursormap) -{ - QMap::const_iterator it; - 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(); -} - -void Bridge::createDir() -{ - 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 deleted file mode 100644 index bb81a50..0000000 --- a/src/bridge.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef BRIDGE_H -#define BRIDGE_H - -#include "globalthemewidget.h" -#include "iconthemewidget.h" -#include "cursorthemewidget.h" -#include -#include "configfilemanager.h" -#include - -class Bridge : public QObject -{ - Q_OBJECT -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); - void accentColorChanged(QColor accentcolor); - void exteriorChanged(QColor accentcolor); - void appIconsMapChanged(QMap *appiconsmaps); - void systemIconsMapChanged(QMap *systemiconsmaps); - void cursorMapChanged(QMap *cursormap); - void timeCursorMapChanged(QMap *timecursormap); - void startCopy(); - -signals: - -private: - Bridge(QObject *parent = nullptr); - QString m_time; - static Bridge* m_instance; - static QMutex m_mutex; - ConfigFileManager *m_configfilemanager; - - QMap *m_appsiconpathmap = nullptr; - QMap *m_systemiconpathmap = nullptr; - QMap *m_cursorpathmap = nullptr; - QMap *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 diff --git a/src/build/build.cpp b/src/build/build.cpp new file mode 100644 index 0000000..58e0cb4 --- /dev/null +++ b/src/build/build.cpp @@ -0,0 +1,6 @@ +//#include "build.h" + +//build::build() +//{ + +//} diff --git a/src/build/build.h b/src/build/build.h new file mode 100644 index 0000000..b769cce --- /dev/null +++ b/src/build/build.h @@ -0,0 +1,80 @@ +#ifndef BUILD_H +#define BUILD_H + +#include "../fileProcess/fileprocess.h" +#include "../module/infocreatewidget.h" +#include + +#include +#include +#include +#include +#include +#include + +class build: public QThread +{ + Q_OBJECT +public: + explicit build(QObject *parent = nullptr) : QThread(parent){} + +protected: + void run() override + { + //生成源码orig文件 + QProcess process1; + QString dir1 = QDir::homePath() + "/.cache/theme-build/"+FileProcess::g_date; + qDebug() << dir1; + QString command1 = "tar"; + QStringList arguments1; + arguments1 << "-zcvf" << FileProcess::g_themeENName+"_1.0.orig.tar.xz" + << "--exclude=.git" << "--exclude=debian" << FileProcess::g_date; + + + process1.setWorkingDirectory(dir1); + process1.start(command1, arguments1); + + QObject::connect(&process1, &QProcess::readyReadStandardOutput, [&]() { + QString output = process1.readAllStandardOutput(); + qDebug() << "Output from tar: " << output; + }); + + process1.waitForFinished(-1); + emit progressChanged(10); + + //编译 + QProcess process2; + QString dir2 = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/"; + qDebug() << dir2; + QString command2 = "debuild"; + QStringList arguments2; + arguments2 << "-us"<<"-uc"; + + process2.setWorkingDirectory(dir2); + process2.start(command2, arguments2); + + // 连接debuild进程的输出信号和槽 + QObject::connect(&process2, &QProcess::readyReadStandardOutput, [&]() { + QString output = process2.readAllStandardOutput(); + qDebug() << "Output from debuild: " << output; + if(output=="dh clean\n"){ + emit progressChanged(20); + }else if(output==" dh_installdocs\n"){ + emit progressChanged(80); + }else if(output==" dh_builddeb\n"){ + emit progressChanged(90); + } + }); + + // 等待debuild进程完成 + process2.waitForFinished(-1); + // 完成后更新进度条的值为100 + emit progressChanged(100); + } + + +signals: + void progressChanged(int value); +}; + +#endif // BUILD_H diff --git a/src/build/buildWidget.cpp b/src/build/buildWidget.cpp new file mode 100644 index 0000000..495f91f --- /dev/null +++ b/src/build/buildWidget.cpp @@ -0,0 +1,34 @@ +#include "buildWidget.h" + +buildWidget::buildWidget(QWidget *parent) + : QWidget(parent) +{ + this->setFixedSize(384,110); + this->setWindowModality(Qt::ApplicationModal); + this->setWindowFlags(Qt::FramelessWindowHint); + + m_buildLayout = new QVBoxLayout; + m_buildMessage = new QLabel; + m_buildMessage->setText("正在制作主题..."); + m_buildProgressBar = new QProgressBar(); + m_buildLayout->addWidget(m_buildMessage); + m_buildLayout->addWidget(m_buildProgressBar); + m_buildProgressBar->setMinimum(0); + m_buildProgressBar->setMaximum(100); + m_buildProgressBar->setValue(0); + + this->setLayout(m_buildLayout); + + build *thread = new build(); + connect(thread, &build::progressChanged, m_buildProgressBar, &QProgressBar::setValue); + thread->start(); + + connect(thread, &build::progressChanged, this, [=](){ + if(m_buildProgressBar->value()==100){ + this->close(); + //清空日期缓存 + FileProcess::g_date = nullptr; + FileProcess::g_themeENName = nullptr; + } + }); +} diff --git a/src/build/buildWidget.h b/src/build/buildWidget.h new file mode 100644 index 0000000..fa55122 --- /dev/null +++ b/src/build/buildWidget.h @@ -0,0 +1,28 @@ +#ifndef BUILDWIDGET_H +#define BUILDWIDGET_H + +#include "build.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class buildWidget : public QWidget +{ + Q_OBJECT +public: + explicit buildWidget(QWidget *parent = nullptr); + +private: + QVBoxLayout *m_buildLayout; + QLabel *m_buildMessage; + QProgressBar *m_buildProgressBar; +}; + +#endif // BUILDWIDGET_H diff --git a/src/build/buildcheckwidget.cpp b/src/build/buildcheckwidget.cpp index 4e9ea57..4944a27 100644 --- a/src/build/buildcheckwidget.cpp +++ b/src/build/buildcheckwidget.cpp @@ -3,6 +3,88 @@ buildCheckWidget::buildCheckWidget(QWidget *parent) : QWidget(parent) { - this->setFixedSize(424,480); - this->setWindowModality(Qt::ApplicationModal); +} + +void buildCheckWidget::buildCopy(){ + + m_debSourceFormat = ":/resource/debian/source/format"; + m_debRules = ":/resource/debian/rules"; + m_debCopyRight = ":/resource/debian/copyright"; + + QString m_debPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src"; + QDir m_debSource = m_debPath +"/debian/source"; + qDebug()<show(); + } 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(); + } } diff --git a/src/build/buildcheckwidget.h b/src/build/buildcheckwidget.h index 36eeaca..f13e12a 100644 --- a/src/build/buildcheckwidget.h +++ b/src/build/buildcheckwidget.h @@ -1,6 +1,10 @@ #ifndef BUILDCHECKWIDGET_H #define BUILDCHECKWIDGET_H +#include "../fileProcess/fileprocess.h" +#include "../fileProcess/filecheck.h" +#include "buildWidget.h" + #include #include #include @@ -8,23 +12,26 @@ #include #include -#include "../fileProcess/fileprocess.h" -#include "../fileProcess/filecheck.h" - class buildCheckWidget : public QWidget { Q_OBJECT public: explicit buildCheckWidget(QWidget *parent = nullptr); - bool buildCheck(); - + void buildCheck(QDir m_buildIconPath); private: QVBoxLayout *m_buildCheckWidget; QLabel *m_buildWarningMessage; QLabel *m_warningMessageList; + QHBoxLayout *m_buildCheckBtnWidget; QPushButton *m_buildBtn; QPushButton *m_exitBuildBtn; + + QString m_debSourceFormat; + QString m_debRules; + QString m_debCopyRight; + + void buildCopy(); }; #endif // BUILDCHECKWIDGET_H diff --git a/src/cacheconfirmedwidget.cpp b/src/cacheconfirmedwidget.cpp deleted file mode 100644 index b368b77..0000000 --- a/src/cacheconfirmedwidget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "cacheconfirmedwidget.h" - -cacheConfirmedWidget::cacheConfirmedWidget(QWidget *parent) - : QWidget(parent) -{ - this->setFixedSize(424,172); - this->setWindowModality(Qt::ApplicationModal); - - m_cacheConfirmedWidget = new QVBoxLayout; - m_questionMessage = new QLabel(); - m_questionMessage->setText("是否保存?"); - - m_saveCache = new QPushButton(); - m_cleanCache = new QPushButton(); - m_saveCache->setText("保存"); - m_cleanCache->setText("清除"); - m_cacheConfirmedBtn = new QHBoxLayout(); - m_cacheConfirmedBtn->addWidget(m_saveCache); - m_cacheConfirmedBtn->addWidget(m_cleanCache); - - m_cacheConfirmedWidget->addWidget(m_questionMessage); - m_cacheConfirmedWidget->addLayout(m_cacheConfirmedBtn); - this->setLayout(m_cacheConfirmedWidget); - - QObject::connect(m_saveCache,&QPushButton::clicked,this,[=](){ - emit cacheSave(); - this->close(); - }); - QObject::connect(m_cleanCache,&QPushButton::clicked,this,[=](){ - FileProcess m_fileClean; - m_fileClean.FileClean(FileProcess::g_date); - emit cacheClean(); - this->close(); - }); -} diff --git a/src/cacheconfirmedwidget.h b/src/cacheconfirmedwidget.h deleted file mode 100644 index c4d06e7..0000000 --- a/src/cacheconfirmedwidget.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CACHECONFIRMEDWIDGET_H -#define CACHECONFIRMEDWIDGET_H - -#include -#include -#include -#include -#include -#include - -#include "fileprocess.h" - -class cacheConfirmedWidget : public QWidget -{ - Q_OBJECT -public: - explicit cacheConfirmedWidget(QWidget *parent = nullptr); - -signals: - void cacheSave(); - void cacheClean(); -private: - - QVBoxLayout *m_cacheConfirmedWidget; - QLabel *m_questionMessage; - QHBoxLayout *m_cacheConfirmedBtn; - QPushButton *m_saveCache; - QPushButton *m_cleanCache; -}; - -#endif // CACHECONFIRMEDWIDGET_H diff --git a/src/configfilemanager.cpp b/src/configfilemanager.cpp deleted file mode 100644 index fd198b9..0000000 --- a/src/configfilemanager.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include "configfilemanager.h" -#include -#include -#include -#include -#include -ConfigFileManager::ConfigFileManager(const QString& time,QObject *parent) : QObject(parent) -{ -//创建json、conf文件到指定目录,在这个类里进行修改。 - m_time = time; - createConf(); - createJson(); -} - - - -bool ConfigFileManager::createJson() -{ - QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/"; - QString filePath = m_themePath + "default.json"; - - jsonFilePath = filePath; - - QDir dir; - if (!dir.exists(m_themePath)) { - dir.mkpath(m_themePath); - } - - if (copyFileContent(":/resource/config/defualt.json", filePath)) { - // 成功将文件内容写入目标文件中 - return true; - } else { - // 写入文件内容失败 - return false; - } -} - -bool ConfigFileManager::createConf() -{ - QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/"; - QString filePath = m_themePath + "theme.conf"; - - confFilePath = filePath; - - QDir dir; - if (!dir.exists(m_themePath)) { - dir.mkpath(m_themePath); - } - - if (copyFileContent(":/resource/config/theme.conf", filePath)) { - // 成功将文件内容写入目标文件中 - return true; - } else { - // 写入文件内容失败 - return false; - } -} - -bool ConfigFileManager::modifyRadiusJson(int radius) -{ - QString confFilePath = jsonFilePath; // 替换为实际的文件路径 - - // 读取配置文件 - QFile configFile(confFilePath); - if (!configFile.open(QIODevice::ReadWrite | QIODevice::Text)) - { - qDebug() << "Failed to open config file"; - return false; - } - - QByteArray data = configFile.readAll(); - configFile.close(); - - // 解析JSON - QJsonParseError error; - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error); - if (error.error != QJsonParseError::NoError) - { - qDebug() << "Failed to parse JSON:" << error.errorString(); - return false; - } - - // 修改"value"字段的值为18 - QJsonObject jsonObj = jsonDoc.object(); - QJsonObject radiusObj = jsonObj["Radius"].toObject(); - for (auto it = radiusObj.begin(); it != radiusObj.end(); ++it) - { - QJsonObject valueObj = it.value().toObject(); - valueObj["value"] = QString::number(radius); - radiusObj[it.key()] = valueObj; - } - jsonObj["Radius"] = radiusObj; - - // 保存修改后的配置文件 - configFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text); - configFile.write(QJsonDocument(jsonObj).toJson()); - configFile.close(); - - qDebug() << "Config file updated successfully"; - -} - - -bool ConfigFileManager::modifyAccentColorConf(QColor accentcolor) -{ - - QString colorString = accentcolor.name().toUpper(); - - while (colorString.length() < 6) { - colorString.prepend('0'); - } - - // 读取文件内容 - QFile file(confFilePath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "无法打开文件:" << confFilePath; - return false; - } - - QTextStream in(&file); - QString content = in.readAll(); - file.close(); - - // 修改内容 - int startIndex = content.indexOf("accent=") + QString("accent=").size(); - content.remove(startIndex, 7); - content.insert(startIndex, colorString); - // 写入文件 - if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QTextStream out(&file); - out << content; - file.close(); - return true; - } else { - qDebug() << "无法写入文件:" << confFilePath; - return false; - } -} - -bool ConfigFileManager::modifyWallPaperConf(QString wallpaperpath) -{ - - // 读取文件内容 - QFile file(confFilePath); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "无法打开文件:" << confFilePath; - return false; - } - - QTextStream in(&file); - QString content = in.readAll(); - file.close(); - - // 修改内容 - int startIndex = content.indexOf("wallPaperPath="); - if (startIndex != -1) { - QString substr = "wallPaperPath="+wallpaperpath; - content.replace(startIndex, content.indexOf('\n', startIndex) - startIndex, substr); - } - - qDebug() << content; - - // 写入文件 - if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QTextStream out(&file); - out << content; - file.close(); - return true; - } else { - qDebug() << "无法写入文件:" << confFilePath; - return false; - } -} - -bool ConfigFileManager::copyFileContent(const QString &sourceFilePath, const QString &destinationFilePath) -{ - QFile sourceFile(sourceFilePath); - if (!sourceFile.open(QIODevice::ReadOnly)) { - qDebug() << "Failed to open source file:" << sourceFilePath; - return false; - } - - QFile destinationFile(destinationFilePath); - if (!destinationFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - qDebug() << "Failed to open destination file:" << destinationFilePath; - sourceFile.close(); - return false; - } - QTextStream in(&sourceFile); - QTextStream out(&destinationFile); - - while (!in.atEnd()) { - QString line = in.readLine(); - out << line << "\n"; - } - - sourceFile.close(); - destinationFile.close(); - - return true; -} - -bool ConfigFileManager::copyIcontoCacheDir(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; -} - -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"; -} - diff --git a/src/configfilemanager.h b/src/configfilemanager.h deleted file mode 100644 index 520c27e..0000000 --- a/src/configfilemanager.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef CONFIGFILEMANAGER_H -#define CONFIGFILEMANAGER_H - -#include -#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); - - bool modifyAccentColorConf(QColor accentcolor); - bool modifyWallPaperConf(QString wallpaperpath); - - - bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath); - bool copyIcontoCacheDir(QMap *map,QDir cachedir); - - void copyCovertoCacheDir(const QString& destinationFilePath,QDir cachedir); -signals: -private: - QString m_time; - QString jsonFilePath; - QString confFilePath; - -}; - -#endif // CONFIGFILEMANAGER_H diff --git a/src/cursorthemefeature.cpp b/src/cursorthemefeature.cpp deleted file mode 100644 index 2c536b8..0000000 --- a/src/cursorthemefeature.cpp +++ /dev/null @@ -1,270 +0,0 @@ -#include "cursorthemefeature.h" -#include "cursorthemewidget.h" -#include -#include -#include -#include -CursorThemeFeature::CursorThemeFeature(QWidget *parent, const QMap *iconMap) : QWidget(parent) -{ - CursorImageWidget* cursorImageWidget = new CursorImageWidget(this, iconMap); -} - -CursorGraphicsView::CursorGraphicsView(QGraphicsScene* scene) : QGraphicsView(scene) -{ - setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - setDragMode(QGraphicsView::ScrollHandDrag); - setRenderHint(QPainter::Antialiasing, true); - setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing |QGraphicsView::DontSavePainterState); - - this->setStyleSheet("background-color: transparent;"); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -} - -void CursorGraphicsView::wheelEvent(QWheelEvent* event) -{ - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) { - qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0); - qreal currentScale = transform().m11(); // 获取当前的缩放倍数 - // 限制最大为1.1倍 - qreal targetScale = currentScale * scaleFactor; - if (targetScale > 1.1) { - scaleFactor = 1.1 / currentScale; - }else if (targetScale < 0.3) { - scaleFactor = 0.3 / currentScale; - } - - scale(scaleFactor, scaleFactor); - scale(scaleFactor, scaleFactor); - } else { - QGraphicsView::wheelEvent(event); - } -} - -void CursorImageWidget::updateImage(const QString& imagePath) -{ - // 删除场景中的所有图像项 - graphicsView->scene()->clear(); - - // 创建新的背景图像项并添加到场景中 - QPixmap image(imagePath); - if (image.isNull()) { - qDebug() << "Failed to load new image."; - return; - } - - QGraphicsPixmapItem* backgroundItem = graphicsView->scene()->addPixmap(image); - - // 创建 QGraphicsBlurEffect 并设置模糊半径 - QGraphicsBlurEffect* blurEffect = new QGraphicsBlurEffect; - blurEffect->setBlurRadius(10); - - // 将模糊效果应用到 QGraphicsPixmapItem 上 - backgroundItem->setGraphicsEffect(blurEffect); - - // 根据需要重新布局图像项 - int columnCount = 15; - int row = 1; - int col = 0; - - for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) { - // 添加新的图像项到场景中 - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - - QPixmap pixmap(filePath); - if (!pixmap.isNull()) { - QGraphicsPixmapItem* item = graphicsView->scene()->addPixmap(pixmap.scaled(128, 128)); - - item->setPos(col * 128, row * 128); - item->setScale(1.0); - item->setData(0, widgetName); - item->setData(1, filePath); - col++; - if (col >= columnCount) { - col = 0; - row++; - } - } else { - qDebug() << "Failed to load image:" << filePath; - } - } - graphicsView->fitInView(graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio); - QTransform currentTransform = graphicsView->transform(); - QPointF sceneCenter = graphicsView->mapToScene(graphicsView->viewport()->rect().center()); - currentTransform.translate(sceneCenter.x(), sceneCenter.y()); - graphicsView->setTransform(currentTransform); - - QPointF viewCenter = graphicsView->mapFromScene(graphicsView->scene()->sceneRect().center()); - graphicsView->centerOn(viewCenter); - - graphicsView->viewport()->update(); -} - -CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap* iconMap) - : QWidget(parent), m_iconMap(iconMap) -{ - - QGraphicsScene* scene = new QGraphicsScene(this); - graphicsView = new CursorGraphicsView(scene); - - QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(graphicsView); - setLayout(layout); - - QPixmap image(":/resource/background/background-light.png"); - if (image.isNull()) { - qDebug() << "Failed to load image."; - } - - // 创建 QGraphicsPixmapItem 并添加到 QGraphicsScene - QGraphicsPixmapItem* backgroundItem = scene->addPixmap(image); - - // 创建 QGraphicsBlurEffect 并设置模糊半径 - QGraphicsBlurEffect* blurEffect = new QGraphicsBlurEffect; - blurEffect->setBlurRadius(10); // 设置模糊半径,可以根据需要调整 - - // 将模糊效果应用到 QGraphicsPixmapItem 上 - backgroundItem->setGraphicsEffect(blurEffect); - graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio); - graphicsView->setScene(scene); - graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio); - graphicsView->show(); - - int columnCount = 15; - int row = 1; - int col = 0; - - for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) { - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - - QPixmap pixmap(filePath); - if (!pixmap.isNull()) { - QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(128, 128)); - - item->setPos(col * 128, row * 128); - item->setScale(1.0); - item->setData(0, widgetName); - item->setData(1, filePath); - col++; - if (col >= columnCount) { - col = 0; - row++; - } - } else { - qDebug() << "Failed to load image:" << filePath; - } - } - // 设置初始缩放倍数为0.9倍 -// qreal initialScale = 0.8; -// graphicsView->scale(initialScale, initialScale); - qreal initialScale = 0.3; - QTransform transform; - transform.scale(initialScale, initialScale); - graphicsView->setTransform(transform); -} - -void CursorImageWidget::updateIcon(const QString& widgetName, const QString& newFilePath) -{ - QGraphicsScene* scene = graphicsView->scene(); - QList items = scene->items(); - - for (QGraphicsItem* item : items) { - QGraphicsPixmapItem* pixmapItem = dynamic_cast(item); - if (pixmapItem && pixmapItem->data(0).toString() == widgetName) { - - QPointF oldPosition = pixmapItem->pos(); - scene->removeItem(pixmapItem); - delete pixmapItem; - QPixmap newPixmap(newFilePath); - if (!newPixmap.isNull()) { - QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(256, 256)); - newPixmapItem->setData(0, widgetName); - newPixmapItem->setData(1, newFilePath); - newPixmapItem->setPos(oldPosition); - qDebug()<<"-----------------"; - } else { - qDebug() << "Failed to load image:" << newFilePath; - } - return; - } - } -} - -void CursorImageWidget::setIconMap(QMap *iconmap) -{ - m_iconMap = iconmap; -} - - -CursorEditWidget::CursorEditWidget(QWidget *parent) -{ - - this->setFixedHeight(110); - m_iconwidgetlayout = new QHBoxLayout(); - m_icondefaultlabel = new QLabel(); - m_icondefaultlabel->setFixedSize(48,48); - - m_icondecustomlabel = new CursorCustomLabel(); - - m_addiconbutton = new QPushButton(); - m_addiconbutton->setIcon(QIcon::fromTheme("list-add-symbolic")); - m_addiconbutton->setFixedSize(36,36); - - m_tiplabel = new QLabel(); - m_tiplabel->setWordWrap(true); - m_tiplabel->setText("格式:svg
尺寸:96*96"); - - m_iconwidgetlayout->addWidget(m_icondefaultlabel); - m_iconwidgetlayout->addWidget(m_icondecustomlabel); - m_iconwidgetlayout->addWidget(m_addiconbutton); - m_iconwidgetlayout->addWidget(m_tiplabel); - - this->setLayout(m_iconwidgetlayout); -} - -void CursorEditWidget::setdefaulticon(QString iconname) -{ - m_icondefaultlabel->setPixmap(QIcon::fromTheme(iconname).pixmap(48,48)); -} - -void CursorEditWidget::setcustomicon(QString iconFilePath) -{ - QPixmap pixmap(iconFilePath); - m_icondecustomlabel->setPixmap(pixmap.scaled(48, 48)); -} -CursorCustomLabel::CursorCustomLabel(QWidget *parent): QLabel(parent), pixmap() -{ - this->setFixedSize(48,48); -} - -void CursorCustomLabel::paintEvent(QPaintEvent *event) -{ - QLabel::paintEvent(event); // 调用父类的 paintEvent 函数,绘制文本 - - QPainter painter(this); - QPen pen(Qt::blue); - pen.setStyle(Qt::DashLine); - painter.setPen(pen); - - QBrush brush(QColor("#F5F5F5")); - painter.setBrush(brush); - - - QRect roundedRect = rect().adjusted(1, 1, -1, -1); - QPainterPath path; - int radius = 6; - path.addRoundedRect(roundedRect, radius, radius); - painter.drawPath(path); - - if (!pixmap.isNull()) { - painter.drawPixmap(rect(), pixmap); - } -} - -void CursorCustomLabel::setPixmap(const QPixmap &pixmap) -{ - this->pixmap = pixmap; // 使用赋值操作来更新 pixmap - update(); -} diff --git a/src/cursorthemefeature.h b/src/cursorthemefeature.h deleted file mode 100644 index f4c6d8c..0000000 --- a/src/cursorthemefeature.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef CURSORTHEMEFEATURE_H -#define CURSORTHEMEFEATURE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class CursorCustomLabel : public QLabel { -public: - explicit CursorCustomLabel(QWidget* parent = nullptr); - - void setPixmap(const QPixmap& pixmap); - -protected: - void paintEvent(QPaintEvent* event) override; - -private: - QPixmap pixmap; -}; - -class CursorEditWidget : public QWidget -{ - Q_OBJECT -public: - CursorEditWidget(QWidget *parent = nullptr); - void setdefaulticon(QString iconname); - void setcustomicon(QString iconFilePath); - - QPushButton *m_addiconbutton; - -private: - - QHBoxLayout *m_iconwidgetlayout; - QLabel *m_icondefaultlabel; - CursorCustomLabel *m_icondecustomlabel; - QLabel *m_tiplabel; - -}; - -class CursorGraphicsView : public QGraphicsView { -public: - explicit CursorGraphicsView(QGraphicsScene* scene); - -protected: - void wheelEvent(QWheelEvent* event) override; -}; - -class CursorImageWidget : public QWidget { -public: - CursorImageWidget(QWidget *parent = nullptr, const QMap* iconMap = nullptr); - void updateIcon(const QString& widgetName, const QString& newFilePath); - - void updateImage(const QString& imagePath); - void setIconMap(QMap*); -private: - const QMap* m_iconMap; - CursorGraphicsView* graphicsView; - QString m_coverFilePath; -}; - - -class CursorThemeFeature : public QWidget -{ - Q_OBJECT -public: - explicit CursorThemeFeature(QWidget *parent = nullptr, const QMap* iconMap = nullptr); - -signals: - -}; - -#endif // CURSORTHEMEFEATURE_H diff --git a/src/cursorthemewidget.cpp b/src/cursorthemewidget.cpp deleted file mode 100644 index a4fb146..0000000 --- a/src/cursorthemewidget.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "cursorthemewidget.h" - -CursorThemeWidget::CursorThemeWidget(QWidget *parent) : QWidget(parent) -{ - initMaps(); - initTimeMaps(); - initPreviewWidget(); - initRightWidget(); - - m_cursorthemelayout = new QHBoxLayout(); - m_cursorthemelayout->addWidget(m_previewwidget); - m_cursorthemelayout->addWidget(m_rightwidget); - this->setLayout(m_cursorthemelayout); -} - -void CursorThemeWidget::initPreviewWidget() -{ - m_previewwidget = new QWidget(this); - m_previewwidget->setMinimumSize(495,620); - m_preview = new CursorImageWidget(m_previewwidget,m_iconpathmap); - m_preview2 = new CursorImageWidget(m_previewwidget,m_timeiconpathmap); - m_previewlayout = new QVBoxLayout(m_previewwidget); - m_preview->setIconMap(m_iconpathmap); - connect(this,&CursorThemeWidget::wallpaperupdate, m_preview,[=](const QString& filePath){ - m_preview->updateImage(filePath); - m_preview2->updateImage(filePath); - }); - - QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - QSpacerItem *spacer2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - spacer->changeSize(m_previewwidget->width(), 155, QSizePolicy::Maximum, QSizePolicy::Maximum); - spacer2->changeSize(m_previewwidget->width(), 159, QSizePolicy::Maximum, QSizePolicy::Maximum); - - m_previewlayout->addItem(spacer); - m_previewlayout->addWidget(m_preview); - m_previewlayout->addWidget(m_preview2); - m_previewlayout->addItem(spacer2); -} - -QStringList CursorThemeWidget::getWidgetNamesFromFilesInDirectory(const QString& directoryPath) { - QStringList widgetNames; - QDir dir(directoryPath); - - QStringList fileNames = dir.entryList(QDir::Files); - foreach (const QString& fileName, fileNames) { - QFileInfo fileInfo(fileName); - QString widgetName = fileInfo.baseName(); - widgetNames.append(widgetName); - } - - return widgetNames; -} - -void CursorThemeWidget::initMaps() -{ - m_iconpathmap = new QMap; - QString directoryPath = ":/resource/cursor/"; - QStringList widgetNames = getWidgetNamesFromFilesInDirectory(directoryPath); - - for (int i = 0; i < widgetNames.size(); ++i) { - qDebug() << widgetNames[i]; - QString cursorFileName = directoryPath + widgetNames[i] + ".png"; - m_iconpathmap->insert(widgetNames[i], cursorFileName); - } - m_customiconpathmap= new QMap; - m_pathWidgetMap = new QMap; -} - -void CursorThemeWidget::initTimeMaps() -{ - m_timeiconpathmap = new QMap; - QString directoryPath = ":/resource/time-cursor/"; - QStringList widgetNames = getWidgetNamesFromFilesInDirectory(directoryPath); - - for (int i = 0; i < widgetNames.size(); ++i) { - qDebug() << widgetNames[i]; - QString cursorFileName = directoryPath + widgetNames[i] + ".png"; - m_timeiconpathmap->insert(widgetNames[i], cursorFileName); - } - - m_timecustomiconpathmap= new QMap; - m_pathWidgetMap = new QMap; -} - -void CursorThemeWidget::initRightWidget() -{ - m_rightwidget = new QWidget(this); - m_rightwidget->setMinimumSize(400,620); - m_rightwidget->setMaximumWidth(400); - - QScrollArea *m_scrollArea = new QScrollArea(m_rightwidget); - m_scrollArea->setMinimumSize(m_rightwidget->size()); - m_scrollArea->setMaximumWidth(this->width()); - m_scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_scrollArea->setWidgetResizable(true); - QWidget *viewportWidget = new QWidget(m_scrollArea); - m_scrollArea->setWidget(viewportWidget); - QVBoxLayout *mainLayout = new QVBoxLayout(viewportWidget); - viewportWidget->setLayout(mainLayout); - - QMap *combinedMap = m_iconpathmap; - combinedMap->unite(*m_timeiconpathmap); - for (auto it = combinedMap->begin(); it != combinedMap->end(); ++it) { - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - - CursorEditWidget* widget = new CursorEditWidget(viewportWidget); - widget->setdefaulticon(filePath); - mainLayout->addWidget(widget); - - m_pathWidgetMap->insert(widgetName, widget); - - connect(widget->m_addiconbutton, &QPushButton::clicked, this, [=]() { - - QPushButton* clickedButton = qobject_cast(sender()); - if (clickedButton) { - CursorEditWidget* clickedWidget = qobject_cast(clickedButton->parentWidget()); - if (clickedWidget) { - QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择SVG文件"), "", tr("SVG 文件 (*.svg)")); - if (!newFilePath.isEmpty()) { - if (m_iconpathmap->contains(widgetName)) { - - m_customiconpathmap->insert(widgetName, newFilePath); - emit newCursorMap(m_customiconpathmap); - } else if (m_timeiconpathmap->contains(widgetName)) { - - m_timecustomiconpathmap->insert(widgetName, newFilePath); - emit newCursorMap(m_timecustomiconpathmap); - } - m_preview->updateIcon(widgetName, newFilePath); - m_preview2->updateIcon(widgetName, newFilePath); - clickedWidget->setcustomicon(newFilePath); - - } - - } - } - }); - } - - QVBoxLayout *mainWidgetLayout = new QVBoxLayout(); - mainWidgetLayout->addWidget(m_scrollArea); - m_rightwidget->setLayout(mainWidgetLayout); -} diff --git a/src/cursorthemewidget.h b/src/cursorthemewidget.h deleted file mode 100644 index e2a0d36..0000000 --- a/src/cursorthemewidget.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef CURSORTHEMEWIDGET_H -#define CURSORTHEMEWIDGET_H -#include "cursorthemefeature.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class CursorThemeWidget : public QWidget -{ - Q_OBJECT -public: - explicit CursorThemeWidget(QWidget *parent = nullptr); - -signals: - void wallpaperupdate(const QString& filePath); - void newCursorMap(QMap *cursormap); - void newTimeCursorMap(QMap *timecursormap); -private: - void initPreviewWidget(); - void initMaps(); - void initTimeMaps(); - void initRightWidget(); - QStringList getWidgetNamesFromFilesInDirectory(const QString& directoryPath); - - QHBoxLayout *m_cursorthemelayout; - QWidget *m_rightwidget; - QVBoxLayout *m_rightwidgetlayout; - - QMap *m_pathWidgetMap; - - QVBoxLayout *m_previewlayout; - QString m_coverfilepath = ":/resource/background/background-glazing.png"; - - QMap *m_iconpathmap; - QMap *m_customiconpathmap; - - - QMap *m_timeiconpathmap; - QMap *m_timecustomiconpathmap; - - QWidget *m_previewwidget; - CursorImageWidget *m_preview; - CursorImageWidget *m_preview2; - QWidget *m_editwidget; - - -}; - -#endif // CURSORTHEMEWIDGET_H diff --git a/src/fileProcess/bridge.cpp b/src/fileProcess/bridge.cpp index dcfe745..cf02b76 100644 --- a/src/fileProcess/bridge.cpp +++ b/src/fileProcess/bridge.cpp @@ -108,12 +108,15 @@ void Bridge::createFileManager(bool ishistory,QString time) void Bridge::createDir() { 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"; + 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()); diff --git a/src/fileProcess/configfilemanager.cpp b/src/fileProcess/configfilemanager.cpp index 79a8cee..c811116 100644 --- a/src/fileProcess/configfilemanager.cpp +++ b/src/fileProcess/configfilemanager.cpp @@ -10,8 +10,8 @@ ConfigFileManager::ConfigFileManager(bool ishistory, const QString& time, QObjec createJson(); }else{ m_time = time; - jsonFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/"+ "default.json"; - confFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/"+ "theme.conf"; + jsonFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/scr/config/"+ "default.json"; + confFilePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/scr/config/"+ "theme.conf"; qDebug()<<"have"; } @@ -20,7 +20,7 @@ ConfigFileManager::ConfigFileManager(bool ishistory, const QString& time, QObjec bool ConfigFileManager::createJson() { - QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/"; + QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/config/"; QString filePath = m_themePath + "default.json"; jsonFilePath = filePath; @@ -41,7 +41,7 @@ bool ConfigFileManager::createJson() bool ConfigFileManager::createConf() { - QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/config/"; + QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + m_time + "/src/config/"; QString filePath = m_themePath + "theme.conf"; confFilePath = filePath; diff --git a/src/fileProcess/fileprocess.cpp b/src/fileProcess/fileprocess.cpp index 1a91d96..ab9dd41 100644 --- a/src/fileProcess/fileprocess.cpp +++ b/src/fileProcess/fileprocess.cpp @@ -1,6 +1,7 @@ #include "fileprocess.h" QString FileProcess::g_date; +QString FileProcess::g_themeENName; FileProcess::FileProcess() { //创建缓存目录 @@ -16,7 +17,7 @@ FileProcess::FileProcess() } QMap FileProcess::FileSearch(const QString &m_date){ - QString m_getInfoFIlePath = QDir::homePath() + "/.cache/theme-build/" + m_date + "/debian/control"; + QString m_getInfoFIlePath = QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/debian/control"; QMap emptyMap; // 处理文件不存在的情况 if (m_getInfoFIlePath.isEmpty()){ @@ -60,15 +61,18 @@ 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_themeTypePath = m_themePath + "/" + m_themeType; + QString m_builderPathSrc = m_themePath + "/src"; + QDir m_builderSrc = m_builderPathSrc; + 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()); if(m_themeType == "globalTheme"){ - QDir iconPath = m_themePath+ "/iconTheme"; - QDir cursorPath = m_themePath+ "/cursorTheme"; + QDir iconPath = m_builderPathSrc+ "/iconTheme"; + QDir cursorPath = m_builderPathSrc+ "/cursorTheme"; iconPath.mkdir(iconPath.absolutePath()); cursorPath.mkdir(cursorPath.absolutePath()); } diff --git a/src/fileProcess/fileprocess.h b/src/fileProcess/fileprocess.h index 9ec5adb..47eb162 100644 --- a/src/fileProcess/fileprocess.h +++ b/src/fileProcess/fileprocess.h @@ -19,6 +19,7 @@ public: void FileClean(const QString &m_date); static QString g_date; + static QString g_themeENName; private: QDir m_builder; diff --git a/src/filecheck.cpp b/src/filecheck.cpp deleted file mode 100644 index df4dc25..0000000 --- a/src/filecheck.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "filecheck.h" -#include -#include -#include -#include - -FileCheck::FileCheck(QObject *parent) : QObject(parent) -{ - -} - -bool FileCheck::isLegalIconFile(const QString &filePath) -{ - QSvgRenderer renderer(filePath); - - if (renderer.isValid()){ - QSize svgSize = renderer.defaultSize(); - if (svgSize.width() >= 96 && svgSize.height() >= 96 && svgSize.width() == svgSize.height()){ - return true; - } - } - - return false; -} - -bool FileCheck::isLegalWallPaperFile(const QString& filePath, const QString& type) -{ - QFileInfo fileInfo(filePath); - QImage image(filePath); - QSize imageSize = image.size(); - qint64 fileSize = fileInfo.size(); - - if (type == "wallpaper") { - if (imageSize.width() != 3840 || imageSize.height() != 2160){ - QMessageBox::information(nullptr, tr("错误"), tr("壁纸尺寸必须为3840x2160")); - return false; - } - qint64 maxSize = 10 * 1024 * 1024; // 10 MB - if (fileSize > maxSize){ - QMessageBox::information(nullptr, tr("错误"), tr("文件大小不能超过10MB")); - return false; - } - } else if (type == "cover") { - if (imageSize.width() != 1640 || imageSize.height() != 1080){ - QMessageBox::information(nullptr, tr("错误"), tr("封面尺寸必须为1640x1080")); - return false; - } - qint64 maxSize = 5 * 1024 * 1024; // 5 MB - if (fileSize > maxSize){ - QMessageBox::information(nullptr, tr("错误"), tr("文件大小不能超过5MB")); - return false; - } - } - - return true; -} - diff --git a/src/filecheck.h b/src/filecheck.h deleted file mode 100644 index fcf4d05..0000000 --- a/src/filecheck.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FILECHECK_H -#define FILECHECK_H - -#include -#include -class FileCheck : public QObject -{ - Q_OBJECT -public: - explicit FileCheck(QObject *parent = nullptr); - static bool isLegalIconFile(const QString& filePath); - static bool isLegalWallPaperFile(const QString& filePath, const QString& type); - -signals: - -}; - -#endif // FILECHECK_H diff --git a/src/fileprocess.cpp b/src/fileprocess.cpp deleted file mode 100644 index 1a91d96..0000000 --- a/src/fileprocess.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "fileprocess.h" - -QString FileProcess::g_date; -FileProcess::FileProcess() -{ - //创建缓存目录 - m_builder = QDir::homePath()+"/.cache/theme-build/"; - - if (m_builder.exists()){ - qDebug()<<"thmem-build cache Dir exists"; - } else { - m_builder.mkdir(m_builder.absolutePath()); - qDebug()<<"thmem-build cache Dir create"; - } - return; -} - -QMap FileProcess::FileSearch(const QString &m_date){ - QString m_getInfoFIlePath = QDir::homePath() + "/.cache/theme-build/" + m_date + "/debian/control"; - QMap emptyMap; - // 处理文件不存在的情况 - if (m_getInfoFIlePath.isEmpty()){ - qDebug() << m_getInfoFIlePath << "文件不存在!"; - return emptyMap; - } else { - QFile m_getInfoFIle(m_getInfoFIlePath); - if (!m_getInfoFIle.open(QIODevice::ReadOnly | QIODevice::Text)){ - // 处理文件打开失败的情况 - qDebug() << m_getInfoFIlePath << "文件无法打开!"; - return emptyMap; - } else { - QTextStream in(&m_getInfoFIle); - int currentLine = 1; - QString line; - QMap m_packageInfo; - - while (!in.atEnd()){ - line = in.readLine(); - if (currentLine == 1){ - m_packageInfo.insert("key1",line.mid(8)); - } else if(currentLine == 4){ - m_packageInfo.insert("key2",line.mid(12, line.indexOf('<')-12).trimmed()); - m_packageInfo.insert("key3",line.mid(line.indexOf('<') + 1, line.indexOf('>') - line.indexOf('<') - 1).trimmed()); - } - currentLine++; - } - m_getInfoFIle.close(); - return m_packageInfo; - } - return emptyMap; - } -} - -QString FileProcess::FileCreate(const QString &m_themeType){ - - QDateTime currentDateTime = QDateTime::currentDateTime(); - g_date = currentDateTime.toString("yyyyMMddhhmmss"); - qDebug()<< g_date; - - //创建新的记录文件目录 - QString m_themePath = QDir::homePath() + "/.cache/theme-build/" + g_date; - QDir m_builderTime = m_themePath; - QDir m_builderDeb = m_themePath + "/debian"; - QDir m_themeTypePath = m_themePath + "/" + m_themeType; - - - m_builderTime.mkdir(m_builderTime.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; -} - -void FileProcess::FileClean(const QString &m_date){ - QDir m_datePath = QDir::homePath() + "/.cache/theme-build/" + m_date; - m_datePath.removeRecursively(); -} diff --git a/src/fileprocess.h b/src/fileprocess.h deleted file mode 100644 index 9ec5adb..0000000 --- a/src/fileprocess.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef FILEPROCESS_H -#define FILEPROCESS_H - -#include -#include -#include -#include -#include -#include - -class FileProcess -{ -public: - FileProcess(); - - QMap FileSearch(const QString &m_date); - QString FileCreate(const QString &themes); - - void FileClean(const QString &m_date); - - static QString g_date; - -private: - QDir m_builder; -}; - -#endif // FILEPROCESS_H diff --git a/src/globalthemefeature.cpp b/src/globalthemefeature.cpp deleted file mode 100644 index 6d74095..0000000 --- a/src/globalthemefeature.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "globalthemefeature.h" -#include "globalthemewidget.h" -#include -CustomGraphicsView::CustomGraphicsView(QGraphicsScene* scene) : QGraphicsView(scene) { - setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - setDragMode(QGraphicsView::ScrollHandDrag); - setRenderHint(QPainter::Antialiasing, true); - setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | - QGraphicsView::DontSavePainterState); - this->setStyleSheet("background-color: transparent;"); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -} - -void CustomGraphicsView::wheelEvent(QWheelEvent* event) { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) { - qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0); - qreal currentScale = transform().m11(); // 获取当前的缩放倍数 - // 限制最大为1.1倍 - qreal targetScale = currentScale * scaleFactor; - if (targetScale > 1.1) { - scaleFactor = 1.1 / currentScale; - }else if (targetScale < 0.3) { - scaleFactor = 0.3 / currentScale; - } - scale(scaleFactor, scaleFactor); - } else { - QGraphicsView::wheelEvent(event); - } -} - -void GlobalImageWidget::updateWidgetRadius(int sliderValue) { - - int radius = sliderValue; - m_showwidget->setRadius(radius); - m_showwidget->update(); -} - -void GlobalImageWidget::updateButtonColor(const QColor& color) { - QPalette palette = m_showbtn->palette(); - - palette.setColor(QPalette::Button, color); - m_showbtn->setPalette(palette); - - m_showbtn->update(); -} - -void GlobalImageWidget::updateWidgetBackgroundColor(const QColor& color) -{ - m_showwidget->setBackgroundColor(color); - -} - -void GlobalImageWidget::updateOverlayImage(const QString& overlayImagePath) { - QPixmap overlayImage(overlayImagePath); - if (!overlayImage.isNull()) { - m_mergedImage = QPixmap(m_image.size()); - m_mergedImage.fill(Qt::transparent); - - QPainter painter(&m_mergedImage); - painter.drawPixmap(0, 0, m_image); - int x = (m_image.width() - overlayImage.width()) / 2; - int y = m_image.height() - overlayImage.height(); - painter.drawPixmap(x, y, overlayImage); - painter.end(); - - QGraphicsProxyWidget* newproxy = m_proxy; - m_scene->removeItem(m_proxy); - m_scene->clear(); - m_scene->addPixmap(m_mergedImage); - m_scene->setSceneRect(m_mergedImage.rect()); - graphicsView->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio); - - m_scene->addItem(newproxy); - } else { - qDebug() << "Failed to load overlay image."; - } -} - -void GlobalImageWidget::updatescale() -{ - graphicsView->resetTransform(); - QPointF centerPoint(1500, 600); - graphicsView->centerOn(centerPoint); - graphicsView->scale(1, 1); -} - -GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePath) - : QWidget(parent), m_coverFilePath(coverFilePath) { - - m_scene = new QGraphicsScene(this); - graphicsView = new CustomGraphicsView(m_scene); - m_proxy = new QGraphicsProxyWidget(); - - QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(graphicsView); - setLayout(layout); - - m_image = QPixmap(m_coverFilePath); - if (m_image.isNull()) { - qDebug() << "Failed to load image."; - } - - m_mergedImage = QPixmap(m_image.size()); - m_mergedImage.fill(Qt::transparent); - QPainter painter(&m_mergedImage); - painter.drawPixmap(0, 0, m_image); - QPixmap overlayImage(":/resource/background/panel-light.png"); - if (!overlayImage.isNull()) { - int x = (m_image.width() - overlayImage.width()) / 2; - int y = m_image.height() - overlayImage.height(); - painter.drawPixmap(x, y, overlayImage); - } else { - qDebug() << "Failed to load overlay image."; - } - painter.end(); - - m_scene->addPixmap(m_mergedImage); - - m_scene->setSceneRect(m_image.rect()); - graphicsView->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio); - graphicsView->show(); - - m_showwidget = new RoundedWidget(); - m_showwidget->setFixedSize(700,320); - m_showwidget->setRadius(6); - - QPalette widgetpalette = m_showwidget->palette(); - widgetpalette.setColor(QPalette::Background, QColor(255, 255, 255)); - m_showwidget->setAutoFillBackground(true); - m_showwidget->setPalette(widgetpalette); - - QHBoxLayout *buttonlayout = new QHBoxLayout(); - m_showbtn = new QPushButton(m_showwidget); - m_showbtn->setFixedWidth(120); - m_showbtn->setParent(m_showwidget); - - QPalette palette = m_showbtn->palette(); - - palette.setColor(QPalette::Button, QColor(55, 144, 250)); - m_showbtn->setPalette(palette); - - QPushButton *disablebtn = new QPushButton(m_showwidget); - disablebtn->setFixedWidth(120); - - buttonlayout->addStretch(1); - buttonlayout->addWidget(m_showbtn); - buttonlayout->addWidget(disablebtn); - m_showwidget->setLayout(buttonlayout); - - m_proxy->setWidget(m_showwidget); - m_proxy->setPos(800, 400); - - m_scene->addItem(m_proxy); - // 设置初始缩放倍数为0.9倍 - qreal initialScale = 0.9; - graphicsView->scale(initialScale, initialScale); -} - -Globalthemefeature::Globalthemefeature(QWidget *parent, const QString& coverFilePath) - : QWidget(parent) { - GlobalImageWidget* globalImageWidget = new GlobalImageWidget(this, coverFilePath); -} - -RoundedWidget::RoundedWidget(QWidget *parent) - : QWidget(parent), m_radius(0) -{ - setAttribute(Qt::WA_TranslucentBackground); - setRadius(6); -} - -void RoundedWidget::setRadius(int radius) -{ - m_radius = radius; -} - -void RoundedWidget::setBackgroundColor(const QColor &color) -{ - backgroundColor = color; - update(); -} - -void RoundedWidget::paintEvent(QPaintEvent *event) -{ - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, true); // 开启抗锯齿 - - QRectF rect = contentsRect().adjusted(borderWidth, borderWidth, -borderWidth, -borderWidth); - int r = std::min(rect.width(), rect.height()) / 2; // 计算圆角半径 - int actualRadius = std::min(m_radius, r); // 取实际圆角半径和计算半径的较小值 - - // 绘制背景 - painter.setPen(Qt::NoPen); - painter.setBrush(backgroundColor); - painter.drawRoundedRect(rect, actualRadius, actualRadius); - - // 绘制边框 -// painter.setPen(QPen(borderColor, borderWidth)); -// painter.setBrush(Qt::NoBrush); -// painter.drawRoundedRect(rect, actualRadius, actualRadius); - -} diff --git a/src/globalthemefeature.h b/src/globalthemefeature.h deleted file mode 100644 index d4cce84..0000000 --- a/src/globalthemefeature.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef GLOBALTHEMEFEATURE_H -#define GLOBALTHEMEFEATURE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class RoundedWidget : public QWidget -{ - Q_OBJECT - -public: - RoundedWidget(QWidget *parent = nullptr); - - void setRadius(int radius); - void setBackgroundColor(const QColor& color); - -protected: - void paintEvent(QPaintEvent *event) override; - -private: - int m_radius; - QColor backgroundColor = Qt::white; // 背景颜色 - QColor borderColor = Qt::white; // 边框颜色 - int borderWidth = 1; // 边框宽度 -}; - -class CustomGraphicsView : public QGraphicsView { -public: - explicit CustomGraphicsView(QGraphicsScene* scene); - -protected: - void wheelEvent(QWheelEvent* event) override; -}; - -class GlobalImageWidget : public QWidget { -public: - GlobalImageWidget(QWidget *parent = nullptr, const QString& coverFilePath = ""); - void updateWidgetRadius(int sliderValue); - void updateButtonColor(const QColor& color); - void updateWidgetBackgroundColor(const QColor& color); - void update(const QString& coverFilePath); - void updateOverlayImage(const QString& overlayImagePath); - void updatescale(); -private: - CustomGraphicsView* graphicsView; - QString m_coverFilePath; - RoundedWidget *m_showwidget; - QPushButton *m_showbtn; - QGraphicsScene* m_scene; - QPixmap m_mergedImage; - QPixmap m_image; - QGraphicsProxyWidget* m_proxy; -}; - -class Globalthemefeature : public QWidget { - Q_OBJECT -public: - explicit Globalthemefeature(QWidget *parent = nullptr, const QString& coverFilePath = ""); - -signals: - -}; - -#endif // GLOBALTHEMEFEATURE_H diff --git a/src/globalthemewidget.cpp b/src/globalthemewidget.cpp deleted file mode 100644 index 76cba1d..0000000 --- a/src/globalthemewidget.cpp +++ /dev/null @@ -1,302 +0,0 @@ -#include "globalthemewidget.h" -#include "filecheck.h" - -GlobalThemeWidget::GlobalThemeWidget(QWidget *parent) : QWidget(parent) -{ - initPreviewWidget(); - initRightWidget(); - m_globalthemelayout = new QHBoxLayout(); - m_globalthemelayout->addWidget(m_previewwidget); - m_globalthemelayout->addWidget(m_rightwidget); - this->setLayout(m_globalthemelayout); -} - -QString GlobalThemeWidget::getWallpaperPath() -{ - return m_wallpaperpath; -} - -void GlobalThemeWidget::initPreviewWidget() -{ - m_previewwidget = new QWidget(this); - m_previewwidget->setMinimumSize(495,620); - - m_previewwidget->setBackgroundRole(QPalette::Window); - - m_preview = new GlobalImageWidget(m_previewwidget,m_wallpaperpath); - - m_previewlayout = new QVBoxLayout(m_previewwidget); - addspaceritem(); - m_previewwidget->setLayout(m_previewlayout); -} - -void GlobalThemeWidget::initRightWidget() -{ - m_rightwidget = new QWidget(this); - m_rightwidget->setMinimumSize(400,620); - m_rightwidget->setMaximumWidth(400); - m_rightwidget->setBackgroundRole(QPalette::Base); - - m_scrollArea = new QScrollArea(m_rightwidget); - m_scrollArea->setMinimumSize(m_rightwidget->size()); - m_scrollArea->setWidgetResizable(true); - - m_viewportwidget = new QWidget(m_scrollArea); - m_scrollArea->setWidget(m_viewportwidget); - QVBoxLayout *mainLayout = new QVBoxLayout(m_viewportwidget); - - - initCoverWidget(); - initWallPaperWidget(); - initExteriorWidget(); - initFilletWidget(); - AccentColorWidget(); - mainLayout->addWidget(m_coverwidget); - mainLayout->addStretch(1); - mainLayout->addWidget(m_wallpaperwidget); - mainLayout->addStretch(1); - mainLayout->addWidget(m_exteriorwidget); - mainLayout->addStretch(1); - mainLayout->addWidget(m_filletwidget); - mainLayout->addStretch(1); - mainLayout->addWidget(m_accentcolorwidget); - mainLayout->addStretch(1); - - m_viewportwidget->setLayout(mainLayout); - - QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_rightwidget); - mainWidgetLayout->addWidget(m_scrollArea); - m_rightwidget->setLayout(mainWidgetLayout); - -} - -void GlobalThemeWidget::initCoverWidget() -{ - m_coverwidget = new QWidget(m_viewportwidget); - m_coverwidget->setFixedHeight(182); - QLabel *title = new QLabel(m_coverwidget); - title->setText("全局主题效果图"); - QVBoxLayout *layout = new QVBoxLayout(); - - QWidget *cover = new QWidget(m_coverwidget); - cover->setFixedHeight(160); - QHBoxLayout *coverlayout = new QHBoxLayout(cover); - QPushButton *coverbtn = new QPushButton(cover); - coverbtn->setFixedSize(160,100); - QLabel *tip = new QLabel(cover); - tip->setText("尺寸:1640*1080
大小:不超过 5 MB
格式:PNG"); - - coverlayout->addWidget(coverbtn); - coverlayout->addWidget(tip); - cover->setLayout(coverlayout); - - - connect(coverbtn, &QPushButton::clicked, this, [=]() { - QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择图片文件"), "", tr("图片文件 (*.png *.jpg)")); - bool legalFile = FileCheck::isLegalWallPaperFile(newFilePath,"cover"); - - if (newFilePath.isEmpty() || !legalFile) { - newFilePath = m_coverpath; - } - - m_coverpath = newFilePath; - coverbtn->setIcon(QIcon(m_coverpath)); - coverbtn->setIconSize(coverbtn->size()); - emit newCoverFilePath(newFilePath); - - }); - - layout->addStretch(1); - layout->addWidget(title); - layout->addWidget(cover); - m_coverwidget->setLayout(layout); - -} - -void GlobalThemeWidget::initWallPaperWidget() -{ - m_wallpaperwidget = new QWidget(m_viewportwidget); - m_wallpaperwidget->setFixedHeight(182); - QLabel *title = new QLabel(m_wallpaperwidget); - title->setText("全局主题效果图"); - QVBoxLayout *layout = new QVBoxLayout(); - - QWidget *cover = new QWidget(m_wallpaperwidget); - cover->setFixedHeight(160); - QHBoxLayout *coverlayout = new QHBoxLayout(cover); - QPushButton *coverbtn = new QPushButton(cover); - coverbtn->setFixedSize(160,100); - QLabel *tip = new QLabel(cover); - tip->setText("尺寸:3840*2160
大小:不超过 10 MB
格式:PNG"); - - coverlayout->addWidget(coverbtn); - coverlayout->addWidget(tip); - cover->setLayout(coverlayout); - - QPixmap pixmap(m_wallpaperpath); - coverbtn->setIcon(QIcon(pixmap)); - coverbtn->setIconSize(coverbtn->size()); - - connect(coverbtn, &QPushButton::clicked, this, [=]() { - QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择图片文件"), "", tr("图片文件 (*.png *.jpg)")); - - if (!newFilePath.isEmpty() && FileCheck::isLegalWallPaperFile(newFilePath,"wallpaper")) { - updateWallpaperFilePath(newFilePath); - emit wallpaperupdate(newFilePath); - emit newWallpaperFilePath(newFilePath); - - QPixmap pixmap(newFilePath); - coverbtn->setIcon(QIcon(pixmap)); - coverbtn->setIconSize(coverbtn->size()); - } else { - qDebug() << "Selected file path:" << newFilePath; - updateWallpaperFilePath(m_wallpaperpath); - } - }); - - layout->addStretch(1); - layout->addWidget(title); - layout->addWidget(cover); - m_wallpaperwidget->setLayout(layout); -} - -void GlobalThemeWidget::initExteriorWidget() -{ - m_exteriorwidget = new QWidget(m_viewportwidget); - m_exteriorwidget->setFixedHeight(65); - QLabel *title = new QLabel(m_exteriorwidget); - title->setFixedWidth(m_exteriorwidget->width()); - title->setText("窗口外观"); - QHBoxLayout *layout = new QHBoxLayout(); - QComboBox *combobox = new QComboBox(m_exteriorwidget); - - combobox->addItem("浅色",QColor(255, 255, 255)); - combobox->addItem("深色", QColor(29, 29, 29)); - connect(combobox, QOverload::of(&QComboBox::currentIndexChanged), this, [=](int index){ - QColor selectedColor = combobox->itemData(index).value(); - QString overlayImage; - - if (index == 0) { - overlayImage = ":/resource/background/panel-light.png"; - } else if (index == 1) { - overlayImage = ":/resource/background/panel-dark.png"; - } - - m_preview->updateWidgetBackgroundColor(selectedColor); - m_preview->updateOverlayImage(overlayImage); - m_preview->updatescale(); - - emit newExterior(selectedColor); - }); - - layout->addWidget(title); - layout->addWidget(combobox); - - m_exteriorwidget->setLayout(layout); -} - -void GlobalThemeWidget::initFilletWidget() -{ - m_filletwidget = new QWidget(m_viewportwidget); - m_filletwidget->setFixedHeight(65); - QLabel *title = new QLabel(m_filletwidget); - title->setFixedWidth(m_filletwidget->width()); - title->setText("控件圆角"); - QHBoxLayout *layout = new QHBoxLayout(); - QSlider *filletslider = new QSlider(m_filletwidget); - - filletslider->setOrientation(Qt::Horizontal); - filletslider->setFixedWidth(210); - filletslider->setRange(0,18); - filletslider->setSingleStep(1); - filletslider->setTickInterval(1); - filletslider->setFixedWidth(120); - filletslider->setValue(6); - - QPushButton *showButton = new QPushButton(m_filletwidget); - showButton->setDisabled(true); - showButton->setFixedSize(60,36); - int value = 0; - value = filletslider->value(); - showButton->setText(QString::number(filletslider->value())+"px"); - - QObject::connect(filletslider, &QSlider::valueChanged, [=](int value) { - showButton->setText(QString::number(value)+"px"); - m_preview->updatescale(); - m_preview->updateWidgetRadius(value); - emit newRadius(value); - }); - - layout->addWidget(title); - layout->addStretch(1); - layout->addWidget(filletslider); - layout->addWidget(showButton); - - m_filletwidget->setLayout(layout); -} - -void GlobalThemeWidget::AccentColorWidget() -{ - m_accentcolorwidget = new QWidget(m_viewportwidget); - m_accentcolorwidget = new QWidget(m_viewportwidget); - m_accentcolorwidget->setFixedHeight(65); - QLabel *title = new QLabel(m_accentcolorwidget); - title->setFixedWidth(m_accentcolorwidget->width()); - title->setText("强调色"); - QHBoxLayout *layout = new QHBoxLayout(); - QComboBox *combobox = new QComboBox(m_accentcolorwidget); - combobox->addItem("daybreakBlue",QColor(55, 144, 250)); - combobox->addItem("jamPurple", QColor(120, 115, 245)); - combobox->addItem("magenta", QColor(235, 48, 150)); - combobox->addItem("sunRed", QColor(243, 34, 45)); - combobox->addItem("sunsetOrange", QColor(246, 140, 39)); - combobox->addItem("dustGold", QColor(249, 197, 61)); - combobox->addItem("polarGreen", QColor(82, 196, 41)); - - connect(combobox, QOverload::of(&QComboBox::currentIndexChanged), this, [=](int index){ - - QColor selectedColor = combobox->itemData(index).value(); - - qDebug() << "Selected color:" << selectedColor; - - qDebug() << "RGB values:" << selectedColor.red() << selectedColor.green() << selectedColor.blue(); - m_preview->updatescale(); - m_preview->updateButtonColor(selectedColor); - emit newAccentColor(selectedColor); - }); - - layout->addWidget(title); - layout->addWidget(combobox); - - m_accentcolorwidget->setLayout(layout); -} - -void GlobalThemeWidget::updateWallpaperFilePath(const QString& coverFilePath) { - m_wallpaperpath = coverFilePath; - - if (m_preview != nullptr) { - delete m_preview; - delete m_previewlayout; - - m_previewwidget->setMinimumSize(495,620); - m_previewwidget->setBackgroundRole(QPalette::Window); - m_preview = new GlobalImageWidget(m_previewwidget,m_wallpaperpath); - m_previewlayout = new QVBoxLayout(m_previewwidget); - - addspaceritem(); - - m_previewwidget->setLayout(m_previewlayout); - } -} - -void GlobalThemeWidget::addspaceritem() -{ - QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - QSpacerItem *spacer2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - spacer->changeSize(m_previewwidget->width(), 155, QSizePolicy::Maximum, QSizePolicy::Maximum); - spacer2->changeSize(m_previewwidget->width(), 159, QSizePolicy::Maximum, QSizePolicy::Maximum); - - m_previewlayout->addItem(spacer); - m_previewlayout->addWidget(m_preview); - m_previewlayout->addItem(spacer2); -} diff --git a/src/globalthemewidget.h b/src/globalthemewidget.h deleted file mode 100644 index 797aacc..0000000 --- a/src/globalthemewidget.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef GLOBALTHEMEWIDGET_H -#define GLOBALTHEMEWIDGET_H -#include "globalthemefeature.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -class GlobalThemeWidget : public QWidget -{ - Q_OBJECT -public: - explicit GlobalThemeWidget(QWidget *parent = nullptr); - QString getWallpaperPath(); -signals: - void wallpaperupdate(const QString& filePath); - void newWallpaperFilePath(const QString& path); - void newCoverFilePath(const QString& path); - void newRadius(const int radius); - void newAccentColor(const QColor selectedColor); - void newExterior(const QColor selectedColor); -private: - void initPreviewWidget(); - void initRightWidget(); - - void initCoverWidget(); - void initWallPaperWidget(); - void initExteriorWidget(); - void initFilletWidget(); - void AccentColorWidget(); - void updateWallpaperFilePath(const QString& coverFilePath); - void addspaceritem(); - - QWidget *m_globalthemewidget; - QWidget *m_coverwidget; - QWidget *m_wallpaperwidget; - QWidget *m_exteriorwidget; - QWidget *m_filletwidget; - QWidget *m_accentcolorwidget; - QVBoxLayout *m_previewlayout; - QString m_wallpaperpath = ":/resource/background/background-light.png"; - QString m_coverpath = ":/resource/background/background-light.png"; - QWidget *m_viewportwidget; - QScrollArea *m_scrollArea; - - QHBoxLayout *m_globalthemelayout; - QWidget *m_rightwidget; - - - QWidget *m_previewwidget; - GlobalImageWidget *m_preview; -}; - -#endif // GLOBALTHEMEWIDGET_H diff --git a/src/iconthemewidget.cpp b/src/iconthemewidget.cpp deleted file mode 100644 index 22bc7fd..0000000 --- a/src/iconthemewidget.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include "iconthemewidget.h" -#include "filecheck.h" - -IconThemeWidget::IconThemeWidget(QWidget *parent) : QWidget(parent) -{ - initMaps(); - initSystemMaps(); - initPreviewWidget(); - initRightWidget(); - - - QHBoxLayout * m_iconthemelayout = new QHBoxLayout(); - m_iconthemelayout->addWidget(m_previewwidget); - m_iconthemelayout->addWidget(m_rightwidget); - this->setLayout(m_iconthemelayout); -} - -void IconThemeWidget::initPreviewWidget() -{ - m_previewwidget = new QWidget(this); - m_previewwidget->setMinimumSize(550,620); - - m_previewstack = new QStackedWidget(m_previewwidget); - - m_preview = new ImageWidget(m_previewwidget,m_iconpathmap); - m_systempreview = new ImageWidget(m_previewwidget,m_systemiconpathmap); - m_previewstack->addWidget(m_preview); - m_previewstack->addWidget(m_systempreview); - QVBoxLayout *layout = new QVBoxLayout(m_previewwidget); - - QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - QSpacerItem *spacer2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - spacer->changeSize(m_previewwidget->width(), 155, QSizePolicy::Maximum, QSizePolicy::Maximum); - spacer2->changeSize(m_previewwidget->width(), 159, QSizePolicy::Maximum, QSizePolicy::Maximum); - connect(this,&IconThemeWidget::wallpaperupdate, m_preview,[=](const QString& filePath){ - m_preview->updateImage(filePath); - }); - layout->addItem(spacer); - layout->addWidget(m_previewstack); - layout->addItem(spacer2); - - m_previewwidget->setLayout(layout); -} - -void IconThemeWidget::initEditWidget() -{ - - m_editwidget = new QWidget(m_stackedwidget); - QScrollArea *m_scrollArea = new QScrollArea(m_rightwidget); - m_scrollArea->setMinimumSize(m_editwidget->size()); - m_scrollArea->setWidgetResizable(true); - QWidget *viewportWidget = new QWidget(m_scrollArea); - m_scrollArea->setWidget(viewportWidget); - QVBoxLayout *mainLayout = new QVBoxLayout(viewportWidget); - viewportWidget->setLayout(mainLayout); - - - for (auto it = m_iconpathmap->begin(); it != m_iconpathmap->end(); ++it) { - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - - IconEditWidget* widget = new IconEditWidget(viewportWidget); - widget->setdefaulticon(filePath); - widget->setdefaulticonname(widgetName); - mainLayout->addWidget(widget); - - m_pathWidgetMap->insert(widgetName, widget); - - connect(widget->m_addiconbutton, &QPushButton::clicked, this, [=]() { - QPushButton* clickedButton = qobject_cast(sender()); - - if (clickedButton) { - IconEditWidget* clickedWidget = nullptr; - QWidget *widget = clickedButton->parentWidget(); - while (widget && !widget->inherits("IconEditWidget")) { - widget = widget->parentWidget(); - } - clickedWidget = qobject_cast(widget); - - if (clickedWidget) { - QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择SVG文件"), "", tr("SVG 文件 (*.svg)")); - - if (!newFilePath.isEmpty()) { - m_customiconpathmap->insert(widgetName, newFilePath); - clickedWidget->setcustomicon(newFilePath); - qDebug() << "Selected file path:" << newFilePath<< "Corresponding widgetName:" << widgetName; - m_preview->updateIcon(widgetName, newFilePath); - } - emit newAppIconsMap(m_customiconpathmap); - } - } - }); - } - - QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_editwidget); - mainWidgetLayout->addWidget(m_scrollArea); - m_editwidget->setLayout(mainWidgetLayout); -} - -void IconThemeWidget::initSystemEditWidget() -{ - m_systemeditwidget = new QWidget(m_stackedwidget); - QScrollArea *m_systemscrollArea = new QScrollArea(m_rightwidget); - m_systemscrollArea->setWidgetResizable(true); - QWidget *viewportWidget = new QWidget(m_systemscrollArea); - m_systemscrollArea->setWidget(viewportWidget); - QVBoxLayout *mainLayout = new QVBoxLayout(viewportWidget); - viewportWidget->setLayout(mainLayout); - - - for (auto it = m_systemiconpathmap->begin(); it != m_systemiconpathmap->end(); ++it) { - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - qDebug() <<"key----------" <setdefaulticon(filePath); - widget->setdefaulticonname(widgetName); - mainLayout->addWidget(widget); - - m_systempathWidgetMap->insert(widgetName, widget); - - connect(widget->m_addiconbutton, &QPushButton::clicked, this, [=]() { - - QPushButton* clickedButton = qobject_cast(sender()); - if (clickedButton) { - IconEditWidget* clickedWidget = nullptr; - QWidget *widget = clickedButton->parentWidget(); - while (widget && !widget->inherits("IconEditWidget")) { - widget = widget->parentWidget(); - } - clickedWidget = qobject_cast(widget); - if (clickedWidget) { - - QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择SVG文件"), "", tr("SVG 文件 (*.svg)")); - if (!newFilePath.isEmpty()) { - //check - if(FileCheck::isLegalIconFile(newFilePath)){ - m_systemcustomiconpathmap->insert(widgetName, newFilePath); - clickedWidget->setcustomicon(newFilePath); - - qDebug() << "Selected file path:" << newFilePath<< "Corresponding widgetName:" << widgetName; - m_systempreview->updateIcon(widgetName, newFilePath); - } - } - emit newSystemIconsMap(m_systemcustomiconpathmap); - } - } - }); - } - - QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_systemeditwidget); - mainWidgetLayout->addWidget(m_systemscrollArea); - m_systemeditwidget->setLayout(mainWidgetLayout); -} - -QStringList IconThemeWidget::getWidgetNamesFromFilesInDirectory(const QString& directoryPath) { - QStringList widgetNames; - QDir dir(directoryPath); - - QStringList fileNames = dir.entryList(QDir::Files); - foreach (const QString& fileName, fileNames) { - QFileInfo fileInfo(fileName); - QString widgetName = fileInfo.baseName(); - widgetNames.append(widgetName); - } - - return widgetNames; -} - -void IconThemeWidget::initMaps() -{ - m_iconpathmap = new QMap; - QString directoryPath = ":/resource/appicons/"; - QStringList widgetNames = getWidgetNamesFromFilesInDirectory(directoryPath); - - for (int i = 0; i < widgetNames.size(); ++i) { - qDebug() << widgetNames[i]; - QString cursorFileName = directoryPath + widgetNames[i] + ".png"; - m_iconpathmap->insert(widgetNames[i], cursorFileName); - } - - m_customiconpathmap = m_iconpathmap; - m_pathWidgetMap = new QMap; -} - -void IconThemeWidget::initSystemMaps() -{ - - m_systemiconpathmap = new QMap ; - QString directoryPath = ":/resource/systemicons/"; - QStringList widgetNames = getWidgetNamesFromFilesInDirectory(directoryPath); - - for (int i = 0; i < widgetNames.size(); ++i) { - qDebug() << widgetNames[i]; - QString cursorFileName = directoryPath + widgetNames[i] + ".png"; - m_systemiconpathmap->insert(widgetNames[i], cursorFileName); - for (const auto& key : m_systemiconpathmap->keys()) { - const QString& value = m_systemiconpathmap->value(key); - qDebug() <<"key----------" <keys() <<"value-----------" <; -} - -void IconThemeWidget::initRightWidget() -{ - m_rightwidget = new QWidget(this); - m_rightwidget->setMinimumSize(400,620); - m_rightwidget->setMaximumWidth(400); - - - m_rightwidgetlayout = new QVBoxLayout(m_rightwidget); - - QWidget *m_changebuttonwidget = new QWidget(m_rightwidget); - m_changebuttonwidget->setMinimumSize(400,70); - QHBoxLayout *layout = new QHBoxLayout(); - - QButtonGroup *group = new QButtonGroup(m_changebuttonwidget); - m_appiconbtn = new QPushButton(); - m_systemiconbtn = new QPushButton(); - group->setExclusive(true); - group->addButton(m_appiconbtn); - group->addButton(m_systemiconbtn); - - m_appiconbtn->setCheckable(true); - m_systemiconbtn->setCheckable(true); - m_appiconbtn->setChecked(true); - - layout->addWidget(m_appiconbtn); - layout->addWidget(m_systemiconbtn); - m_changebuttonwidget->setLayout(layout); - - m_stackedwidget = new QStackedWidget(m_rightwidget); - - initEditWidget(); - initSystemEditWidget(); - m_stackedwidget->addWidget(m_editwidget); - m_stackedwidget->addWidget(m_systemeditwidget); - - m_stackedwidget->setCurrentIndex(0); - - QObject::connect(m_appiconbtn, &QPushButton::clicked,m_stackedwidget, [=]() { - m_stackedwidget->setCurrentIndex(0); - m_previewstack->setCurrentIndex(0); - }); - - QObject::connect(m_systemiconbtn, &QPushButton::clicked,m_stackedwidget, [=](){ - m_stackedwidget->setCurrentIndex(1); - m_previewstack->setCurrentIndex(1); - }); - - m_rightwidgetlayout->addWidget(m_changebuttonwidget); - m_rightwidgetlayout->addWidget(m_stackedwidget); - - m_rightwidget->setLayout(m_rightwidgetlayout); -} diff --git a/src/iconthemewidget.h b/src/iconthemewidget.h deleted file mode 100644 index 117ee99..0000000 --- a/src/iconthemewidget.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef ICONTHEMEWIDGET_H -#define ICONTHEMEWIDGET_H -#include "iconwidgetfeature.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class IconThemeWidget : public QWidget -{ - Q_OBJECT -public: - explicit IconThemeWidget(QWidget *parent = nullptr); - void initPreviewWidget(); - void initEditWidget(); - void initSystemEditWidget(); - void initMaps(); - void initSystemMaps(); - void initRightWidget(); -signals: - void wallpaperupdate(const QString& filePath); - void newAppIconsMap(QMap *appiconsmap); - void newSystemIconsMap(QMap *systemiconsmap); -private: - QStringList getWidgetNamesFromFilesInDirectory(const QString& directoryPath); - - QStackedWidget *m_themestackedwidget; - QWidget *m_rightwidget; - QVBoxLayout *m_rightwidgetlayout; - QStackedWidget *m_stackedwidget; - - QPushButton *m_appiconbtn; - QPushButton *m_systemiconbtn; - - QMap *m_iconpathmap; - QMap *m_customiconpathmap; - QMap *m_pathWidgetMap; - - QMap *m_systemiconpathmap; - QMap *m_systemcustomiconpathmap; - QMap *m_systempathWidgetMap; - - QWidget *m_previewwidget; - ImageWidget *m_preview; - ImageWidget *m_systempreview; - QStackedWidget *m_previewstack; - - QWidget *m_editwidget; - QWidget *m_systemeditwidget; -}; - -#endif // ICONTHEMEWIDGET_H diff --git a/src/iconwidgetfeature.cpp b/src/iconwidgetfeature.cpp deleted file mode 100644 index 91bc7a3..0000000 --- a/src/iconwidgetfeature.cpp +++ /dev/null @@ -1,336 +0,0 @@ -#include "iconwidgetfeature.h" - -MainInterFaceFeature::MainInterFaceFeature(QWidget *parent) : QWidget(parent) -{ - -} -TypeButton::TypeButton(QWidget *parent): QPushButton(parent) -{ - setCheckable(true); -} - -void TypeButton::paintEvent(QPaintEvent *event) -{ - QPushButton::paintEvent(event); - - if (isChecked()) { - QPainter painter(this); - QIcon icon = QIcon::fromTheme("kylin-settings-account"); - QPixmap pixmap = icon.pixmap(QSize(16, 16)); - QRect pixmapRect(rect().right() - pixmap.width(), (rect().height() - pixmap.height()) / 2, pixmap.width(), pixmap.height()); - painter.drawPixmap(pixmapRect, pixmap); - } -} - - - -IconGraphicsView::IconGraphicsView(QGraphicsScene* scene) : QGraphicsView(scene) -{ - setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - setDragMode(QGraphicsView::ScrollHandDrag); - setRenderHint(QPainter::Antialiasing, true); - setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing |QGraphicsView::DontSavePainterState); - - this->setStyleSheet("background-color: transparent;"); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -} - -void IconGraphicsView::wheelEvent(QWheelEvent* event) -{ -// if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) { -// qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0); -// scale(scaleFactor, scaleFactor); -// } else { -// QGraphicsView::wheelEvent(event); -// } - - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) { - qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0); - qreal currentScale = transform().m11(); // 获取当前的缩放倍数 - - // 限制最大为1.1倍 - qreal targetScale = currentScale * scaleFactor; - if (targetScale > 1.1) { - scaleFactor = 1.1 / currentScale; - }else if (targetScale < 0.3) { - scaleFactor = 0.3 / currentScale; - } - - scale(scaleFactor, scaleFactor); - } else { - QGraphicsView::wheelEvent(event); - } -} - -ImageWidget::ImageWidget(QWidget *parent, const QMap* iconMap) - : QWidget(parent), m_iconMap(iconMap) -{ - - QGraphicsScene* scene = new QGraphicsScene(this); - scene->setBackgroundBrush(Qt::transparent); - graphicsView = new IconGraphicsView(scene); - - QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(graphicsView); - setLayout(layout); - - - int count = m_iconMap->size(); - if(count == 11){ - image = new QPixmap(":/resource/background/controlcenter-light.png"); - if (image->isNull()) { - qDebug() << "Failed to load image."; - } - }else{ - image = new QPixmap(":/resource/background/background-light.png"); - if (image->isNull()) { - qDebug() << "Failed to load image."; - } - } - scene->addPixmap(*image); - graphicsView->setScene(scene); - graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio); - graphicsView->show(); - - - if (count == 11) { - - QList keys = m_iconMap->keys(); - QString positions[11] = { keys[0], keys[9], keys[4], keys[5], keys[6], - keys[3], keys[10], keys[8], keys[1], keys[7], keys[2] }; - - int posX[3] = { 208, 879, 1550 }; - int posY[4] = { 275, 535, 795, 1055 }; - int index = 0; - - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 3; ++j) { - if (index >= 11) { - break; // 处理超出索引范围的情况 - } - - QString pixmapPath = m_iconMap->value(positions[index]); - QPixmap pixmap(pixmapPath); - QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(100, 100)); - item->setFlag(QGraphicsItem::ItemIsSelectable); // 启用选择事件 - item->setFlag(QGraphicsItem::ItemIsFocusable); // 启用焦点事件 - item->setData(0, keys[index]); - item->setData(1, pixmapPath); - item->setPos(posX[j], posY[i]); - - ++index; - } - } - } - else{ - int columnCount = 10; - int row = 1; - int col = 2; - for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) { - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - - QPixmap pixmap(filePath); - if (!pixmap.isNull()) { - QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(128, 128)); - item->setFlag(QGraphicsItem::ItemIsSelectable); // 启用选择事件 - item->setFlag(QGraphicsItem::ItemIsFocusable); // 启用焦点事件 - item->setPos(col * 160, row * 160); - item->setScale(1.0); - item->setData(0, widgetName); - item->setData(1, filePath); - qDebug()<<"widgetName"<= columnCount) { - col = 2; - row++; - } - } else { - qDebug() << "Failed to load image:" << filePath; - } - } - } - - // 设置初始缩放倍数为0.9倍 - qreal initialScale = 0.9; - graphicsView->scale(initialScale, initialScale); - -} - -void ImageWidget::updateImage(const QString& imagePath) -{ - if (image != nullptr) { - delete image; - image = nullptr; - } - image = new QPixmap(imagePath); - if (image->isNull()) { - qDebug() << "Failed to load image."; - } - - QGraphicsScene* scene = graphicsView->scene(); - scene->clear(); - - scene->addPixmap(*image); - int columnCount = 10; - int row = 1; - int col = 2; - for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) { - const QString& widgetName = it.key(); - const QString& filePath = it.value(); - - QPixmap pixmap(filePath); - if (!pixmap.isNull()) { - QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(128, 128)); - - item->setPos(col * 160, row * 160); - item->setScale(1.0); - item->setData(0, widgetName); - item->setData(1, filePath); - - col++; - if (col >= columnCount) { - col = 2; - row++; - } - } else { - qDebug() << "Failed to load image:" << filePath; - } - } - graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio); -} - -void ImageWidget::updateIcon(const QString& widgetName, const QString& newFilePath) -{ - QGraphicsScene* scene = graphicsView->scene(); - QList items = scene->items(); - for (int i = 0; i < items.size(); ++i) { - QGraphicsItem* item = items.at(i); - // 输出item的内容,例如位置和类型等信息 - qDebug() << "Item" << i << ":" - << "Position:" << item->pos() - << "Type:" << item->type(); - } - for (QGraphicsItem* item : items) { - QGraphicsPixmapItem* pixmapItem = dynamic_cast(item); - qDebug()<data(0).toString() == widgetName) { - qDebug()<<"!!!!!sss!!!!!!"; - QPointF oldPosition = pixmapItem->pos(); - scene->removeItem(pixmapItem); - delete pixmapItem; - QPixmap newPixmap(newFilePath); - if (!newPixmap.isNull()) { - if(widgetName.contains("kylin-setting")){ - QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(100, 100)); - newPixmapItem->setData(0, widgetName); - newPixmapItem->setData(1, newFilePath); - newPixmapItem->setPos(oldPosition); - }else{ - QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(128, 128)); - newPixmapItem->setData(0, widgetName); - newPixmapItem->setData(1, newFilePath); - newPixmapItem->setPos(oldPosition); - } - - } else { - qDebug() << "Failed to load image:" << newFilePath; - } - return; - } - } -} - -IconEditWidget::IconEditWidget(QWidget *parent) -{ - QVBoxLayout *widgetLayout = new QVBoxLayout(this); - - // 创建一个 QFrame 作为边框容器 - QFrame *frame = new QFrame(this); - frame->setFrameShape(QFrame::Box); // 设置边框样式 - frame->setLineWidth(1); // 设置边框宽度为 2 像素 - - QVBoxLayout *innerLayout = new QVBoxLayout(); - m_label = new QLabel(); - QWidget *editwidget = new QWidget(); - - QHBoxLayout *m_iconwidgetlayout = new QHBoxLayout(); - m_icondefaultlabel = new QLabel(); - m_icondefaultlabel->setFixedSize(48,48); - - m_icondecustomlabel = new CustomLabel(); - - m_addiconbutton = new QPushButton(); - m_addiconbutton->setIcon(QIcon::fromTheme("list-add-symbolic")); - m_addiconbutton->setFixedSize(36,36); - - QLabel *m_tiplabel = new QLabel(); - m_tiplabel->setWordWrap(true); - m_tiplabel->setText("格式:svg
尺寸:96*96"); - - m_iconwidgetlayout->addWidget(m_icondefaultlabel); - m_iconwidgetlayout->addWidget(m_icondecustomlabel); - m_iconwidgetlayout->addWidget(m_addiconbutton); - m_iconwidgetlayout->addWidget(m_tiplabel); - editwidget->setLayout(m_iconwidgetlayout); - - innerLayout->addWidget(m_label); - innerLayout->addWidget(editwidget); - - frame->setLayout(innerLayout); - widgetLayout->addWidget(frame); - -} - -void IconEditWidget::setdefaulticon(QString iconname) -{ - m_icondefaultlabel->setPixmap(QIcon::fromTheme(iconname).pixmap(48,48)); -} - -void IconEditWidget::setdefaulticonname(QString iconname) -{ - m_label->setText(iconname); -} - -void IconEditWidget::setcustomicon(QString iconFilePath) -{ - QPixmap pixmap(iconFilePath); - m_icondecustomlabel->setPixmap(pixmap.scaled(48, 48)); -} - - -CustomLabel::CustomLabel(QWidget *parent): QLabel(parent), pixmap() -{ - this->setFixedSize(48,48); -} - -void CustomLabel::paintEvent(QPaintEvent *event) -{ - QLabel::paintEvent(event); - QPainter painter(this); - QPen pen(Qt::blue); - pen.setStyle(Qt::DashLine); - painter.setPen(pen); - - QBrush brush(QColor("#F5F5F5")); - painter.setBrush(brush); - - - QRect roundedRect = rect().adjusted(1, 1, -1, -1); - QPainterPath path; - int radius = 6; - path.addRoundedRect(roundedRect, radius, radius); - painter.drawPath(path); - - if (!pixmap.isNull()) { - painter.drawPixmap(rect(), pixmap); - } -} - -void CustomLabel::setPixmap(const QPixmap &pixmap) -{ - this->pixmap = pixmap; - update(); -} - diff --git a/src/iconwidgetfeature.h b/src/iconwidgetfeature.h deleted file mode 100644 index 5419725..0000000 --- a/src/iconwidgetfeature.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef MAININTERFACEFEATURE_H -#define MAININTERFACEFEATURE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class MainInterFaceFeature : public QWidget -{ - Q_OBJECT -public: - explicit MainInterFaceFeature(QWidget *parent = nullptr); - -}; - -class TypeButton : public QPushButton -{ -public: - TypeButton(QWidget *parent = nullptr); - -protected: - void paintEvent(QPaintEvent *event) override; - -}; - - -class IconGraphicsView : public QGraphicsView { -public: - explicit IconGraphicsView(QGraphicsScene* scene); - -protected: - void wheelEvent(QWheelEvent* event) override; -}; -class ImageWidget : public QWidget { -public: - ImageWidget(QWidget *parent = nullptr, const QMap* iconMap = nullptr); - - void setIconMap(QMap*); - void updateIcon(const QString& widgetName, const QString& newFilePath); - void updateImage(const QString& imagePath); -private: - const QMap* m_iconMap; - QPixmap* image; - IconGraphicsView* graphicsView; - QString m_coverFilePath; -}; - -class CustomLabel : public QLabel { -public: - explicit CustomLabel(QWidget* parent = nullptr); - - void setPixmap(const QPixmap& pixmap); - -protected: - void paintEvent(QPaintEvent* event) override; - -private: - QPixmap pixmap; -}; - -class IconEditWidget : public QWidget -{ - Q_OBJECT -public: - IconEditWidget(QWidget *parent = nullptr); - void setdefaulticon(QString iconname); - void setdefaulticonname(QString iconname); - void setcustomicon(QString iconFilePath); - QLabel *m_label; - QPushButton *m_addiconbutton; - -private: - - QLabel *m_icondefaultlabel; - CustomLabel *m_icondecustomlabel; - -}; -#endif // MAININTERFACEFEATURE_H diff --git a/src/infocreatefeature.cpp b/src/infocreatefeature.cpp deleted file mode 100644 index 7cc40b8..0000000 --- a/src/infocreatefeature.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "infocreatefeature.h" - -//theme info proecessing -InfoCreateFeature::InfoCreateFeature() -{ - -} diff --git a/src/infocreatefeature.h b/src/infocreatefeature.h deleted file mode 100644 index 9b31f1e..0000000 --- a/src/infocreatefeature.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef INFOCREATEFEATURE_H -#define INFOCREATEFEATURE_H - -#include -#include -#include -#include - -#include "infocreatewidget.h" - -class InfoCreateFeature -{ - -public: - InfoCreateFeature(); - -private: -}; - -#endif // INFOCREATEFEATURE_H diff --git a/src/infocreatewidget.cpp b/src/infocreatewidget.cpp deleted file mode 100644 index 8f37eeb..0000000 --- a/src/infocreatewidget.cpp +++ /dev/null @@ -1,295 +0,0 @@ -#include "infocreatewidget.h" - -//create theme info graphical interface -InfoCreateWidget::InfoCreateWidget(QWidget *parent, const QString &m_date, - const QString &m_state) : QWidget(parent) -{ - this->setFixedSize(424,404); - this->setWindowModality(Qt::ApplicationModal); - - InitThemeName(); - InitBuilderInfo(); - InitInfoBtn(m_state); - InfoProcess(m_date); - - m_warningMessage = new QLabel(); - m_warningMessage->setText(""); - m_warningMessage2 = new QLabel(); - m_warningMessage2->setText(""); - m_warningMessage3 = new QLabel(); - m_warningMessage3->setText(""); - m_warningMessage4 = new QLabel(); - m_warningMessage4->setText(""); - - QVBoxLayout *m_infoCreateLayout = new QVBoxLayout(this); - m_infoCreateLayout->addLayout(m_themeNameCNLayout); - m_infoCreateLayout->addWidget(m_warningMessage); - m_infoCreateLayout->addLayout(m_themeNameENLayout); - m_infoCreateLayout->addWidget(m_warningMessage2); - m_infoCreateLayout->addLayout(m_builderNameLayout); - m_infoCreateLayout->addWidget(m_warningMessage3); - m_infoCreateLayout->addLayout(m_builderMailLayout); - m_infoCreateLayout->addWidget(m_warningMessage4); - m_infoCreateLayout->addLayout(m_infoBtnLayout); - - this->setLayout(m_infoCreateLayout); -} - -void InfoCreateWidget::InitThemeName(){ - - m_themeNameCNLayout = new QHBoxLayout(); - m_themeNameCNLabel = new QLabel(); - m_themeNameCNLineEdit = new QLineEdit(); - m_themeNameCNLabel->setText("ThemeName-CN"); - m_themeNameCNLineEdit->setEchoMode(QLineEdit::Normal); - - m_themeNameCNLayout->addWidget(m_themeNameCNLabel); - m_themeNameCNLayout->addWidget(m_themeNameCNLineEdit); - - m_themeNameENLayout = new QHBoxLayout(); - m_themeNameENLabel = new QLabel(); - m_themeNameENLineEdit = new QLineEdit(); - m_themeNameENLabel->setText("ThemeName-EN"); - m_themeNameENLineEdit->setEchoMode(QLineEdit::Normal); - - m_themeNameENLayout->addWidget(m_themeNameENLabel); - m_themeNameENLayout->addWidget(m_themeNameENLineEdit); - - -} - -void InfoCreateWidget::InitBuilderInfo(){ - - m_builderNameLayout = new QHBoxLayout(); - m_builderNameLabel = new QLabel(); - m_builderNameLineEdit = new QLineEdit(); - m_builderNameLabel->setText("Builder Name"); - m_builderNameLineEdit->setEchoMode(QLineEdit::Normal); - - m_builderNameLayout->addWidget(m_builderNameLabel); - m_builderNameLayout->addWidget(m_builderNameLineEdit); - - m_builderMailLayout = new QHBoxLayout(); - m_builderMailLabel = new QLabel(); - m_builderMailLineEdit = new QLineEdit(); - m_builderMailLabel->setText("Builder Mail"); - m_builderMailLineEdit->setEchoMode(QLineEdit::Normal); - - m_builderMailLayout->addWidget(m_builderMailLabel); - m_builderMailLayout->addWidget(m_builderMailLineEdit); -} - -void InfoCreateWidget::InitInfoBtn(const QString &m_state){ - - m_infoBtnLayout = new QHBoxLayout(); - m_exitBtn = new QPushButton(); - m_recogniseBtn = new QPushButton(); - m_createDebBtn = new QPushButton(); - m_exitBtn->setText("Back"); - m_recogniseBtn->setText("OK"); - m_createDebBtn->setText("Create"); - - m_infoBtnLayout->addWidget(m_exitBtn); - m_infoBtnLayout->addWidget(m_recogniseBtn); - m_infoBtnLayout->addWidget(m_createDebBtn); - - if(m_state == "recognise"){ - m_recogniseBtn->setHidden(false); - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setHidden(true); - } else if(m_state == "create"){ - if (m_builderNameLineEdit->text() != nullptr && m_themeNameENLineEdit->text() != nullptr - && m_builderMailLineEdit->text() != nullptr ){ - m_recogniseBtn->setHidden(true); - m_createDebBtn->setHidden(false); - m_createDebBtn->setEnabled(true); - } else { - m_recogniseBtn->setHidden(true); - m_createDebBtn->setHidden(false); - m_createDebBtn->setEnabled(false); - } - } else { - qDebug() << m_state; - } -} - -void InfoCreateWidget::InfoProcess(const QString &m_date){ - m_themeENNameState = false; - m_builderMailState = false; - m_builderNameState = false; - // 监听文本变化 - QObject::connect(m_themeNameCNLineEdit, &QLineEdit::textChanged, [this]() { - - m_warningMessage->setText("11111111111"); - }); - - QObject::connect(m_themeNameENLineEdit, &QLineEdit::textChanged, [this]() { - m_themeENName = m_themeNameENLineEdit->text(); - QRegExp englishRegexp("[A-Za-z0-9]+$"); - if(m_themeNameENLineEdit != nullptr){ - if (englishRegexp.exactMatch(m_themeENName)){ - m_warningMessage2->setText(""); - m_themeENNameState = true; - if (m_themeENNameState && m_builderMailState && m_builderNameState){ - m_recogniseBtn->setEnabled(true); - m_createDebBtn->setEnabled(true); - } else { - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - } else { - QPalette m_fontqpe; - m_fontqpe.setColor(QPalette::WindowText,Qt::red); - m_warningMessage2->setPalette(m_fontqpe); - m_warningMessage2->setText("输入格式错误!"); - m_themeENNameState = false; - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - } else { - QPalette m_fontqpe; - m_fontqpe.setColor(QPalette::WindowText,Qt::red); - m_warningMessage2->setPalette(m_fontqpe); - m_warningMessage2->setText("输入为空!"); - m_themeENNameState = false; - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - }); - - QObject::connect(m_builderNameLineEdit, &QLineEdit::textChanged, [this]() { - - m_builderName = m_builderNameLineEdit->text(); - QRegExp englishRegexp("[A-Za-z0-9]+$"); - if(m_themeNameENLineEdit != nullptr){ - if (englishRegexp.exactMatch(m_builderName)){ - m_warningMessage3->setText(""); - m_builderNameState = true; - if (m_themeENNameState && m_builderMailState && m_builderNameState){ - m_recogniseBtn->setEnabled(true); - m_createDebBtn->setEnabled(true); - } else { - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - } else { - QPalette m_fontqpe; - m_fontqpe.setColor(QPalette::WindowText,Qt::red); - m_warningMessage3->setPalette(m_fontqpe); - m_warningMessage3->setText("输入格式错误!"); - m_builderNameState = false; - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - } else { - QPalette m_fontqpe; - m_fontqpe.setColor(QPalette::WindowText,Qt::red); - m_warningMessage3->setPalette(m_fontqpe); - m_warningMessage3->setText("输入为空!"); - m_builderNameState = false; - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - }); - - QObject::connect(m_builderMailLineEdit, &QLineEdit::textChanged, [this]() { - - m_builderMail = m_builderMailLineEdit->text(); - QRegExp mailRegexp("\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b"); - if(m_themeNameENLineEdit != nullptr){ - if (mailRegexp.exactMatch(m_builderMail)){ - m_warningMessage4->setText(""); - m_builderMailState = true; - if (m_themeENNameState && m_builderNameState && m_builderMailState){ - m_recogniseBtn->setEnabled(true); - m_createDebBtn->setEnabled(true); - } else { - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - } else { - QPalette m_fontqpe; - m_fontqpe.setColor(QPalette::WindowText,Qt::red); - m_warningMessage4->setPalette(m_fontqpe); - m_warningMessage4->setText("输入格式错误!"); - m_builderMailState = false; - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - } else { - QPalette m_fontqpe; - m_fontqpe.setColor(QPalette::WindowText,Qt::red); - m_warningMessage4->setPalette(m_fontqpe); - m_warningMessage4->setText("输入为空!"); - m_builderMailState = false; - m_recogniseBtn->setEnabled(false); - m_createDebBtn->setEnabled(false); - } - }); - - //退出信息收集页面 - connect(m_exitBtn, &QPushButton::clicked,this,[=](){ - this->close(); - }); - - //创建control/changelog文件 - connect(m_recogniseBtn, &QPushButton::clicked,this,[=](){ - createControlChangelog(m_date); - }); - - //获取已输入信息,再次确认后开始编译 - connect(m_createDebBtn,&QPushButton::clicked,this,[=](){ - createControlChangelog(FileProcess::g_date); - //清空日期缓存 - FileProcess::g_date = nullptr; - //发送文件复制信号 - emit readytoBuild(); - }); -} - -void InfoCreateWidget::createControlChangelog(const QString &m_date){ - //点击生成制作主题包按钮时,m_date将设为空 - qDebug()<"); - m_controlStream << endl << QStringLiteral("Build-Depends: debhelper-compat (= 13), dh-python, python3-setuptools, python3-all"); - m_controlStream << endl << QStringLiteral("Standards-Version: 4.6.0"); - m_controlStream << endl << QStringLiteral("Rules-Requires-Root: no"); - m_controlStream << endl; - m_controlStream << endl << QStringLiteral("Package: ") + m_themeENName; - m_controlStream << endl << QStringLiteral("Architecture: all"); - m_controlStream << endl << QStringLiteral("Depends: ${python3:Depends}, ${misc:Depends}"); - m_controlStream << endl << QStringLiteral("Description: Theme Package ") + m_themeENName; - } - - QFile m_changelog(QDir::homePath() + "/.cache/theme-build/" + m_date + "/debian/changelog"); - - if (m_changelog.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){ - QTextStream m_changelogStream(&m_changelog); - m_changelogStream << m_themeENName + QStringLiteral(" (1.0-1) UNRELEASED; urgency=medium"); - m_changelogStream << endl; - m_changelogStream << endl << QStringLiteral(" * Initial release"); - m_changelogStream << endl; - m_changelogStream << endl << QStringLiteral(" -- ") + m_builderName + QStringLiteral(" <") + m_builderMail - + QStringLiteral("> Wed, 30 Aug 2023 14:42:06 +0800"); - } - - this->close(); - } -} - -void InfoCreateWidget::getFileInfo(const QMap &m_packageInfo){ - m_themeNameENLineEdit->setText(m_packageInfo.value("key1").toString()); - m_builderNameLineEdit->setText(m_packageInfo.value("key2").toString()); - m_builderMailLineEdit->setText(m_packageInfo.value("key3").toString()); -} - diff --git a/src/infocreatewidget.h b/src/infocreatewidget.h deleted file mode 100644 index 94e5dc6..0000000 --- a/src/infocreatewidget.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INFOCREATEWIDGET_H -#define INFOCREATEWIDGET_H - -#include "fileprocess.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class InfoCreateWidget : public QWidget -{ - Q_OBJECT -public: - explicit InfoCreateWidget(QWidget *parent = nullptr); - explicit InfoCreateWidget(QWidget *parent, const QString &m_date, const QString &m_state); - - void InitThemeName(); - void InitBuilderInfo(); - void InitInfoBtn(const QString &m_state); - void InfoProcess(const QString &m_date); - void InfoCreateBtn(); - - QString m_themeENName; - QString m_builderMail; - QString m_builderName; - - void createControlChangelog(const QString &m_date); - void getFileInfo(const QMap &m_packageInfo); -signals: - void readytoBuild(); -private: - QLabel *m_warningMessage; - QLabel *m_warningMessage2; - QLabel *m_warningMessage3; - QLabel *m_warningMessage4; - - QHBoxLayout *m_themeNameCNLayout; - QLabel *m_themeNameCNLabel; - QLineEdit *m_themeNameCNLineEdit; - - QHBoxLayout *m_themeNameENLayout; - QLabel *m_themeNameENLabel; - QLineEdit *m_themeNameENLineEdit; - - QHBoxLayout *m_builderNameLayout; - QLabel *m_builderNameLabel; - QLineEdit *m_builderNameLineEdit; - - QHBoxLayout *m_builderMailLayout; - QLabel *m_builderMailLabel; - QLineEdit *m_builderMailLineEdit; - - QHBoxLayout *m_infoBtnLayout; - QPushButton *m_exitBtn; - QPushButton *m_recogniseBtn; - QPushButton *m_createDebBtn; - - bool m_themeENNameState; - bool m_builderNameState; - bool m_builderMailState; -}; - -#endif // INFOCREATEWIDGET_H diff --git a/src/module/infocreatewidget.cpp b/src/module/infocreatewidget.cpp index ceba198..c3b3d9a 100644 --- a/src/module/infocreatewidget.cpp +++ b/src/module/infocreatewidget.cpp @@ -124,10 +124,10 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){ }); QObject::connect(m_themeNameENLineEdit, &QLineEdit::textChanged, [this]() { - m_themeENName = m_themeNameENLineEdit->text(); + FileProcess::g_themeENName = m_themeNameENLineEdit->text(); QRegExp englishRegexp("[A-Za-z0-9]+$"); if(m_themeNameENLineEdit != nullptr){ - if (englishRegexp.exactMatch(m_themeENName)){ + if (englishRegexp.exactMatch(FileProcess::g_themeENName)){ m_warningMessage2->setText(""); m_themeENNameState = true; if (m_themeENNameState && m_builderMailState && m_builderNameState){ @@ -240,13 +240,14 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){ //获取已输入信息,再次确认后开始编译 connect(m_createDebBtn,&QPushButton::clicked,this,[=](){ createControlChangelog(FileProcess::g_date); - //清空日期缓存 - FileProcess::g_date = nullptr; //发送文件复制信号 emit readytoBuild(); - -// buildCheckWidget *m_buildCheckWidget = new buildCheckWidget(); -// m_buildCheckWidget->show(); + //编包前检查 + 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(); }); @@ -256,31 +257,31 @@ void InfoCreateWidget::createControlChangelog(const QString &m_date){ //点击生成制作主题包按钮时,m_date将设为空 qDebug()<"); - m_controlStream << endl << QStringLiteral("Build-Depends: debhelper-compat (= 13), dh-python, python3-setuptools, python3-all"); + m_controlStream << endl << QStringLiteral("Build-Depends: debhelper-compat (= 13)"); m_controlStream << endl << QStringLiteral("Standards-Version: 4.6.0"); m_controlStream << endl << QStringLiteral("Rules-Requires-Root: no"); m_controlStream << endl; - m_controlStream << endl << QStringLiteral("Package: ") + m_themeENName; + m_controlStream << endl << QStringLiteral("Package: ") + FileProcess::g_themeENName; m_controlStream << endl << QStringLiteral("Architecture: all"); - m_controlStream << endl << QStringLiteral("Depends: ${python3:Depends}, ${misc:Depends}"); - m_controlStream << endl << QStringLiteral("Description: Theme Package ") + m_themeENName; + m_controlStream << endl << QStringLiteral("Depends: ${misc:Depends},${shlibs:Depends}"); + m_controlStream << endl << QStringLiteral("Description: Theme Package ") + FileProcess::g_themeENName; } - QFile m_changelog(QDir::homePath() + "/.cache/theme-build/" + m_date + "/debian/changelog"); + QFile m_changelog(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/debian/changelog"); if (m_changelog.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){ QTextStream m_changelogStream(&m_changelog); - m_changelogStream << m_themeENName + QStringLiteral(" (1.0-1) UNRELEASED; urgency=medium"); + m_changelogStream << FileProcess::g_themeENName + QStringLiteral(" (1.0-1) UNRELEASED; urgency=medium"); m_changelogStream << endl; m_changelogStream << endl << QStringLiteral(" * Initial release"); m_changelogStream << endl; diff --git a/src/module/infocreatewidget.h b/src/module/infocreatewidget.h index 665e971..c706639 100644 --- a/src/module/infocreatewidget.h +++ b/src/module/infocreatewidget.h @@ -35,7 +35,6 @@ public: void InfoProcess(const QString &m_date); void InfoCreateBtn(); - QString m_themeENName; QString m_builderMail; QString m_builderName;