From b7974a5a9638fe111db8f26b46fdb5ac7f498f50 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Fri, 3 Nov 2023 14:29:32 +0800 Subject: [PATCH 1/3] add Transparency function --- src/fileProcess/bridge.cpp | 5 ++++ src/fileProcess/bridge.h | 1 + src/fileProcess/configfilemanager.cpp | 31 +++++++++++++++++++++ src/fileProcess/configfilemanager.h | 2 +- src/fileProcess/historyinfoload.cpp | 39 ++++++++++++++++++++++++++- src/fileProcess/historyinfoload.h | 2 ++ src/maininterface.cpp | 3 +++ src/maininterface.h | 1 + src/mainwindow.cpp | 3 +++ src/module/globalthemewidget.cpp | 7 +++++ src/module/globalthemewidget.h | 2 ++ 11 files changed, 94 insertions(+), 2 deletions(-) diff --git a/src/fileProcess/bridge.cpp b/src/fileProcess/bridge.cpp index 30433f1..3c54316 100644 --- a/src/fileProcess/bridge.cpp +++ b/src/fileProcess/bridge.cpp @@ -42,6 +42,11 @@ void Bridge::exteriorChanged(QColor accentcolor) } +void Bridge::transparencyChanged(int transparency) +{ + m_configfilemanager->modifyTransparencyConf(transparency); +} + void Bridge::appIconsMapChanged(QMap *appiconsmaps) { QMap::const_iterator it; diff --git a/src/fileProcess/bridge.h b/src/fileProcess/bridge.h index 31163fb..fb6f7eb 100644 --- a/src/fileProcess/bridge.h +++ b/src/fileProcess/bridge.h @@ -20,6 +20,7 @@ public: void radiusChanged(int radius); void accentColorChanged(QColor accentcolor); void exteriorChanged(QColor accentcolor); + void transparencyChanged(int transparency); void appIconsMapChanged(QMap *appiconsmaps); void systemIconsMapChanged(QMap *systemiconsmaps); void cursorMapChanged(QMap *cursormap); diff --git a/src/fileProcess/configfilemanager.cpp b/src/fileProcess/configfilemanager.cpp index 7c91a64..59c52df 100644 --- a/src/fileProcess/configfilemanager.cpp +++ b/src/fileProcess/configfilemanager.cpp @@ -177,6 +177,37 @@ bool ConfigFileManager::modifyWallPaperConf(QString wallpaperpath) } } +bool ConfigFileManager::modifyTransparencyConf(int transparency) +{ + // 读取文件内容 + QFile file(confFilePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "无法打开文件:" << confFilePath; + return false; + } + + QTextStream in(&file); + QString content = in.readAll(); + file.close(); + + // 修改内容 + QString oldValue = "transparencyBlur="; + QString newValue = QString("transparencyBlur=%1").arg(transparency); + content.replace(QRegExp(oldValue + "\\d+"), newValue); + + // 写入文件 + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream out(&file); + out << content; + file.close(); + emit updateInfo(); + return true; + } else { + qDebug() << "无法写入文件:" << confFilePath; + return false; + } +} + bool ConfigFileManager::copyFileContent(const QString &sourceFilePath, const QString &destinationFilePath) { QFile sourceFile(sourceFilePath); diff --git a/src/fileProcess/configfilemanager.h b/src/fileProcess/configfilemanager.h index b6a34c5..5f9ad8a 100644 --- a/src/fileProcess/configfilemanager.h +++ b/src/fileProcess/configfilemanager.h @@ -23,7 +23,7 @@ public: bool modifyAccentColorConf(QColor accentcolor); bool modifyWallPaperConf(QString wallpaperpath); - + bool modifyTransparencyConf(int transparency); bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath); bool copyIcontoCacheDir(QMap *map,QDir cachedir); diff --git a/src/fileProcess/historyinfoload.cpp b/src/fileProcess/historyinfoload.cpp index 211a203..3ee8149 100644 --- a/src/fileProcess/historyinfoload.cpp +++ b/src/fileProcess/historyinfoload.cpp @@ -13,6 +13,7 @@ HistoryInfoLoad::HistoryInfoLoad(const QString &date, QObject *parent) getWallpaper(); getAccentColor(); getRadius(); + getTransparency(); } QString HistoryInfoLoad::getCover() @@ -154,7 +155,6 @@ void HistoryInfoLoad::getAccentColor() QString content = in.readAll(); file.close(); - // 查找 wallPaperPath= 所在行的位置 int startIndex = content.indexOf("accent="); if (startIndex != -1) { int lineStartIndex = content.lastIndexOf('\n', startIndex) + 1; @@ -171,6 +171,42 @@ void HistoryInfoLoad::getAccentColor() } } +void HistoryInfoLoad::getTransparency() +{ + QString filePath = m_historyInfo.filepath + "/src/config/theme.conf"; + // 读取文件内容 + QFile file(filePath); + if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { + qDebug() << "无法打开文件:" << filePath; + return; + } + + QTextStream in(&file); + QString content = in.readAll(); + file.close(); + + int startIndex = content.indexOf("transparencyBlur="); + if (startIndex != -1) { + int lineStartIndex = content.lastIndexOf('\n', startIndex) + 1; + int lineEndIndex = content.indexOf('\n', startIndex); + + if (lineEndIndex == -1) { + lineEndIndex = content.size(); + } + + QString lineContent = content.mid(lineStartIndex, lineEndIndex - lineStartIndex).trimmed(); + lineContent.remove("transparencyBlur="); + + bool conversionSuccess = false; + int transparencyBlurValue = lineContent.toInt(&conversionSuccess); + if (conversionSuccess) { + m_historyInfo.transparency = transparencyBlurValue; + } else { + qDebug() << "无法将字符串转换为整数:" << lineContent; + } + } +} + HistoryInfo HistoryInfoLoad::getInfoData() { qDebug()< *appiconsmaps) { emit appIconsMapChanged(appiconsmaps); }); diff --git a/src/maininterface.h b/src/maininterface.h index efd4dd0..971747f 100644 --- a/src/maininterface.h +++ b/src/maininterface.h @@ -47,6 +47,7 @@ signals: void wallpaperPathChanged(QString path); void coverPathChanged(QString path); void radiusChanged(int radius); + void transparencyChanged(int transparency); void accentColorChanged(QColor accentcolor); void exteriorChanged(QColor exteriorcolor); void appIconsMapChanged(QMap *appiconsmap); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b49c388..453786d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -24,6 +24,7 @@ MainWindow::MainWindow(QWidget *parent) connect(m_maininterface, &MainInterface::radiusChanged, m_bridge, &Bridge::radiusChanged); connect(m_maininterface, &MainInterface::accentColorChanged, m_bridge, &Bridge::accentColorChanged); connect(m_maininterface, &MainInterface::exteriorChanged, m_bridge, &Bridge::exteriorChanged); + connect(m_maininterface, &MainInterface::transparencyChanged, m_bridge, &Bridge::transparencyChanged); // connect(m_maininterface, &MainInterface::appIconsMapChanged, this,[=]{ // m_bridge->updateIconCache(m_maininterface->getAppIconsMap(),"appicon"); // }); @@ -200,10 +201,12 @@ void MainWindow::onGoHomeClicked() m_cacheConfirmedWidget->show(); connect(m_cacheConfirmedWidget, &cacheConfirmedWidget::cacheClean, this, [=](){ m_stackedWidget->setCurrentIndex(0); + //添加一个reflesh功能,清除所有界面上的改动 }); connect(m_cacheConfirmedWidget, &cacheConfirmedWidget::cacheSave, this, [=](){ m_historywidget->updateHistoryDir(); m_stackedWidget->setCurrentIndex(0); + //添加一个reflesh功能,清除所有界面上的改动 }); } else { m_stackedWidget->setCurrentIndex(0); diff --git a/src/module/globalthemewidget.cpp b/src/module/globalthemewidget.cpp index d643376..6bd1425 100644 --- a/src/module/globalthemewidget.cpp +++ b/src/module/globalthemewidget.cpp @@ -24,6 +24,7 @@ void GlobalThemeWidget::eidtInitWidget(const HistoryInfo &InfoData) this->setAccentColor(m_info.accentcolor); this->setCover(m_info.coverpath); this->setWallpaper(m_info.wallpaperpath); + this->setTransparency(m_info.transparency); // this->update(); } @@ -321,6 +322,7 @@ void GlobalThemeWidget::initTransparencyWidget() showButton->setText(QString::number(m_transparencyslider->value())+"%"); QObject::connect(m_transparencyslider, &QSlider::valueChanged, [=](int value) { showButton->setText(QString::number(value)+"%"); + newTransparency(value); }); layout->addWidget(title); layout->addWidget(m_transparencyslider); @@ -392,6 +394,11 @@ void GlobalThemeWidget::setAccentColor(QString accentcolor) } } +void GlobalThemeWidget::setTransparency(int transparency) +{ + m_transparencyslider->setValue(transparency); +} + void GlobalThemeWidget::setCover(QString coverpath) { m_coverbtn->setIcon(QIcon(coverpath)); diff --git a/src/module/globalthemewidget.h b/src/module/globalthemewidget.h index 846e5aa..bbfc8d6 100644 --- a/src/module/globalthemewidget.h +++ b/src/module/globalthemewidget.h @@ -30,6 +30,7 @@ signals: void newRadius(const int radius); void newAccentColor(const QColor selectedColor); void newExterior(const QColor selectedColor); + void newTransparency(const int transparency); private: void initPreviewWidget(); void initRightWidget(); @@ -46,6 +47,7 @@ private: void setRadiusSetting(int radius); void setAccentColor(QString accentcolor); + void setTransparency(int transparency); void setCover(QString coverpath); void setWallpaper(QString wallpaperpath); QWidget *m_globalthemewidget; From b5e8627281ff45a2b7b13245ca25485505d67a0c Mon Sep 17 00:00:00 2001 From: likehomedream Date: Fri, 3 Nov 2023 15:56:13 +0800 Subject: [PATCH 2/3] fix previewwidget bgcolor --- src/module/cursorthemewidget.cpp | 5 +++++ src/module/globalthemewidget.cpp | 6 +++++- src/module/grubthemewidget.cpp | 6 ++++++ src/module/iconthemewidget.cpp | 6 ++++++ src/module/plymouththemewidget.cpp | 6 ++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/module/cursorthemewidget.cpp b/src/module/cursorthemewidget.cpp index e768050..dea7b6d 100644 --- a/src/module/cursorthemewidget.cpp +++ b/src/module/cursorthemewidget.cpp @@ -17,6 +17,11 @@ void CursorThemeWidget::initPreviewWidget() { m_previewwidget = new QWidget(this); m_previewwidget->setMinimumSize(495,620); + QPalette palette; + QColor bgColor("#F5F5F5"); + palette.setColor(QPalette::Window, bgColor); + m_previewwidget->setPalette(palette); + m_previewwidget->setAutoFillBackground(true); m_preview = new CursorImageWidget(m_previewwidget,m_iconpathmap); m_preview2 = new CursorImageWidget(m_previewwidget,m_timeiconpathmap); m_previewlayout = new QVBoxLayout(m_previewwidget); diff --git a/src/module/globalthemewidget.cpp b/src/module/globalthemewidget.cpp index 6bd1425..6d2c817 100644 --- a/src/module/globalthemewidget.cpp +++ b/src/module/globalthemewidget.cpp @@ -33,7 +33,11 @@ void GlobalThemeWidget::initPreviewWidget() m_previewwidget = new QWidget(this); m_previewwidget->setMinimumSize(495,620); - m_previewwidget->setBackgroundRole(QPalette::Window); + QPalette palette; + QColor bgColor("#F5F5F5"); + palette.setColor(QPalette::Window, bgColor); + m_previewwidget->setPalette(palette); + m_previewwidget->setAutoFillBackground(true); m_preview = new GlobalImageWidget(m_previewwidget,m_wallpaperpath); diff --git a/src/module/grubthemewidget.cpp b/src/module/grubthemewidget.cpp index 2af2582..6846aa9 100644 --- a/src/module/grubthemewidget.cpp +++ b/src/module/grubthemewidget.cpp @@ -17,6 +17,12 @@ void GrubThemeWidget::initPreviewWidget() m_previewwidget->setBackgroundRole(QPalette::Window); + QPalette palette; + QColor bgColor("#F5F5F5"); + palette.setColor(QPalette::Window, bgColor); + m_previewwidget->setPalette(palette); + m_previewwidget->setAutoFillBackground(true); + m_preview = new GrubImageWidget(m_previewwidget); m_previewlayout = new QVBoxLayout(m_previewwidget); diff --git a/src/module/iconthemewidget.cpp b/src/module/iconthemewidget.cpp index 78c778b..4d4c573 100644 --- a/src/module/iconthemewidget.cpp +++ b/src/module/iconthemewidget.cpp @@ -19,6 +19,12 @@ void IconThemeWidget::initPreviewWidget() m_previewwidget = new QWidget(this); m_previewwidget->setMinimumSize(550,620); + QPalette palette; + QColor bgColor("#F5F5F5"); + palette.setColor(QPalette::Window, bgColor); + m_previewwidget->setPalette(palette); + m_previewwidget->setAutoFillBackground(true); + m_previewstack = new QStackedWidget(m_previewwidget); m_preview = new ImageWidget(m_previewwidget,m_iconpathmap); diff --git a/src/module/plymouththemewidget.cpp b/src/module/plymouththemewidget.cpp index 36ca55b..959dfb4 100644 --- a/src/module/plymouththemewidget.cpp +++ b/src/module/plymouththemewidget.cpp @@ -18,6 +18,12 @@ void PlymouthThemeWidget::initPreviewWidget() m_previewwidget->setBackgroundRole(QPalette::Window); + QPalette palette; + QColor bgColor("#F5F5F5"); + palette.setColor(QPalette::Window, bgColor); + m_previewwidget->setPalette(palette); + m_previewwidget->setAutoFillBackground(true); + m_preview = new PlymouthImageWidget(m_previewwidget); m_previewlayout = new QVBoxLayout(m_previewwidget); From 63e73b1e5d30452e877b8832d5975562bd7785a4 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Tue, 7 Nov 2023 16:39:38 +0800 Subject: [PATCH 3/3] add windowRadiu and Transparency UI --- kylin-theme-builder.pro | 2 +- resource/config/theme.conf | 1 + src/fileProcess/bridge.cpp | 5 +++ src/fileProcess/bridge.h | 2 + src/fileProcess/configfilemanager.cpp | 28 ++++++++++++ src/fileProcess/configfilemanager.h | 2 +- src/fileProcess/historyinfoload.cpp | 40 ++++++++++++++++- src/fileProcess/historyinfoload.h | 2 + src/maininterface.cpp | 3 ++ src/maininterface.h | 1 + src/mainwindow.cpp | 3 +- src/module/globalthemefeature.cpp | 64 +++++++++++++++++++++++++-- src/module/globalthemefeature.h | 19 +++++++- src/module/globalthemewidget.cpp | 34 +++++++++++--- src/module/globalthemewidget.h | 2 + 15 files changed, 195 insertions(+), 13 deletions(-) diff --git a/kylin-theme-builder.pro b/kylin-theme-builder.pro index 70cf06f..9b16e91 100644 --- a/kylin-theme-builder.pro +++ b/kylin-theme-builder.pro @@ -1,4 +1,4 @@ -QT += core gui svg +QT += core gui svg KWindowSystem greaterThan(QT_MAJOR_VERSION, 4): QT += widgets diff --git a/resource/config/theme.conf b/resource/config/theme.conf index 55a6aef..3be6999 100644 --- a/resource/config/theme.conf +++ b/resource/config/theme.conf @@ -35,3 +35,4 @@ transparencyBlur=65 transparencyNoBlur=90 supportAnimation=true animationDuration=150 +windowRadius=6 diff --git a/src/fileProcess/bridge.cpp b/src/fileProcess/bridge.cpp index 3c54316..8015322 100644 --- a/src/fileProcess/bridge.cpp +++ b/src/fileProcess/bridge.cpp @@ -47,6 +47,11 @@ void Bridge::transparencyChanged(int transparency) m_configfilemanager->modifyTransparencyConf(transparency); } +void Bridge::windowRadiusChanged(int windowradius) +{ + m_configfilemanager->modifywindowRadiusConf(windowradius); +} + void Bridge::appIconsMapChanged(QMap *appiconsmaps) { QMap::const_iterator it; diff --git a/src/fileProcess/bridge.h b/src/fileProcess/bridge.h index fb6f7eb..e26feb3 100644 --- a/src/fileProcess/bridge.h +++ b/src/fileProcess/bridge.h @@ -21,10 +21,12 @@ public: void accentColorChanged(QColor accentcolor); void exteriorChanged(QColor accentcolor); void transparencyChanged(int transparency); + void windowRadiusChanged(int windowradius); void appIconsMapChanged(QMap *appiconsmaps); void systemIconsMapChanged(QMap *systemiconsmaps); void cursorMapChanged(QMap *cursormap); void timeCursorMapChanged(QMap *timecursormap); + void startCopy(); void updateIconCache(QMap *appiconsmaps,QString icontype); signals: diff --git a/src/fileProcess/configfilemanager.cpp b/src/fileProcess/configfilemanager.cpp index 59c52df..cfc3b51 100644 --- a/src/fileProcess/configfilemanager.cpp +++ b/src/fileProcess/configfilemanager.cpp @@ -208,6 +208,34 @@ bool ConfigFileManager::modifyTransparencyConf(int transparency) } } +bool ConfigFileManager::modifywindowRadiusConf(int windowradius) +{ + QFile file(confFilePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Failed to open file: " << confFilePath; + return false; + } + + QTextStream in(&file); + QString content = in.readAll(); + file.close(); + + QString oldValue = "windowRadius="; + QString newValue = QString("windowRadius=%1").arg(windowradius); + content.replace(QRegExp(oldValue + "\\d+"), newValue); + qDebug()< *map,QDir cachedir); diff --git a/src/fileProcess/historyinfoload.cpp b/src/fileProcess/historyinfoload.cpp index 3ee8149..a93f3a1 100644 --- a/src/fileProcess/historyinfoload.cpp +++ b/src/fileProcess/historyinfoload.cpp @@ -14,6 +14,7 @@ HistoryInfoLoad::HistoryInfoLoad(const QString &date, QObject *parent) getAccentColor(); getRadius(); getTransparency(); + getWindowRadius(); } QString HistoryInfoLoad::getCover() @@ -207,9 +208,45 @@ void HistoryInfoLoad::getTransparency() } } +void HistoryInfoLoad::getWindowRadius() +{ + QString filePath = m_historyInfo.filepath + "/src/config/theme.conf"; + QFile file(filePath); + if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { + qDebug() << "无法打开文件:" << filePath; + return; + } + + QTextStream in(&file); + QString content = in.readAll(); + file.close(); + + int startIndex = content.indexOf("windowRadius="); + if (startIndex != -1) { + int lineStartIndex = content.lastIndexOf('\n', startIndex) + 1; + int lineEndIndex = content.indexOf('\n', startIndex); + + if (lineEndIndex == -1) { + lineEndIndex = content.size(); + } + + QString lineContent = content.mid(lineStartIndex, lineEndIndex - lineStartIndex).trimmed(); + lineContent.remove("windowRadius="); + + bool conversionSuccess = false; + int windowRadiusValue = lineContent.toInt(&conversionSuccess); + if (conversionSuccess) { + m_historyInfo.windowradius = windowRadiusValue; + qDebug() << "m_historyInfo.windowradius" << windowRadiusValue; + } else { + qDebug() << "无法将字符串转换为整数:" << lineContent; + } + } +} + HistoryInfo HistoryInfoLoad::getInfoData() { - qDebug()< *appiconsmaps) { emit appIconsMapChanged(appiconsmaps); }); diff --git a/src/maininterface.h b/src/maininterface.h index 971747f..9663176 100644 --- a/src/maininterface.h +++ b/src/maininterface.h @@ -48,6 +48,7 @@ signals: void coverPathChanged(QString path); void radiusChanged(int radius); void transparencyChanged(int transparency); + void windowRadiusChanged(int windowRadius); void accentColorChanged(QColor accentcolor); void exteriorChanged(QColor exteriorcolor); void appIconsMapChanged(QMap *appiconsmap); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 453786d..01b5ac8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -25,6 +25,7 @@ MainWindow::MainWindow(QWidget *parent) connect(m_maininterface, &MainInterface::accentColorChanged, m_bridge, &Bridge::accentColorChanged); connect(m_maininterface, &MainInterface::exteriorChanged, m_bridge, &Bridge::exteriorChanged); connect(m_maininterface, &MainInterface::transparencyChanged, m_bridge, &Bridge::transparencyChanged); + connect(m_maininterface, &MainInterface::windowRadiusChanged, m_bridge, &Bridge::windowRadiusChanged); // connect(m_maininterface, &MainInterface::appIconsMapChanged, this,[=]{ // m_bridge->updateIconCache(m_maininterface->getAppIconsMap(),"appicon"); // }); @@ -32,7 +33,7 @@ MainWindow::MainWindow(QWidget *parent) connect(m_maininterface, &MainInterface::systemIconsMapChanged, m_bridge, &Bridge::systemIconsMapChanged); connect(m_maininterface, &MainInterface::cursorMapChanged, m_bridge, &Bridge::cursorMapChanged); connect(m_maininterface, &MainInterface::timeCursorMapChanged, m_bridge, &Bridge::timeCursorMapChanged); - connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy); +// connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy); connect(m_bridge,&Bridge::updateInfo,m_historywidget,&HistoryWidget::updateInfo); } diff --git a/src/module/globalthemefeature.cpp b/src/module/globalthemefeature.cpp index 6d74095..f646736 100644 --- a/src/module/globalthemefeature.cpp +++ b/src/module/globalthemefeature.cpp @@ -1,6 +1,10 @@ -#include "globalthemefeature.h" +#include "globalthemefeature.h" #include "globalthemewidget.h" #include +#include +#include +#include + CustomGraphicsView::CustomGraphicsView(QGraphicsScene* scene) : QGraphicsView(scene) { setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setDragMode(QGraphicsView::ScrollHandDrag); @@ -85,6 +89,17 @@ void GlobalImageWidget::updatescale() graphicsView->scale(1, 1); } +void GlobalImageWidget::updateControlRadius(int Value) +{ + m_showbtn->setRadius(Value); +} + +void GlobalImageWidget::updateTransparency(int transparency) +{ + m_showwidget->setTransparency(transparency); + m_showwidget->update(); +} + GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePath) : QWidget(parent), m_coverFilePath(coverFilePath) { @@ -131,7 +146,7 @@ GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePa m_showwidget->setPalette(widgetpalette); QHBoxLayout *buttonlayout = new QHBoxLayout(); - m_showbtn = new QPushButton(m_showwidget); + m_showbtn = new RoundedButton(m_showwidget); m_showbtn->setFixedWidth(120); m_showbtn->setParent(m_showwidget); @@ -155,6 +170,10 @@ GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePa // 设置初始缩放倍数为0.9倍 qreal initialScale = 0.9; graphicsView->scale(initialScale, initialScale); + +// QGraphicsBlurEffect* blurEffect = new QGraphicsBlurEffect(this); +// blurEffect->setBlurRadius(1); +// m_showwidget->setGraphicsEffect(blurEffect); } Globalthemefeature::Globalthemefeature(QWidget *parent, const QString& coverFilePath) @@ -167,6 +186,8 @@ RoundedWidget::RoundedWidget(QWidget *parent) { setAttribute(Qt::WA_TranslucentBackground); setRadius(6); + setTransparency(65); + } void RoundedWidget::setRadius(int radius) @@ -174,6 +195,13 @@ void RoundedWidget::setRadius(int radius) m_radius = radius; } +void RoundedWidget::setTransparency(int transparency) +{ + m_transparency = transparency / 100.0; + qDebug()<setCover(m_info.coverpath); this->setWallpaper(m_info.wallpaperpath); this->setTransparency(m_info.transparency); + this->setWindowRadius(m_info.windowradius); // this->update(); } @@ -254,8 +255,9 @@ void GlobalThemeWidget::initFilletWidget() QObject::connect(m_filletslider, &QSlider::valueChanged, [=](int value) { showButton->setText(QString::number(value)+"px"); - m_preview->updatescale(); - m_preview->updateWidgetRadius(value); + + m_preview->updateControlRadius(value); + emit newRadius(value); }); @@ -327,6 +329,7 @@ void GlobalThemeWidget::initTransparencyWidget() QObject::connect(m_transparencyslider, &QSlider::valueChanged, [=](int value) { showButton->setText(QString::number(value)+"%"); newTransparency(value); + m_preview->updateTransparency(value); }); layout->addWidget(title); layout->addWidget(m_transparencyslider); @@ -343,10 +346,18 @@ void GlobalThemeWidget::initWindowFilletWidget() QLabel *title = new QLabel(tr("Window fillet")); m_filletcombobox = new QComboBox(m_windowfilletwidget); - m_filletcombobox->addItem(tr("Large"),QColor(55, 144, 250)); - m_filletcombobox->addItem(tr("Medium"), QColor(120, 115, 245)); - m_filletcombobox->addItem(tr("Small"), QColor(120, 115, 245)); + m_filletcombobox->addItem(tr("Large"), int(12)); + m_filletcombobox->addItem(tr("Medium"), int(6)); + m_filletcombobox->addItem(tr("Small"), int(0)); + m_filletcombobox->setCurrentIndex(1); + connect(m_filletcombobox, QOverload::of(&QComboBox::currentIndexChanged), this, [=](int index){ + int selectedSize = m_filletcombobox->itemData(index).value(); + m_preview->updatescale(); + m_preview->updateWidgetRadius(selectedSize); + + emit newWindowRadius(selectedSize); + }); layout->addWidget(title); layout->addWidget(m_filletcombobox); m_windowfilletwidget->setLayout(layout); @@ -412,3 +423,16 @@ void GlobalThemeWidget::setWallpaper(QString wallpaperpath) { wallpaperbtn->setIcon(QIcon(wallpaperpath)); } + +void GlobalThemeWidget::setWindowRadius(int windowradius) +{ + QMap radiusIndexMap; + radiusIndexMap.insert(0, 2); + radiusIndexMap.insert(6, 1); + radiusIndexMap.insert(12, 0); + + if (radiusIndexMap.contains(windowradius)) { + int index = radiusIndexMap.value(windowradius); + m_filletcombobox->setCurrentIndex(index); + } +} diff --git a/src/module/globalthemewidget.h b/src/module/globalthemewidget.h index bbfc8d6..81d8603 100644 --- a/src/module/globalthemewidget.h +++ b/src/module/globalthemewidget.h @@ -31,6 +31,7 @@ signals: void newAccentColor(const QColor selectedColor); void newExterior(const QColor selectedColor); void newTransparency(const int transparency); + void newWindowRadius(const int radius); private: void initPreviewWidget(); void initRightWidget(); @@ -50,6 +51,7 @@ private: void setTransparency(int transparency); void setCover(QString coverpath); void setWallpaper(QString wallpaperpath); + void setWindowRadius(int windowradius); QWidget *m_globalthemewidget; QWidget *m_coverwidget; QWidget *m_wallpaperwidget;