I9PXK【光标主题】点击添加图片成功添加大于和小于96x96的图片,但拖拽无法添加小于96x96的图片 OI9PXLV【图标主题】可以添加非96x96的图片

This commit is contained in:
like 2024-05-21 14:16:59 +08:00
parent f87d2de028
commit 91d961a8b8
8 changed files with 57 additions and 9 deletions

2
debian/control vendored
View File

@ -2,7 +2,7 @@ Source: kylin-theme-builder
Section: x11
Priority: optional
Maintainer: kevin <kevin@unknown>
Build-Depends: debhelper-compat (= 13),
Build-Depends: debhelper-compat (= 12),
qt5-qmake,
qtbase5-dev,
libqt5core5a,

View File

@ -34,15 +34,52 @@ bool FileCheck::isLegalIconFile(const QString &filePath)
}
if (renderer.isValid()){
QSize svgSize = renderer.defaultSize();
if (svgSize.width() >= 96 && svgSize.height() >= 96 ){
if (svgSize.width() == 256 && svgSize.height() == 256 ){
if(svgSize.width() == svgSize.height()){
return true;
}else{
QMessageBox::information(nullptr, tr("error"), tr("the icon is not a square icon"));
if(FileProcess::g_isBatchImport == false){
QMessageBox::information(nullptr, tr("error"), tr("the icon is not a square icon"));
}
return false;
}
}else{
QMessageBox::information(nullptr, tr("error"), tr("The icon size must be greater than 96x96"));
if(FileProcess::g_isBatchImport == false){
QMessageBox::information(nullptr, tr("error"), tr("The icon size must be 256x256"));
}
return false;
}
}
return false;
}
bool FileCheck::isLegalCursorFile(const QString &filePath)
{
QSvgRenderer renderer(filePath);
QFileInfo fileinfo(filePath);
if(fileinfo.suffix() != "svg"){
QMessageBox::information(nullptr, tr("error"), tr("The file is not a svg"));
return false;
}
if (renderer.isValid()){
QSize svgSize = renderer.defaultSize();
if (svgSize.width() == 96 && svgSize.height() == 96 ){
if(svgSize.width() == svgSize.height()){
return true;
}else{
if(FileProcess::g_isBatchImport == false){
QMessageBox::information(nullptr, tr("error"), tr("the icon is not a square icon"));
}
return false;
}
}else{
if(FileProcess::g_isBatchImport == false){
QMessageBox::information(nullptr, tr("error"), tr("The icon size must be 96x96"));
}
return false;
}
}

View File

@ -27,12 +27,14 @@
#include <QImage>
#include <QMessageBox>
#include <QDir>
#include "fileprocess.h"
class FileCheck : public QObject
{
Q_OBJECT
public:
explicit FileCheck(QObject *parent = nullptr);
static bool isLegalIconFile(const QString& filePath);
static bool isLegalCursorFile(const QString& filePath);
static bool isLegalWallPaperFile(const QString& filePath, const QString& type);
static bool isLegalMP4File(const QString& filePath);
static bool isLegalPlymouthPicFile(const QString& filePath);

View File

@ -8,6 +8,8 @@ QString FileProcess::g_builderMailName;
QString FileProcess::g_createThemeType;
QString FileProcess::g_debPath;
bool FileProcess::g_isSetup = false;
bool FileProcess::g_isBatchImport = false;
FileProcess::FileProcess()
{
//创建缓存目录

View File

@ -26,6 +26,7 @@ public:
static QString g_createThemeType;
static QString g_debPath;
static bool g_isSetup;
static bool g_isBatchImport;
private:
QDir m_builder;

View File

@ -581,7 +581,7 @@ void cursorAddIconWidget::dropEvent(QDropEvent *event)
QList<QUrl> urlList = mimeData->urls();
for (const QUrl &url : urlList) {
qDebug() << "File path:" << url.toLocalFile();
bool islegal = FileCheck::isLegalIconFile(url.toLocalFile());
bool islegal = FileCheck::isLegalCursorFile(url.toLocalFile());
if(islegal){
//发信号给widget换图标
emit droprealicon(url.toLocalFile());

View File

@ -503,6 +503,8 @@ void CursorThemeWidget::initBuildWidget()
connect(m_batchimportdlg,&BatchImportDialog::startimport,this,[=](){
m_batchimportdlg->close();
//批量导入不显示错误
FileProcess::g_isBatchImport = true;
// 打开文件对话框选中文件夹filecheck之后把对应文件update到相应位置上
QString folderPath = QFileDialog::getExistingDirectory(this, tr("Select Batch"), QDir::homePath());
QStringList fileList;
@ -524,7 +526,7 @@ void CursorThemeWidget::initBuildWidget()
QString fileName = QFileInfo(filePath).baseName();
if (fileName == widgetName) {
qDebug() << "File Path: " << filePath << " contains Widget Name: " << widgetName;
if(FileCheck::isLegalIconFile(filePath)){
if(FileCheck::isLegalCursorFile(filePath)){
if(m_customiconpathmap->contains(widgetName)){
m_customiconpathmap->insert(widgetName, filePath);
@ -545,7 +547,7 @@ void CursorThemeWidget::initBuildWidget()
QString widgetName = widget->property("widgetname").toString();
if (fileName == widgetName) {
qDebug() << "File Path: " << filePath << " contains Widget Name: " << widgetName;
if(FileCheck::isLegalIconFile(filePath)){
if(FileCheck::isLegalCursorFile(filePath)){
if(m_timecustomiconpathmap->contains(widgetName)){
m_timecustomiconpathmap->insert(widgetName, filePath);
@ -560,6 +562,7 @@ void CursorThemeWidget::initBuildWidget()
}
}
}
FileProcess::g_isBatchImport = false;
});
@ -568,7 +571,7 @@ void CursorThemeWidget::initBuildWidget()
});
connect(m_buildButton,&QPushButton::clicked,this,[=](){
emit build();
});
});
}
void CursorThemeWidget::initFormatWidget()

View File

@ -653,6 +653,8 @@ void IconThemeWidget::initBatchEditWidget()
connect(m_batchimportdlg,&BatchImportDialog::startimport,this,[=](){
m_batchimportdlg->close();
FileProcess::g_isBatchImport = true;
// 打开文件对话框选中文件夹filecheck之后把对应文件update到相应位置上
QString folderPath = QFileDialog::getExistingDirectory(this, tr("Select Batch"), QDir::homePath());
QStringList fileList;
@ -746,6 +748,7 @@ void IconThemeWidget::initBatchEditWidget()
}
}
}
FileProcess::g_isBatchImport = false;
});
// connect(bacthButton,&DropBatchButton::droprealbatchicon,this,[=](const QString& folderPath){
// // 打开文件对话框选中文件夹filecheck之后把对应文件update到相应位置上
@ -1008,7 +1011,7 @@ void IconThemeWidget::initRightWidget()
line->setFixedWidth(m_rightwidget->width());
QLabel *tip = new QLabel();
tip->setText(tr("*The uploaded ICONS are 96 X 96 in SVG format"));
tip->setText(tr("*The uploaded ICONS are 256 X 256 in SVG format"));
m_rightwidgetlayout->addWidget(m_changebuttonwidget);
m_rightwidgetlayout->addWidget(tip);