!63 add Grub and Plymouth history

Merge pull request !63 from likehomedream/plymouthshow
This commit is contained in:
KevinDuan 2023-11-28 01:32:24 +00:00 committed by Gitee
commit 32cad8d5a3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 54 additions and 8 deletions

View File

@ -479,6 +479,13 @@ bool ConfigFileManager::copyIcontoCacheDir(QMap<QString, QString> *map, QDir cac
*/
void ConfigFileManager::copyPictoCacheDir(const QString &destinationFilePath, QDir cachedir, QString type)
{
//清空文件夹
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();
@ -513,11 +520,18 @@ void ConfigFileManager::copyPictoCacheDir(const QString &destinationFilePath, QD
*/
void ConfigFileManager::copyMp4toCacheDir(const QString &destinationFilePath, QDir cachedir)
{
//清空文件夹
QStringList fileList = cachedir.entryList(QDir::Files);
foreach (const QString &fileName, fileList) {
QString filePath = cachedir.absoluteFilePath(fileName);
QFile::remove(filePath);
}
QStringList list;
//ffmpeg -i "111.mp4" -vframes 104 "/home/.cache/theme-build/m_time/src/plymouthTheme/%d.png"
//FIX ME :限制条件
QString cache = cachedir.absolutePath()+"/%d.png";
list<<"-i"<<destinationFilePath<<"-vframes"<<"70"<<cache;
list<<"-i"<<destinationFilePath<<"-vframes"<<"104"<<cache;
QProcess p;
p.start("ffmpeg",list);

View File

@ -121,6 +121,7 @@ void MainInterface::init()
});
connect(m_plymouthbtn,&TypeButton::clicked,m_themestackedwidget,[=](){
m_themestackedwidget->setCurrentIndex(3);
this->startShowPlymouth();
});
connect(m_grubbtn,&TypeButton::clicked,m_themestackedwidget,[=](){
m_themestackedwidget->setCurrentIndex(4);
@ -267,6 +268,12 @@ void MainInterface::getThemeInfo(const HistoryInfo &InfoData)
}else if(InfoData.themetype == "iconTheme"){
setIconTheme();
m_iconthemewidget->eidtInitWidget(InfoData);
}else if(InfoData.themetype == "plymouthTheme"){
setPlymouthTheme();
m_plymouththemewidget->eidtInitWidget(InfoData);
}else if(InfoData.themetype == "grubTheme"){
setGrubTheme();
m_grubthemewidget->eidtInitWidget(InfoData);
}
}

View File

@ -90,13 +90,13 @@ void GrubThemeWidget::initEditWidget()
QWidget *grubWidget = new QWidget();
QHBoxLayout *widgetLayout = new QHBoxLayout();
QPushButton *showBtn = new QPushButton();
showBtn->setFixedSize(160,100);
m_showBtn = new QPushButton();
m_showBtn->setFixedSize(160,100);
QLabel *tipLabel1 = new QLabel();
tipLabel1->setText("<html>尺寸3840*2160<br>大小:不超过 10 MB<br>格式PNG</html>");
connect(showBtn, &QPushButton::clicked, this, [=]() {
connect(m_showBtn, &QPushButton::clicked, this, [=]() {
// 弹出文件选择对话框,选择图片文件
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select picture file"), "", tr("Picture file (*.png *.jpg)"));
@ -109,8 +109,8 @@ void GrubThemeWidget::initEditWidget()
// 加载图片文件并创建一个QPixmap对象
QPixmap pixmap(newFilePath);
// 设置按钮的图标为加载的图片文件对应的图标,并设置图标大小为按钮的大小
showBtn->setIcon(QIcon(pixmap));
showBtn->setIconSize(showBtn->size());
m_showBtn->setIcon(QIcon(pixmap));
m_showBtn->setIconSize(m_showBtn->size());
// 发出新的Grub文件路径信号
emit newGrubFilePath(newFilePath);
g_themeChange = true;
@ -120,7 +120,7 @@ void GrubThemeWidget::initEditWidget()
}
});
widgetLayout->addWidget(showBtn);
widgetLayout->addWidget(m_showBtn);
widgetLayout->addWidget(tipLabel1);
grubWidget->setLayout(widgetLayout);
@ -129,6 +129,15 @@ void GrubThemeWidget::initEditWidget()
m_grubwidget->setLayout(layout);
}
void GrubThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
{
QString imagedirpath = InfoData.filepath+"/src/grubTheme/background.jpg";
m_preview->updateBackground(imagedirpath);
QPixmap pixmap(imagedirpath);
m_showBtn->setIcon(QIcon(pixmap));
m_showBtn->setIconSize(m_showBtn->size());
}
void GrubThemeWidget::addspaceritem()
{
QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);

View File

@ -2,7 +2,7 @@
#define GRUBTHEMEWIDGET_H
#include "grubthemefeature.h"
#include "historywidget.h"
#include <QObject>
#include <QWidget>
#include <QPushButton>
@ -21,6 +21,7 @@ public:
void addspaceritem();
void initEditWidget();
static bool g_themeChange;
void eidtInitWidget(const HistoryInfo &InfoData);
signals:
void newGrubFilePath(const QString& path);
private:
@ -29,6 +30,7 @@ private:
QWidget *m_rightwidget;
QWidget *m_grubwidget;
QVBoxLayout *m_previewlayout;
QPushButton *m_showBtn;
};
#endif // GRUBTHEMEWIDGET_H

View File

@ -140,6 +140,18 @@ void PlymouthThemeWidget::startShowPlymouth()
m_preview->showPlymouth();
}
void PlymouthThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
{
QString imagedirpath = InfoData.filepath+"/src/plymouthTheme/";
m_preview->updatePlymouth(imagedirpath);
m_preview->showPlymouth();
QPixmap pixmap(InfoData.filepath+"/src/plymouthTheme/40.png");
pixmap = pixmap.scaled(64,64, Qt::KeepAspectRatio);
m_customLabel->setPixmap(pixmap);
}
void PlymouthThemeWidget::addspaceritem()
{
QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);

View File

@ -2,6 +2,7 @@
#define PLYMOUTHMOUTHTHEMEWIDGET_H
#include "plymouththemefeature.h"
#include "iconwidgetfeature.h"
#include "historywidget.h"
#include <QObject>
#include <QWidget>
@ -24,6 +25,7 @@ public:
void setThumbnailIcon(QString path);
static bool g_themeChange;
void startShowPlymouth();
void eidtInitWidget(const HistoryInfo &InfoData);
signals:
void newPlymouthFilePath(const QString& path);
private: