add plymouth delete function
This commit is contained in:
parent
601d1f214e
commit
d37d78ba80
|
@ -120,8 +120,8 @@ void Bridge::plymouthPathChanged(QString path)
|
|||
m_configfilemanager->copyMp4toCacheDir(m_plymouthpath,QDir::homePath()+"/.cache/theme-build/"
|
||||
+m_time+"/src/plymouthTheme");
|
||||
}else{
|
||||
m_configfilemanager->copyPictoCacheDir(m_plymouthpath,QDir::homePath()+"/.cache/theme-build/"
|
||||
+m_time+"/src/plymouthTheme","plymouth");
|
||||
m_configfilemanager->copyPicstoCacheDir(m_plymouthpath,QDir::homePath()+"/.cache/theme-build/"
|
||||
+m_time+"/src/plymouthTheme");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void Bridge::createConfig()
|
|||
m_configfilemanager->createJson(QDir::homePath() + "/.cache/theme-build/"
|
||||
+ m_time + "/src/globalTheme/");
|
||||
m_configfilemanager->copyPictoCacheDir(m_coverpath,QDir::homePath()+"/.cache/theme-build/"
|
||||
+m_time+"/src/globalTheme","grub");
|
||||
+m_time+"/src/globalTheme","cover");
|
||||
}
|
||||
|
||||
void Bridge::createGrub()
|
||||
|
@ -150,8 +150,8 @@ void Bridge::createGrub()
|
|||
|
||||
void Bridge::createPlymouth()
|
||||
{
|
||||
m_configfilemanager->copyPictoCacheDir(m_plymouthpath,QDir::homePath()+"/.cache/theme-build/"
|
||||
+m_time+"/src/plymouthTheme","plymouth");
|
||||
m_configfilemanager->copyAllPictoCacheDir(m_plymouthdir,QDir::homePath()+"/.cache/theme-build/"
|
||||
+m_time+"/src/plymouthTheme");
|
||||
}
|
||||
|
||||
void Bridge::startCopy()
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
QString m_wallpaperpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
|
||||
QString m_coverpath = ":/resource/background/background-light.png";
|
||||
QString m_plymouthpath = ":/resource/background/openKylin.svg";
|
||||
QString m_plymouthdir = ":/resource/plymouth/";
|
||||
QString m_grubpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
|
||||
// QDir m_builderConfig;
|
||||
// QDir m_buildericons;
|
||||
|
|
|
@ -479,24 +479,12 @@ bool ConfigFileManager::copyIcontoCacheDir(QMap<QString, QString> *map, QDir cac
|
|||
*/
|
||||
void ConfigFileManager::copyPictoCacheDir(const QString &destinationFilePath, QDir cachedir, QString type)
|
||||
{
|
||||
//清空文件夹
|
||||
// if(type == "plymouth"){
|
||||
// QStringList fileList = cachedir.entryList(QDir::Files);
|
||||
// foreach (const QString &fileName, fileList) {
|
||||
// QString filePath = cachedir.absoluteFilePath(fileName);
|
||||
// QFile::remove(filePath)
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
QString sourceFilePath = destinationFilePath;
|
||||
QString sourceFileExt = QFileInfo(sourceFilePath).suffix();
|
||||
|
||||
QString targetFileName = "";
|
||||
if(type == "cover"){
|
||||
targetFileName = "preview." + sourceFileExt;
|
||||
}else if (type == "plymouth"){
|
||||
targetFileName = "1." + sourceFileExt;
|
||||
}else if (type == "grub"){
|
||||
targetFileName = "background." + sourceFileExt;
|
||||
}
|
||||
|
@ -513,6 +501,51 @@ void ConfigFileManager::copyPictoCacheDir(const QString &destinationFilePath, QD
|
|||
qDebug() << "File copied successfully";
|
||||
}
|
||||
|
||||
void ConfigFileManager::copyPicstoCacheDir(const QString &destinationFilePath, QDir cachedir)
|
||||
{
|
||||
//清空文件夹
|
||||
QStringList fileList = cachedir.entryList(QDir::Files);
|
||||
foreach (const QString &fileName, fileList) {
|
||||
QString filePath = cachedir.absoluteFilePath(fileName);
|
||||
QFile::remove(filePath);
|
||||
}
|
||||
|
||||
QFile sourceFile(destinationFilePath);
|
||||
|
||||
if (!sourceFile.exists()) {
|
||||
qDebug() << "Source file does not exist!";
|
||||
return;
|
||||
}
|
||||
|
||||
QDir destinationDirectory(cachedir);
|
||||
if (!destinationDirectory.exists()) {
|
||||
qDebug() << "Destination directory does not exist!";
|
||||
return;
|
||||
}
|
||||
|
||||
// QString baseFileName = QFileInfo(sourceFile).baseName();
|
||||
QString fileExtension = QFileInfo(sourceFile).completeSuffix();
|
||||
QString destinationPath = destinationDirectory.absolutePath(); // Convert QDir to QString
|
||||
|
||||
for (int i = 1; i <= 104; ++i) {
|
||||
QString newFileName = QString("%1/%2.%4").arg(destinationPath).arg(i).arg(fileExtension);
|
||||
QFile destinationFile(newFileName);
|
||||
|
||||
if (destinationFile.exists()) {
|
||||
qDebug() << "File" << newFileName << "already exists. Skipping.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sourceFile.copy(newFileName)) {
|
||||
qDebug() << "Copied" << destinationFilePath << "to" << newFileName;
|
||||
} else {
|
||||
qDebug() << "Failed to copy" << destinationFilePath << "to" << newFileName;
|
||||
}
|
||||
}
|
||||
QString thunbnail = cachedir.absolutePath()+"/40.png";
|
||||
emit updateThumbnail(thunbnail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 将文件复制到缓存目录
|
||||
*
|
||||
|
@ -582,7 +615,57 @@ void ConfigFileManager::copyMp4toCacheDir(const QString &destinationFilePath, QD
|
|||
// }
|
||||
|
||||
|
||||
QString thunbnail = cachedir.absolutePath()+"/40.png";;
|
||||
QString thunbnail = cachedir.absolutePath()+"/40.png";
|
||||
emit updateThumbnail(thunbnail);
|
||||
}
|
||||
|
||||
void ConfigFileManager::copyAllPictoCacheDir(QDir sourcedir, QDir cachedir)
|
||||
{
|
||||
//清空文件夹
|
||||
QStringList fileList1 = cachedir.entryList(QDir::Files);
|
||||
|
||||
foreach (const QString &fileName, fileList1) {
|
||||
QString filePath = cachedir.absoluteFilePath(fileName);
|
||||
QFile::remove(filePath);
|
||||
}
|
||||
QDir sourceDirectory(sourcedir);
|
||||
QDir destinationDirectory(cachedir);
|
||||
|
||||
if (!sourceDirectory.exists()) {
|
||||
qDebug() << "Source directory does not exist!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!destinationDirectory.exists()) {
|
||||
qDebug() << "Destination directory does not exist!";
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList filters;
|
||||
filters << "*.png";
|
||||
|
||||
sourceDirectory.setNameFilters(filters);
|
||||
QFileInfoList fileList = sourceDirectory.entryInfoList();
|
||||
|
||||
foreach (QFileInfo fileInfo, fileList) {
|
||||
QString baseFileName = fileInfo.baseName();
|
||||
QString fileExtension = fileInfo.completeSuffix();
|
||||
QString destinationPath = destinationDirectory.absoluteFilePath(QString("%1.%2").arg(baseFileName).arg(fileExtension));
|
||||
|
||||
QFile destinationFile(destinationPath);
|
||||
|
||||
if (destinationFile.exists()) {
|
||||
qDebug() << "File" << destinationPath << "already exists. Skipping.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (QFile::copy(fileInfo.filePath(), destinationPath)) {
|
||||
qDebug() << "Copied" << fileInfo.filePath() << "to" << destinationPath;
|
||||
} else {
|
||||
qDebug() << "Failed to copy" << fileInfo.filePath() << "to" << destinationPath;
|
||||
}
|
||||
}
|
||||
QString thunbnail = cachedir.absolutePath()+"/40.png";
|
||||
emit updateThumbnail(thunbnail);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ public:
|
|||
bool copyIcontoCacheDir(QMap<QString, QString> *map,QDir cachedir);
|
||||
|
||||
void copyPictoCacheDir(const QString& destinationFilePath,QDir cachedir,QString type);
|
||||
void copyPicstoCacheDir(const QString& destinationFilePath,QDir cachedir);
|
||||
void copyMp4toCacheDir(const QString& destinationFilePath,QDir cachedir);
|
||||
void copyAllPictoCacheDir(const QDir sourcedir,QDir cachedir);
|
||||
signals:
|
||||
void updateInfo();
|
||||
void updateThumbnail(QString thumbnailPath);
|
||||
|
|
|
@ -57,6 +57,9 @@ MainInterface::MainInterface(QWidget *parent) : QWidget(parent)
|
|||
connect(m_plymouththemewidget, &PlymouthThemeWidget::newPlymouthFilePath, this, [&](const QString& path) {
|
||||
emit plymouthPathChanged(path);
|
||||
});
|
||||
connect(m_plymouththemewidget, &PlymouthThemeWidget::refreshPlymouthDir, this, [=](){
|
||||
emit refreshPlymouthDir();
|
||||
});
|
||||
connect(m_grubthemewidget, &GrubThemeWidget::newGrubFilePath, this, [&](const QString& path) {
|
||||
emit grubPathChanged(path);
|
||||
});
|
||||
|
|
|
@ -66,7 +66,7 @@ signals:
|
|||
void plymouthPathChanged(QString path);
|
||||
void grubPathChanged(QString path);
|
||||
void deleteIcon(QString widgetName);
|
||||
|
||||
void refreshPlymouthDir();
|
||||
void startCopy();
|
||||
void gohomesignals();
|
||||
private:
|
||||
|
|
|
@ -35,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(m_maininterface, &MainInterface::timeCursorMapChanged, m_bridge, &Bridge::timeCursorMapChanged);
|
||||
connect(m_maininterface, &MainInterface::plymouthPathChanged, m_bridge, &Bridge::plymouthPathChanged);
|
||||
connect(m_maininterface, &MainInterface::grubPathChanged, m_bridge, &Bridge::grubPathChanged);
|
||||
connect(m_maininterface, &MainInterface::refreshPlymouthDir, m_bridge, &Bridge::createPlymouth);
|
||||
// connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy);
|
||||
connect(m_bridge,&Bridge::updateInfo,m_historywidget,&HistoryWidget::updateInfo);
|
||||
connect(m_bridge,&Bridge::updateThumbnail,m_maininterface,&MainInterface::updateThumbnail);
|
||||
|
|
|
@ -78,10 +78,19 @@ void PlymouthThemeWidget::initEditWidget()
|
|||
QLabel *pixLabel = new QLabel("图片");
|
||||
QCheckBox *video = new QCheckBox();
|
||||
QLabel *videoLabel = new QLabel("视频");
|
||||
checkBoxLayout->addWidget(pic);
|
||||
checkBoxLayout->addWidget(pixLabel);
|
||||
|
||||
QButtonGroup *btngroup = new QButtonGroup();
|
||||
btngroup->addButton(pic);
|
||||
btngroup->addButton(video);
|
||||
btngroup->setExclusive(true);
|
||||
//默认导入视频
|
||||
video->setChecked(true);
|
||||
|
||||
checkBoxLayout->addWidget(video);
|
||||
checkBoxLayout->addWidget(videoLabel);
|
||||
checkBoxLayout->addWidget(pic);
|
||||
checkBoxLayout->addWidget(pixLabel);
|
||||
|
||||
checkBoxLayout->addStretch(1);
|
||||
QWidget *showWidget = new QWidget();
|
||||
QHBoxLayout *showLayout = new QHBoxLayout(showWidget);
|
||||
|
@ -96,26 +105,35 @@ void PlymouthThemeWidget::initEditWidget()
|
|||
addButton->setIcon(QIcon::fromTheme("list-add-symbolic"));
|
||||
addButton->setFixedSize(36,36);
|
||||
connect(addButton, &QPushButton::clicked, this, [=]() {
|
||||
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select MP4 file"), "", tr("MP4 file (*.svg *.png *.gif *.mp4)"));
|
||||
if (!newFilePath.isEmpty()) {
|
||||
QPixmap pixmap(newFilePath);
|
||||
pixmap = pixmap.scaled(64,64, Qt::KeepAspectRatio);
|
||||
m_customLabel->setPixmap(pixmap);
|
||||
emit newPlymouthFilePath(newFilePath);
|
||||
if(pic->isChecked()){
|
||||
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select Png file"), "", tr("Png file (*.png)"));
|
||||
if (!newFilePath.isEmpty()) {
|
||||
QPixmap pixmap(newFilePath);
|
||||
pixmap = pixmap.scaled(64,64, Qt::KeepAspectRatio);
|
||||
m_customLabel->setPixmap(pixmap);
|
||||
emit newPlymouthFilePath(newFilePath);
|
||||
|
||||
g_themeChange = true;
|
||||
g_themeChange = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select MP4 file"), "", tr("MP4 file (*.svg *.png *.gif *.mp4)"));
|
||||
if (!newFilePath.isEmpty()) {
|
||||
QPixmap pixmap(newFilePath);
|
||||
pixmap = pixmap.scaled(64,64, Qt::KeepAspectRatio);
|
||||
m_customLabel->setPixmap(pixmap);
|
||||
emit newPlymouthFilePath(newFilePath);
|
||||
|
||||
g_themeChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
connect(m_customLabel,&PlymouthCustomLabel::deleteCustomIcon,this,[=](){
|
||||
m_preview->updatePlymouth(":/resource/plymouth/");
|
||||
m_preview->showPlymouth();
|
||||
|
||||
QDir cachedir(m_imagedirpath);
|
||||
QStringList fileList = cachedir.entryList(QDir::Files);
|
||||
foreach (const QString &fileName, fileList) {
|
||||
QString filePath = cachedir.absoluteFilePath(fileName);
|
||||
QFile::remove(filePath);
|
||||
}
|
||||
emit refreshPlymouthDir();
|
||||
|
||||
});
|
||||
QLabel *tipLabel = new QLabel();
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <QScrollArea>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include <QButtonGroup>
|
||||
|
||||
class PlymouthThemeWidget : public QWidget
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ public:
|
|||
void refresh();
|
||||
signals:
|
||||
void newPlymouthFilePath(const QString& path);
|
||||
void refreshPlymouthDir();
|
||||
private:
|
||||
QWidget *m_previewwidget;
|
||||
PlymouthImageWidget *m_preview;
|
||||
|
|
|
@ -28,6 +28,7 @@ SavePathDialog::SavePathDialog(QWidget *parent) :
|
|||
void SavePathDialog::updateLabel(QString savepath)
|
||||
{
|
||||
m_pathLabel->setText(tr("Storage Path:")+savepath);
|
||||
m_pathLabel->setToolTip(savepath);
|
||||
}
|
||||
|
||||
void SavePathDialog::onModifyBtnClicked()
|
||||
|
|
Loading…
Reference in New Issue