diff --git a/src/fileProcess/configfilemanager.cpp b/src/fileProcess/configfilemanager.cpp index 648f3e0..4a7b216 100644 --- a/src/fileProcess/configfilemanager.cpp +++ b/src/fileProcess/configfilemanager.cpp @@ -480,11 +480,14 @@ bool ConfigFileManager::copyIcontoCacheDir(QMap *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); - } +// 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(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d223895..9742ded 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -160,6 +160,11 @@ void MainWindow::initUI() m_bridge->createPlymouth(); m_maininterface->refresh("global"); + m_maininterface->refresh("icon"); + m_maininterface->refresh("cursor"); + m_maininterface->refresh("plymouth"); + m_maininterface->refresh("grub"); + } else if (button == m_iconbtn) { m_maininterface->setIconTheme(); m_fileProcess.FileCreate("iconTheme"); diff --git a/src/module/globalthemefeature.cpp b/src/module/globalthemefeature.cpp index 1cbb32a..0992903 100644 --- a/src/module/globalthemefeature.cpp +++ b/src/module/globalthemefeature.cpp @@ -114,6 +114,59 @@ void GlobalImageWidget::updateWidgetBackgroundColor(const QColor& color) } +/** + * @brief 更新壁纸文件路径 + * + * 根据传入的封面文件路径更新壁纸文件路径。 + * + * @param coverFilePath 封面文件路径 + */ +void GlobalImageWidget::updateWallpaper(const QString &WallpaperFilePath) +{ + m_image = QPixmap(WallpaperFilePath); + m_image = m_image.scaled(1920, 1080, Qt::KeepAspectRatio, Qt::SmoothTransformation); + 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); + + QString overlayImagePath; + if(m_islight){ + overlayImagePath = ":/resource/background/panel-light.png"; + }else{ + overlayImagePath = ":/resource/background/panel-dark.png"; + } + QPixmap overlayImage(overlayImagePath); + 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); + // 将原代理窗口删除,并清空场景 + 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); +} + /** * @brief 更新覆盖图像 * @@ -122,6 +175,11 @@ void GlobalImageWidget::updateWidgetBackgroundColor(const QColor& color) * @param overlayImagePath 覆盖图像路径 */ void GlobalImageWidget::updateOverlayImage(const QString& overlayImagePath) { + if(":/resource/background/panel-light.png" == overlayImagePath){ + m_islight = true; + }else{ + m_islight = false; + } // 加载叠加图像 QPixmap overlayImage(overlayImagePath); @@ -254,7 +312,7 @@ GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePa qDebug() << "Failed to load overlay image."; } painter.end(); - + m_islight = true; m_scene->addPixmap(m_mergedImage); m_scene->setSceneRect(m_image.rect()); diff --git a/src/module/globalthemefeature.h b/src/module/globalthemefeature.h index de5a4f3..477428c 100644 --- a/src/module/globalthemefeature.h +++ b/src/module/globalthemefeature.h @@ -63,7 +63,7 @@ public: void updateWidgetRadius(int sliderValue); void updateButtonColor(const QColor& color); void updateWidgetBackgroundColor(const QColor& color); - void update(const QString& coverFilePath); + void updateWallpaper(const QString& WallpaperFilePath); void updateOverlayImage(const QString& overlayImagePath); void updatescale(); void updateControlRadius(int Value); @@ -78,6 +78,7 @@ private: QPixmap m_mergedImage; QPixmap m_image; QGraphicsProxyWidget* m_proxy; + bool m_islight; }; class Globalthemefeature : public QWidget { diff --git a/src/module/globalthemewidget.cpp b/src/module/globalthemewidget.cpp index f0ada1a..9f0164e 100644 --- a/src/module/globalthemewidget.cpp +++ b/src/module/globalthemewidget.cpp @@ -48,6 +48,8 @@ void GlobalThemeWidget::eidtInitWidget(const HistoryInfo &InfoData) this->setWallpaper(m_info.wallpaperpath); this->setTransparency(m_info.transparency); this->setWindowRadius(m_info.windowradius); + +// m_preview->updateWallpaper(m_info.wallpaperpath); // this->update(); } @@ -65,6 +67,7 @@ void GlobalThemeWidget::refresh() this->setTransparency(65); this->setCover(":/resource/background/background-glazing.png"); this->setWallpaper(":/resource/background/background-light.png"); +// m_preview->updateWallpaper(":/resource/background/background-light.png"); m_preview->updatescale1(); } @@ -237,7 +240,7 @@ void GlobalThemeWidget::initWallPaperWidget() if (!newFilePath.isEmpty()) { if(FileCheck::isLegalWallPaperFile(newFilePath,"wallpaper")){ - updateWallpaperFilePath(newFilePath); + m_preview->updateWallpaper(newFilePath); emit wallpaperupdate(newFilePath); emit newWallpaperFilePath(newFilePath); @@ -248,7 +251,8 @@ void GlobalThemeWidget::initWallPaperWidget() } } else { qDebug() << "Selected file path:" << newFilePath; - updateWallpaperFilePath(m_wallpaperpath); + //删除的时候可以用 +// updateWallpaperFilePath(m_wallpaperpath); } }); @@ -476,31 +480,6 @@ void GlobalThemeWidget::initWindowFilletWidget() m_windowfilletwidget->setLayout(layout); } -/** - * @brief 更新壁纸文件路径 - * - * 根据传入的封面文件路径更新壁纸文件路径。 - * - * @param coverFilePath 封面文件路径 - */ -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); - } -} - /** * @brief 添加间距项 * diff --git a/src/module/globalthemewidget.h b/src/module/globalthemewidget.h index 7b68468..ad6dc09 100644 --- a/src/module/globalthemewidget.h +++ b/src/module/globalthemewidget.h @@ -45,7 +45,6 @@ private: void initAccentColorWidget(); void initTransparencyWidget(); void initWindowFilletWidget(); - void updateWallpaperFilePath(const QString& coverFilePath); void addspaceritem(); void setRadiusSetting(int radius);