fix new UI

This commit is contained in:
like 2024-04-16 17:31:00 +08:00
parent 03d696495a
commit 447dc9eff4
18 changed files with 461 additions and 102 deletions

View File

@ -30,6 +30,7 @@ SOURCES += \
src/fileProcess/historyinfoload.cpp \
src/module/aboutdialog.cpp \
src/module/basewidget.cpp \
src/module/batchimportdialog.cpp \
src/module/cacheconfirmedwidget.cpp \
src/module/cursorthemefeature.cpp \
src/module/cursorthemewidget.cpp \
@ -63,6 +64,7 @@ HEADERS += \
src/fileProcess/historyinfoload.h \
src/module/aboutdialog.h \
src/module/basewidget.h \
src/module/batchimportdialog.h \
src/module/cacheconfirmedwidget.h \
src/module/cursorthemefeature.h \
src/module/cursorthemewidget.h \

View File

@ -80,6 +80,12 @@ MainInterface::MainInterface(QWidget *parent) : QWidget(parent)
emit grubPathChanged(path);
});
connect(m_globalthemewidget,&GlobalThemeWidget::build,m_buildbtn,&QPushButton::click);
connect(m_iconthemewidget,&IconThemeWidget::build,m_buildbtn,&QPushButton::click);
connect(m_cursorthemewidget,&CursorThemeWidget::build,m_buildbtn,&QPushButton::click);
connect(m_plymouththemewidget,&PlymouthThemeWidget::build,m_buildbtn,&QPushButton::click);
connect(m_grubthemewidget,&GrubThemeWidget::build,m_buildbtn,&QPushButton::click);
}
/**
@ -218,6 +224,7 @@ void MainInterface::initLeftBar()
leftLayout->addWidget(m_navigation);
leftLayout->addStretch();
leftLayout->addWidget(m_buildbtn);
m_buildbtn->setVisible(false);
}
void MainInterface::setGlobalTheme()

View File

@ -250,6 +250,11 @@ void MainWindow::initUI()
m_maininterface->getThemeInfo(InfoData);
m_ishistory = true;
if(InfoData.themetype == "globalTheme"){
m_maininterface->hideNavigation(true);
}else{
m_maininterface->hideNavigation(false);
}
});
connect(buttonGroup, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), [=](QAbstractButton* button) {

View File

@ -1,6 +1,48 @@
#include "batchimportdialog.h"
BatchImportDialog::BatchImportDialog(QWidget *parent) : QWidget(parent)
BatchImportDialog::BatchImportDialog(QWidget *parent) :
kdk::KDialog(parent)
{
this->setWindowModality(Qt::ApplicationModal);
this->setFixedSize(QSize(424,170));
this->setFocus();
QWidget*mainwindow = mainWidget();
QVBoxLayout *vlayout = new QVBoxLayout(mainwindow);
vlayout->setContentsMargins(23,0,23,23);
QHBoxLayout *vhlayout = new QHBoxLayout();
QHBoxLayout *hlayout = new QHBoxLayout();
QIcon icon = QIcon::fromTheme("emblem-danger");
QPixmap pixmap = icon.pixmap(16, 16);
QLabel *tip = new QLabel();
tip->setPixmap(pixmap);
QLabel *tip1 = new QLabel();
tip1->setText(tr("批量导入前,请确保所有图标已按照规范要求命名。"));
QPushButton *specificationBtn = new QPushButton(this);
specificationBtn->setFixedSize(120,36);
specificationBtn->setText(tr("查看图标规范"));
connect(specificationBtn,&QPushButton::clicked,this,[=](){
QUrl Url("https://gitee.com/openkylin/kylin-theme-builder/blob/openkylin/nile/README.md");
QDesktopServices::openUrl(Url);
});
QPushButton *importBtn = new QPushButton(this);
importBtn->setFixedSize(96,36);
importBtn->setText(tr("批量导入"));
connect(importBtn,&QPushButton::clicked,this,[=](){
emit startimport();
});
vhlayout->addWidget(tip);
vhlayout->addWidget(tip1);
vhlayout->addStretch(1);
vlayout->addLayout(vhlayout);
hlayout->addWidget(specificationBtn);
hlayout->addStretch(1);
hlayout->addWidget(importBtn);
vlayout->addLayout(hlayout);
}

View File

@ -1,17 +1,27 @@
#ifndef BATCHIMPORTDIALOG_H
#define BATCHIMPORTDIALOG_H
#include <kaboutdialog.h>
#include "../fileProcess/fileprocess.h"
#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QUrl>
#include <QDesktopServices>
class BatchImportDialog : public QWidget
class BatchImportDialog : public kdk::KDialog
{
Q_OBJECT
public:
explicit BatchImportDialog(QWidget *parent = nullptr);
signals:
void startimport();
};
#endif // BATCHIMPORTDIALOG_H

View File

@ -217,11 +217,12 @@ void CursorThemeWidget::initRightWidget()
m_rightwidget = new QWidget(this);
m_rightwidget->setMinimumSize(400,620);
m_rightwidget->setMaximumWidth(400);
initBuildWidget();
initFormatWidget();
QScrollArea *m_scrollArea = new QScrollArea(m_rightwidget);
m_scrollArea->setFrameStyle(QFrame::HLine);
m_scrollArea->setMinimumSize(m_rightwidget->size());
m_scrollArea->setMaximumWidth(this->width());
m_scrollArea->setFixedWidth(m_rightwidget->width()-5);
// m_scrollArea->setMaximumWidth(this->width());
m_scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_scrollArea->setWidgetResizable(true);
QWidget *viewportWidget = new QWidget(m_scrollArea);
@ -435,10 +436,51 @@ void CursorThemeWidget::initRightWidget()
}
QVBoxLayout *mainWidgetLayout = new QVBoxLayout();
QPushButton *line = new QPushButton();
line->setDisabled(true);
line->setFixedHeight(1);
line->setFixedWidth(m_rightwidget->width());
QPushButton *line1 = new QPushButton();
line1->setDisabled(true);
line1->setFixedHeight(1);
line1->setFixedWidth(m_rightwidget->width());
mainWidgetLayout->setContentsMargins(0,0,0,0);
mainWidgetLayout->addWidget(m_formatwidget);
mainWidgetLayout->addWidget(line);
mainWidgetLayout->addWidget(m_scrollArea);
mainWidgetLayout->addWidget(line1);
mainWidgetLayout->addWidget(m_buildwidget);
m_rightwidget->setLayout(mainWidgetLayout);
}
void CursorThemeWidget::initBuildWidget()
{
m_buildwidget = new QWidget();
m_buildwidget->setFixedHeight(70);
QPushButton *buildButton = new QPushButton(m_buildwidget);
buildButton->setFixedSize(346,36);
buildButton->setText(tr("制作光标主题"));
QHBoxLayout *buildlayout = new QHBoxLayout(m_buildwidget);
buildlayout->addWidget(buildButton);
connect(buildButton,&QPushButton::clicked,this,[=](){
emit build();
});
}
void CursorThemeWidget::initFormatWidget()
{
m_formatwidget = new QWidget();
m_formatwidget->setFixedHeight(55);
QHBoxLayout*layout = new QHBoxLayout(m_formatwidget);
QLabel *tipslabel = new QLabel(m_formatwidget);
tipslabel->setText(tr("*上传的图标尺寸为96 X 96、格式为 SVG"));
layout->addWidget(tipslabel);
}
/**
* @brief
*

View File

@ -41,12 +41,14 @@ signals:
void newCursorMap(QMap<QString, QString> *cursormap);
void newTimeCursorMap(QMap<QString, QString> *timecursormap);
void cursorthemeChange(QMap<QString, bool> *cursorthemeChangeMap);
void build();
private:
void initPreviewWidget();
void initMaps();
void initTimeMaps();
void initRightWidget();
void initBuildWidget();
void initFormatWidget();
void setHistoryCursor(QString type);
void updateCustomPathMap(QMap<QString, QString>*historyMap,QString type);
void setHistoryTimeCursor();
@ -76,7 +78,8 @@ private:
CursorImageWidget *m_preview;
CursorImageWidget *m_preview2;
QWidget *m_editwidget;
QWidget *m_buildwidget;
QWidget *m_formatwidget;
HistoryInfo m_info;
};

View File

@ -165,7 +165,7 @@ void GlobalThemeWidget::initRightWidget()
m_scrollArea = new QScrollArea(m_rightwidget);
m_scrollArea->setContentsMargins(0,0,0,0);
m_scrollArea->setFrameStyle(QFrame::HLine);
m_scrollArea->setMinimumSize(m_rightwidget->size());
m_scrollArea->setMinimumWidth(m_rightwidget->width());
m_scrollArea->setWidgetResizable(true);
m_viewportwidget = new QWidget(m_scrollArea);
@ -180,6 +180,7 @@ void GlobalThemeWidget::initRightWidget()
initAccentColorWidget();
initTransparencyWidget();
initWindowFilletWidget();
initbuildWidget();
QPushButton *line = new QPushButton();
line->setDisabled(true);
line->setFixedHeight(1);
@ -199,6 +200,11 @@ void GlobalThemeWidget::initRightWidget()
line5->setDisabled(true);
line5->setFixedHeight(1);
QPushButton *line6 = new QPushButton();
line6->setDisabled(true);
line6->setFixedHeight(1);
line6->setFixedWidth(m_rightwidget->width());
mainLayout->addWidget(m_coverwidget);
mainLayout->addWidget(line);
mainLayout->addStretch(1);
@ -225,6 +231,9 @@ void GlobalThemeWidget::initRightWidget()
QVBoxLayout *mainWidgetLayout = new QVBoxLayout(m_rightwidget);
mainWidgetLayout->addWidget(m_scrollArea);
mainWidgetLayout->setSpacing(0);
mainWidgetLayout->addWidget(line6);
mainWidgetLayout->addWidget(m_buildwidget);
mainWidgetLayout->setContentsMargins(0,0,0,0);
m_rightwidget->setLayout(mainWidgetLayout);
@ -710,6 +719,20 @@ void GlobalThemeWidget::initWindowFilletWidget()
m_windowfilletwidget->setLayout(layout);
}
void GlobalThemeWidget::initbuildWidget()
{
m_buildwidget = new QWidget();
m_buildwidget->setFixedHeight(70);
QPushButton *buildButton = new QPushButton();
buildButton->setFixedSize(346,36);
buildButton->setText(tr("制作全局主题"));
QHBoxLayout *buildlayout = new QHBoxLayout(m_buildwidget);
buildlayout->addWidget(buildButton);
connect(buildButton,&QPushButton::clicked,this,[=](){
emit build();
});
}
/**
* @brief
*
@ -722,9 +745,9 @@ void GlobalThemeWidget::addspaceritem()
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->addItem(spacer);
m_previewlayout->addWidget(m_preview);
m_previewlayout->addItem(spacer2);
// m_previewlayout->addItem(spacer2);
}
void GlobalThemeWidget::setStyle(QString style)

View File

@ -42,6 +42,7 @@ signals:
void newTransparency(const int transparency);
void newWindowRadius(const int radius);
void globalthemeChange(QMap<QString, bool> *globalthemeChangeMap);
void build();
private:
void initPreviewWidget();
void initRightWidget();
@ -53,6 +54,7 @@ private:
void initAccentColorWidget();
void initTransparencyWidget();
void initWindowFilletWidget();
void initbuildWidget();
void addspaceritem();
void setStyle(QString style);
@ -70,6 +72,7 @@ private:
QWidget *m_accentcolorwidget;
QWidget *m_transparencywidget;
QWidget *m_windowfilletwidget;
QWidget *m_buildwidget;
QVBoxLayout *m_previewlayout;
QString m_wallpaperpath = ":/resource/background/background-light.png";
QString m_coverpath = ":/resource/background/custom-preview.png";

View File

@ -66,10 +66,11 @@ GrubImageWidget::GrubImageWidget(QWidget *parent)
m_backgroundItem->setGraphicsEffect(blurEffect);
// 设置图元居中显示
QRectF viewRect = graphicsView->viewport()->rect();
QPointF center(viewRect.center());
QSize viewSize = graphicsView->size();
QPointF center(viewSize.width() / 2, viewSize.height() / 2);
m_backgroundItem->setPos(center.x() - pixmap.width() / 2, center.y() - pixmap.height() / 2);
// 添加新的图元
m_overlayPixmap.load(":/resource/background/grub-listview.png");
m_overlayItem = new QGraphicsPixmapItem(m_overlayPixmap);
@ -82,6 +83,7 @@ GrubImageWidget::GrubImageWidget(QWidget *parent)
qreal scaledHeight = m_overlayPixmap.height() * scaleRatio; // 放大后的高度
m_overlayItem->setPos(center.x() - scaledWidth / 2, center.y() - scaledHeight / 2);
graphicsView->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->show();

View File

@ -69,7 +69,20 @@ void GrubThemeWidget::initRightWidget()
m_rightwidget->setMaximumWidth(400);
m_rightwidget->setBackgroundRole(QPalette::Base);
m_rightwidget->setAutoFillBackground(true);
QVBoxLayout *layout = new QVBoxLayout(m_rightwidget);
layout->setContentsMargins(0,0,0,0);
initEditWidget();
initBuildWidget();
QPushButton *line = new QPushButton();
line->setDisabled(true);
line->setFixedHeight(1);
line->setFixedWidth(m_rightwidget->width());
layout->addWidget(m_grubwidget);
layout->addStretch(1);
layout->addWidget(line);
layout->addWidget(m_buildwidget);
}
/**
@ -154,6 +167,21 @@ void GrubThemeWidget::initEditWidget()
m_grubwidget->setLayout(layout);
}
void GrubThemeWidget::initBuildWidget()
{
m_buildwidget = new QWidget();
m_buildwidget->setFixedHeight(70);
QPushButton *buildButton = new QPushButton(m_buildwidget);
buildButton->setFixedSize(346,36);
buildButton->setText(tr("制作GRUB主题"));
QHBoxLayout *buildlayout = new QHBoxLayout(m_buildwidget);
buildlayout->addWidget(buildButton);
connect(buildButton,&QPushButton::clicked,this,[=](){
emit build();
});
}
void GrubThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
{
QString imagedirpath = InfoData.filepath+"/src/grubTheme/background.png";
@ -189,9 +217,9 @@ void GrubThemeWidget::addspaceritem()
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->addItem(spacer);
m_previewlayout->addWidget(m_preview);
m_previewlayout->addItem(spacer2);
// m_previewlayout->addItem(spacer2);
}

View File

@ -22,6 +22,7 @@ public:
void initRightWidget();
void addspaceritem();
void initEditWidget();
void initBuildWidget();
static bool g_themeChange;
void eidtInitWidget(const HistoryInfo &InfoData);
void refresh();
@ -29,12 +30,14 @@ public:
void useRestoreScale();
signals:
void newGrubFilePath(const QString& path);
void build();
private:
const QString resourceGrubPath = ":/resource/background/grub-background.png";
BasePreviewWidget *m_previewwidget;
GrubImageWidget *m_preview;
QWidget *m_rightwidget;
QWidget *m_grubwidget;
QWidget *m_buildwidget;
QVBoxLayout *m_previewlayout;
GrubEditButton *m_showBtn;
};

View File

@ -310,7 +310,35 @@ void IconThemeWidget::updateCustomPlaceIconPathMap(QMap<QString, QString> *histo
void IconThemeWidget::updateCustomDeviceIconPathMap(QMap<QString, QString> *historyMap)
{
m_devicescustomiconpathmap->clear();
m_devicescustomiconpathmap = historyMap;
for (auto it = m_devicespathWidgetMap->begin(); it != m_devicespathWidgetMap->end(); ++it) {
const QString& widgetName = it.key();
IconEditWidget* widget = it.value();
m_themeChangeMap->insert(widgetName, false);
m_iconPresenceMap->insert(widgetName, false);
widget->setcustomicon(NULL);
if (m_devicescustomiconpathmap->contains(widgetName)) {
m_themeChangeMap->insert(widgetName, false);
m_iconPresenceMap->insert(widgetName, false);
const QString& filePath = m_devicescustomiconpathmap->value(widgetName);
// 判断文件类型为svg才显示
QFileInfo fileInfo(filePath);
if (fileInfo.suffix().toLower() == "svg") {
widget->setcustomicon(filePath);
m_preview->updateIcon(widgetName, filePath);
m_iconPresenceMap->insert(widgetName, true);
}
else {
// 如果文件类型不是svg直接跳过并不显示
continue;
}
}
}
}
/**
@ -584,14 +612,20 @@ void IconThemeWidget::initBatchEditWidget()
m_batchwidget = new QWidget(m_rightwidget);
DropBatchButton*bacthButton = new DropBatchButton(m_batchwidget);
bacthButton->setText(tr("批量添加"));
QPushButton*buildButton = new QPushButton(m_batchwidget);
buildButton->setText(tr("制作光标主题"));
m_batchimportdlg = new BatchImportDialog();
QHBoxLayout *layout = new QHBoxLayout(m_batchwidget);
layout->addWidget(bacthButton);
layout->addWidget(buildButton);
m_batchwidget->setFixedHeight(60);
connect(bacthButton,&DropBatchButton::clicked,this,[=](){
connect(m_batchimportdlg,&BatchImportDialog::startimport,this,[=](){
m_batchimportdlg->close();
// 打开文件对话框选中文件夹filecheck之后把对应文件update到相应位置上
QString folderPath = QFileDialog::getExistingDirectory(this, tr("Select Batch"), QDir::homePath());
QStringList fileList;
@ -629,8 +663,11 @@ void IconThemeWidget::initBatchEditWidget()
m_systempreview->updateIcon(widgetName, filePath);
emit newSystemIconsMap(m_systemcustomiconpathmap);
}else if(m_stackedwidget->currentIndex() == 2){
m_placescustomiconpathmap->insert(widgetName, filePath);
m_devicescustomiconpathmap->insert(widgetName, filePath);
if(m_placescustomiconpathmap->contains(widgetName)){
m_placescustomiconpathmap->insert(widgetName, filePath);
}else if(m_devicescustomiconpathmap->contains(widgetName)){
m_devicescustomiconpathmap->insert(widgetName, filePath);
}
widget->setcustomicon(filePath);
m_placepreview->updateIcon(widgetName, filePath);
emit newPlaceIconsMap(m_placescustomiconpathmap);
@ -661,76 +698,82 @@ void IconThemeWidget::initBatchEditWidget()
}
}
});
connect(bacthButton,&DropBatchButton::droprealbatchicon,this,[=](const QString& folderPath){
// 打开文件对话框选中文件夹filecheck之后把对应文件update到相应位置上
// QString folderPath = QFileDialog::getExistingDirectory(this, tr("Select Batch"), QDir::homePath());
QStringList fileList;
QStringList fileList1;
// connect(bacthButton,&DropBatchButton::droprealbatchicon,this,[=](const QString& folderPath){
// // 打开文件对话框选中文件夹filecheck之后把对应文件update到相应位置上
//// QString folderPath = QFileDialog::getExistingDirectory(this, tr("Select Batch"), QDir::homePath());
// QStringList fileList;
// QStringList fileList1;
QList<IconEditWidget*> childWidgets;
if(m_stackedwidget->currentIndex() == 0){
fileList = FileCheck::isLegalBatchIcon(folderPath, m_iconpathmap);
childWidgets = m_scrollArea->viewport()->findChildren<IconEditWidget*>();
} else if (m_stackedwidget->currentIndex() == 1){
fileList = FileCheck::isLegalBatchIcon(folderPath, m_systemiconpathmap);
childWidgets = m_systemscrollArea->viewport()->findChildren<IconEditWidget*>();
} else if(m_stackedwidget->currentIndex() == 2){
fileList = FileCheck::isLegalBatchIcon(folderPath, m_placesiconpathmap);
fileList1 = FileCheck::isLegalBatchIcon(folderPath, m_devicesiconpathmap);
childWidgets = m_placescrollArea->viewport()->findChildren<IconEditWidget*>();
}
// QList<IconEditWidget*> childWidgets;
// if(m_stackedwidget->currentIndex() == 0){
// fileList = FileCheck::isLegalBatchIcon(folderPath, m_iconpathmap);
// childWidgets = m_scrollArea->viewport()->findChildren<IconEditWidget*>();
// } else if (m_stackedwidget->currentIndex() == 1){
// fileList = FileCheck::isLegalBatchIcon(folderPath, m_systemiconpathmap);
// childWidgets = m_systemscrollArea->viewport()->findChildren<IconEditWidget*>();
// } else if(m_stackedwidget->currentIndex() == 2){
// fileList = FileCheck::isLegalBatchIcon(folderPath, m_placesiconpathmap);
// fileList1 = FileCheck::isLegalBatchIcon(folderPath, m_devicesiconpathmap);
// childWidgets = m_placescrollArea->viewport()->findChildren<IconEditWidget*>();
// }
for (const QString &filePath : fileList) {
QString fileName = QFileInfo(filePath).baseName();
// 检查文件路径是否包含任何部件的名称
for (IconEditWidget *widget : childWidgets) {
QString widgetName = widget->property("widgetname").toString();
if (fileName == widgetName) {
qDebug() << "File Path: " << filePath << " contains Widget Name: " << widgetName;
if(FileCheck::isLegalIconFile(filePath)){
if(m_stackedwidget->currentIndex() == 0){
m_customiconpathmap->insert(widgetName, filePath);
widget->setcustomicon(filePath);
m_preview->updateIcon(widgetName, filePath);
m_themeChangeMap->insert(widgetName, true);
emit iconthemeChange(m_themeChangeMap);
emit newAppIconsMap(m_customiconpathmap);
}else if(m_stackedwidget->currentIndex() == 1){
m_systemcustomiconpathmap->insert(widgetName, filePath);
widget->setcustomicon(filePath);
m_systempreview->updateIcon(widgetName, filePath);
emit newSystemIconsMap(m_systemcustomiconpathmap);
}else if(m_stackedwidget->currentIndex() == 2){
m_placescustomiconpathmap->insert(widgetName, filePath);
m_devicescustomiconpathmap->insert(widgetName, filePath);
widget->setcustomicon(filePath);
m_placepreview->updateIcon(widgetName, filePath);
emit newPlaceIconsMap(m_placescustomiconpathmap);
emit newDeviceIconsMap(m_devicescustomiconpathmap);
}
}
break;
}
}
}
for (const QString &filePath : fileList1) {
QString fileName = QFileInfo(filePath).baseName();
for (IconEditWidget *widget : childWidgets) {
QString widgetName = widget->property("widgetname").toString();
if (fileName == widgetName) {
qDebug() << "File Path: " << filePath << " contains Widget Name: " << widgetName;
if(FileCheck::isLegalIconFile(filePath)){
if(m_stackedwidget->currentIndex() == 2){
m_devicescustomiconpathmap->insert(widgetName, filePath);
widget->setcustomicon(filePath);
m_placepreview->updateIcon(widgetName, filePath);
emit newDeviceIconsMap(m_devicescustomiconpathmap);
}
}
break;
}
}
}
// for (const QString &filePath : fileList) {
// QString fileName = QFileInfo(filePath).baseName();
// // 检查文件路径是否包含任何部件的名称
// for (IconEditWidget *widget : childWidgets) {
// QString widgetName = widget->property("widgetname").toString();
// if (fileName == widgetName) {
// qDebug() << "File Path: " << filePath << " contains Widget Name: " << widgetName;
// if(FileCheck::isLegalIconFile(filePath)){
// if(m_stackedwidget->currentIndex() == 0){
// m_customiconpathmap->insert(widgetName, filePath);
// widget->setcustomicon(filePath);
// m_preview->updateIcon(widgetName, filePath);
// m_themeChangeMap->insert(widgetName, true);
// emit iconthemeChange(m_themeChangeMap);
// emit newAppIconsMap(m_customiconpathmap);
// }else if(m_stackedwidget->currentIndex() == 1){
// m_systemcustomiconpathmap->insert(widgetName, filePath);
// widget->setcustomicon(filePath);
// m_systempreview->updateIcon(widgetName, filePath);
// emit newSystemIconsMap(m_systemcustomiconpathmap);
// }else if(m_stackedwidget->currentIndex() == 2){
// m_placescustomiconpathmap->insert(widgetName, filePath);
// m_devicescustomiconpathmap->insert(widgetName, filePath);
// widget->setcustomicon(filePath);
// m_placepreview->updateIcon(widgetName, filePath);
// emit newPlaceIconsMap(m_placescustomiconpathmap);
// emit newDeviceIconsMap(m_devicescustomiconpathmap);
// }
// }
// break;
// }
// }
// }
// for (const QString &filePath : fileList1) {
// QString fileName = QFileInfo(filePath).baseName();
// for (IconEditWidget *widget : childWidgets) {
// QString widgetName = widget->property("widgetname").toString();
// if (fileName == widgetName) {
// qDebug() << "File Path: " << filePath << " contains Widget Name: " << widgetName;
// if(FileCheck::isLegalIconFile(filePath)){
// if(m_stackedwidget->currentIndex() == 2){
// m_devicescustomiconpathmap->insert(widgetName, filePath);
// widget->setcustomicon(filePath);
// m_placepreview->updateIcon(widgetName, filePath);
// emit newDeviceIconsMap(m_devicescustomiconpathmap);
// }
// }
// break;
// }
// }
// }
// });
connect(bacthButton,&DropBatchButton::clicked,this,[=](){
m_batchimportdlg->show();
});
connect(buildButton,&QPushButton::clicked,this,[=](){
emit build();
});
}
@ -910,9 +953,18 @@ void IconThemeWidget::initRightWidget()
m_previewstack->setCurrentIndex(tabIndex);
});
m_rightwidgetlayout->addWidget(m_changebuttonwidget);
QPushButton *line = new QPushButton();
line->setDisabled(true);
line->setFixedHeight(1);
line->setFixedWidth(m_rightwidget->width());
QLabel *tip = new QLabel();
tip->setText(tr("*上传的图标尺寸为96 X 96、格式为 SVG"));
m_rightwidgetlayout->addWidget(m_changebuttonwidget);
m_rightwidgetlayout->addWidget(tip);
m_rightwidgetlayout->addWidget(m_stackedwidget);
m_rightwidgetlayout->addWidget(line);
m_rightwidgetlayout->addWidget(m_batchwidget);
m_rightwidget->setLayout(m_rightwidgetlayout);
@ -1023,7 +1075,20 @@ void IconThemeWidget::setHistoryPlaceIcon()
void IconThemeWidget::setHistoryDeviceIcon()
{
QString directoryPath = m_info.filepath + "/src/iconTheme/deviceicon/";
QDir directory(directoryPath);
QStringList filters;
filters << "*.png" << "*.svg";
QStringList fileList = directory.entryList(filters, QDir::Files);
m_historydevicesiconmap = new QMap<QString, QString>;
foreach (const QString& fileName, fileList) {
QString filePath = directoryPath + fileName; // 使用文件名构建文件路径
QString name = fileName.left(fileName.lastIndexOf('.'));
m_historydevicesiconmap->insert(name, filePath);
}
}
/**
@ -1040,14 +1105,19 @@ void IconThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
setHistoryAppIcon();
setHistorySystemIcon();
setHistoryPlaceIcon();
setHistoryDeviceIcon();
m_preview->updateIconMap(m_historyiconmap,"appicon");
m_systempreview->updateIconMap(m_historysystemiconmap,"systemicon");
m_placepreview->updateIconMap(m_historyplacesiconmap,"placeicon");
QMap<QString, QString> placesMap = *m_historyplacesiconmap;
QMap<QString, QString> devicesMap = *m_historydevicesiconmap;
QMap<QString, QString> mergedMap = placesMap.unite(devicesMap);
m_placepreview->updateIconMap(&mergedMap,"placeicon");
updateCustomIconPathMap(m_historyiconmap);
updateCustomSyetemIconPathMap(m_historysystemiconmap);
updateCustomPlaceIconPathMap(m_historyplacesiconmap);
updateCustomDeviceIconPathMap(m_historydevicesiconmap);
if(m_info.wallpaperpath != nullptr){
m_preview->updateImage(m_info.wallpaperpath);

View File

@ -5,6 +5,7 @@
#include "../fileProcess/filecheck.h"
#include "historywidget.h"
#include "basewidget.h"
#include "batchimportdialog.h"
#include <QWidget>
#include <QPushButton>
@ -34,8 +35,10 @@ public:
void initSystemEditWidget();
void initPlaceandDeviceEditWidget();
void initDeviceEditWidget();
void initBatchEditWidget();
void initRightWidget();
QMap<QString, QString> *getResourcesAppIconMap(QString Type);
void initMaps();
@ -43,7 +46,6 @@ public:
void initPlacesMaps();
void initDevicesMaps();
void initRightWidget();
QMap<QString, QString>* getAppIconsMap();
QMap<QString, QString>* getSystemIconsMap();
QMap<QString, QString>* getPlaceIconsMap();
@ -78,6 +80,7 @@ signals:
void iconthemeChange(QMap<QString, bool> *iconthemeChangeMap);
void batchIconUpdate(const QString& filePath);
void build();
private:
QStringList getWidgetNamesFromFilesInDirectory(const QString& directoryPath);
@ -126,6 +129,7 @@ private:
QScrollArea *m_systemscrollArea;
QScrollArea *m_placescrollArea;
// QScrollArea *m_systemscrollArea;
BatchImportDialog *m_batchimportdlg;
};
#endif // ICONTHEMEWIDGET_H

View File

@ -628,15 +628,17 @@ IconEditWidget::IconEditWidget(QWidget *parent)
m_addiconbutton = new DropButton();
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("<html>格式svg<br>尺寸96*96</html>");
m_addiconbutton->setVisible(false);
m_addwidget = new addIconWidget();
// QLabel *m_tiplabel = new QLabel();
// m_tiplabel->setWordWrap(true);
// m_tiplabel->setText("<html>格式svg<br>尺寸96*96</html>");
m_iconwidgetlayout->addWidget(m_icondefaultlabel);
m_iconwidgetlayout->addWidget(m_icondecustomlabel);
m_iconwidgetlayout->addWidget(m_addiconbutton);
m_iconwidgetlayout->addWidget(m_tiplabel);
m_iconwidgetlayout->addWidget(m_addwidget);
// m_iconwidgetlayout->addWidget(m_tiplabel);
editwidget->setLayout(m_iconwidgetlayout);
innerLayout->addWidget(m_label);
@ -645,6 +647,8 @@ IconEditWidget::IconEditWidget(QWidget *parent)
frame->setLayout(innerLayout);
widgetLayout->addWidget(frame);
connect(m_icondecustomlabel,&CustomLabel::deleteCustomIcon,this,&IconEditWidget::deleteCustomIcon);
connect(m_addwidget,&addIconWidget::buttonclick,m_addiconbutton,&DropButton::click);
connect(m_addwidget,&addIconWidget::droprealicon,m_addiconbutton,&DropButton::droprealicon);
}
/**
@ -888,3 +892,60 @@ void DropBatchButton::dropEvent(QDropEvent *event)
}
}
}
addIconWidget::addIconWidget(QWidget *parent)
{
this->setFixedSize(188,48);
this->setAcceptDrops(true);
QHBoxLayout *layout = new QHBoxLayout(this);
QPushButton *button = new QPushButton();
button->setFixedSize(36,36);
button->setIcon(QIcon::fromTheme("list-add-symbolic"));
button->setProperty("isRoundButton", true);
QLabel *tip = new QLabel();
tip->setText(tr("添加图标"));
layout->addStretch(1);
layout->addWidget(button);
layout->addWidget(tip);
layout->addStretch(1);
connect(button,&QPushButton::clicked,this,[=](){
emit buttonclick();
});
}
void addIconWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setPen(Qt::DashLine);
painter.drawRect(rect().adjusted(1, 1, -1, -1));
}
void addIconWidget::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void addIconWidget::dropEvent(QDropEvent *event)
{
const QMimeData *mimeData = event->mimeData();
if (mimeData->hasUrls()) {
qDebug()<<"aaaaa";
QList<QUrl> urlList = mimeData->urls();
for (const QUrl &url : urlList) {
qDebug() << "File path:" << url.toLocalFile();
bool islegal = FileCheck::isLegalIconFile(url.toLocalFile());
if(islegal){
//发信号给widget换图标
emit droprealicon(url.toLocalFile());
}
}
}
}

View File

@ -6,6 +6,7 @@
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QButtonGroup>
#include <QPainter>
#include <QScrollArea>
@ -120,6 +121,24 @@ signals:
void droprealbatchicon(QString batchFilePath);
};
class addIconWidget : public QWidget
{
Q_OBJECT
public:
addIconWidget(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
signals:
void buttonclick();
void droprealicon(QString iconFilePath);
private:
};
class IconEditWidget : public QWidget
{
Q_OBJECT
@ -136,6 +155,6 @@ private:
QLabel *m_icondefaultlabel;
CustomLabel *m_icondecustomlabel;
addIconWidget *m_addwidget;
};
#endif // MAININTERFACEFEATURE_H

View File

@ -66,7 +66,21 @@ void PlymouthThemeWidget::initRightWidget()
m_rightwidget->setMaximumWidth(400);
m_rightwidget->setBackgroundRole(QPalette::Base);
m_rightwidget->setAutoFillBackground(true);
QVBoxLayout *layout = new QVBoxLayout(m_rightwidget);
layout->setContentsMargins(0,0,0,0);
initEditWidget();
initBuildWidget();
QPushButton *line = new QPushButton();
line->setDisabled(true);
line->setFixedHeight(1);
line->setFixedWidth(m_rightwidget->width());
layout->addWidget(m_plymouthwidget);
layout->addStretch(1);
layout->addWidget(line);
layout->addWidget(m_buildwidget);
}
/**
@ -81,10 +95,10 @@ void PlymouthThemeWidget::initEditWidget()
QVBoxLayout *widgetLayout = new QVBoxLayout(m_plymouthwidget);
QWidget *checkBoxWidget = new QWidget();
QHBoxLayout *checkBoxLayout = new QHBoxLayout(checkBoxWidget);
QRadioButton *pic = new QRadioButton();
QLabel *pixLabel = new QLabel("图片");
QRadioButton *video = new QRadioButton();
QLabel *videoLabel = new QLabel("视频");
pic = new QRadioButton();
pixLabel = new QLabel("图片");
video = new QRadioButton();
videoLabel = new QLabel("视频");
QButtonGroup *btngroup = new QButtonGroup();
btngroup->addButton(pic);
@ -205,6 +219,20 @@ void PlymouthThemeWidget::initEditWidget()
m_plymouthwidget->setLayout(widgetLayout);
}
void PlymouthThemeWidget::initBuildWidget()
{
m_buildwidget = new QWidget();
m_buildwidget->setFixedHeight(70);
QPushButton *buildButton = new QPushButton(m_buildwidget);
buildButton->setFixedSize(346,36);
buildButton->setText(tr("制作开机动画"));
QHBoxLayout *buildlayout = new QHBoxLayout(m_buildwidget);
buildlayout->addWidget(buildButton);
connect(buildButton,&QPushButton::clicked,this,[=](){
emit build();
});
}
void PlymouthThemeWidget::setThumbnailIcon(QString path)
{
QPixmap pixmap(path);
@ -266,8 +294,8 @@ void PlymouthThemeWidget::addspaceritem()
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->addItem(spacer);
m_previewlayout->addWidget(m_preview);
m_previewlayout->addItem(spacer2);
// m_previewlayout->addItem(spacer2);
}

View File

@ -23,6 +23,7 @@ public:
void initRightWidget();
void addspaceritem();
void initEditWidget();
void initBuildWidget();
void setThumbnailIcon(QString path);
static bool g_themeChange;
void startShowPlymouth();
@ -34,14 +35,20 @@ public:
signals:
void newPlymouthFilePath(const QString& path);
void refreshPlymouthDir();
void build();
private:
BasePreviewWidget *m_previewwidget;
PlymouthImageWidget *m_preview;
QWidget *m_rightwidget;
QWidget *m_plymouthwidget;
QWidget *m_buildwidget;
QVBoxLayout *m_previewlayout;
PlymouthCustomLabel *m_customLabel;
QString m_imagedirpath;
QRadioButton *pic;
QLabel *pixLabel;
QRadioButton *video;
QLabel *videoLabel;
};
#endif // PLYMOUTHMOUTHTHEMEWIDGET_H