From ba188d74342fbf1755f969e2039fe8fa23c8dc19 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Wed, 6 Sep 2023 11:06:00 +0800 Subject: [PATCH] add bridge --- src/bridge.cpp | 60 +++++++++++++++++++++++++++++++++++++++ src/bridge.h | 30 ++++++++++++++++++++ src/cursorthemewidget.cpp | 14 +++++++-- src/cursorthemewidget.h | 2 ++ src/globalthemewidget.cpp | 34 +++++++++++++++------- src/globalthemewidget.h | 12 ++++++-- src/iconthemewidget.cpp | 5 ++-- src/iconthemewidget.h | 2 ++ src/infocreatewidget.cpp | 2 -- src/maininterface.cpp | 30 +++++++++++++++++++- src/maininterface.h | 9 ++++++ src/mainwindow.cpp | 11 ++++++- src/mainwindow.h | 2 ++ 13 files changed, 191 insertions(+), 22 deletions(-) create mode 100644 src/bridge.cpp create mode 100644 src/bridge.h diff --git a/src/bridge.cpp b/src/bridge.cpp new file mode 100644 index 0000000..af2d317 --- /dev/null +++ b/src/bridge.cpp @@ -0,0 +1,60 @@ +#include "bridge.h" + +Bridge::Bridge(QObject *parent) : QObject(parent) +{ + +} + +void Bridge::wallpaperPathChanged(QString path) { + +} +void Bridge::coverPathChanged(QString path) { + +} + +void Bridge::radiusChanged(int radius) +{ + +} + +void Bridge::accentColorChanged(QColor accentcolor) +{ + +} + +void Bridge::exteriorChanged(QColor accentcolor) +{ + +} + +void Bridge::appIconsMapChanged(QMap *appiconsmaps) +{ + QMap::const_iterator it; + for (it = appiconsmaps->begin(); it != appiconsmaps->end(); ++it) { + qDebug() << "Key:" << it.key() << "Value:" << it.value(); + } +} + +void Bridge::systemIconsMapChanged(QMap *systemiconsmaps) +{ + QMap::const_iterator it; + for (it = systemiconsmaps->begin(); it != systemiconsmaps->end(); ++it) { + qDebug() << "Key:" << it.key() << "Value:" << it.value(); + } +} + +void Bridge::cursorMapChanged(QMap *cursormap) +{ + QMap::const_iterator it; + for (it = cursormap->begin(); it != cursormap->end(); ++it) { + qDebug() << "Key:" << it.key() << "Value:" << it.value(); + } +} + +void Bridge::timeCursorMapChanged(QMap *timecursormap) +{ + QMap::const_iterator it; + for (it = timecursormap->begin(); it != timecursormap->end(); ++it) { + qDebug() << "Key:" << it.key() << "Value:" << it.value(); + } +} diff --git a/src/bridge.h b/src/bridge.h new file mode 100644 index 0000000..0b97dec --- /dev/null +++ b/src/bridge.h @@ -0,0 +1,30 @@ +#ifndef BRIDGE_H +#define BRIDGE_H + +#include +#include +#include +#include + +class Bridge : public QObject +{ + Q_OBJECT +public: + explicit Bridge(QObject *parent = nullptr); + + void wallpaperPathChanged(QString path); + void coverPathChanged(QString path); + void radiusChanged(int radius); + void accentColorChanged(QColor accentcolor); + void exteriorChanged(QColor accentcolor); + void appIconsMapChanged(QMap *appiconsmaps); + void systemIconsMapChanged(QMap *systemiconsmaps); + void cursorMapChanged(QMap *cursormap); + void timeCursorMapChanged(QMap *timecursormap); +signals: + +private: + +}; + +#endif // BRIDGE_H diff --git a/src/cursorthemewidget.cpp b/src/cursorthemewidget.cpp index d19011e..a4fb146 100644 --- a/src/cursorthemewidget.cpp +++ b/src/cursorthemewidget.cpp @@ -118,11 +118,21 @@ void CursorThemeWidget::initRightWidget() if (clickedWidget) { QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择SVG文件"), "", tr("SVG 文件 (*.svg)")); if (!newFilePath.isEmpty()) { - m_customiconpathmap->insert(widgetName, newFilePath); - clickedWidget->setcustomicon(newFilePath); + if (m_iconpathmap->contains(widgetName)) { + + m_customiconpathmap->insert(widgetName, newFilePath); + emit newCursorMap(m_customiconpathmap); + } else if (m_timeiconpathmap->contains(widgetName)) { + + m_timecustomiconpathmap->insert(widgetName, newFilePath); + emit newCursorMap(m_timecustomiconpathmap); + } m_preview->updateIcon(widgetName, newFilePath); m_preview2->updateIcon(widgetName, newFilePath); + clickedWidget->setcustomicon(newFilePath); + } + } } }); diff --git a/src/cursorthemewidget.h b/src/cursorthemewidget.h index 8eb919f..e2a0d36 100644 --- a/src/cursorthemewidget.h +++ b/src/cursorthemewidget.h @@ -24,6 +24,8 @@ public: signals: void wallpaperupdate(const QString& filePath); + void newCursorMap(QMap *cursormap); + void newTimeCursorMap(QMap *timecursormap); private: void initPreviewWidget(); void initMaps(); diff --git a/src/globalthemewidget.cpp b/src/globalthemewidget.cpp index b14ede6..8ca37a6 100644 --- a/src/globalthemewidget.cpp +++ b/src/globalthemewidget.cpp @@ -11,6 +11,11 @@ GlobalThemeWidget::GlobalThemeWidget(QWidget *parent) : QWidget(parent) this->setLayout(m_globalthemelayout); } +QString GlobalThemeWidget::getWallpaperPath() +{ + return m_wallpaperpath; +} + void GlobalThemeWidget::initPreviewWidget() { m_previewwidget = new QWidget(this); @@ -91,12 +96,17 @@ void GlobalThemeWidget::initCoverWidget() if (newFilePath.isEmpty()) { qDebug() << "Selected file path:" << newFilePath; newFilePath = m_coverpath; + QPixmap pixmap(m_coverpath); + coverbtn->setIcon(QIcon(pixmap)); + coverbtn->setIconSize(coverbtn->size()); + }else{ + m_coverpath = newFilePath; + QPixmap pixmap(m_coverpath); + coverbtn->setIcon(QIcon(pixmap)); + coverbtn->setIconSize(coverbtn->size()); + emit newCoverFilePath(newFilePath); } - qDebug() << "Selected file path:<<<<<<<<<<<<<<,snewFilePath" << newFilePath; - m_coverpath = newFilePath; - QPixmap pixmap(m_coverpath); - coverbtn->setIcon(QIcon(pixmap)); - coverbtn->setIconSize(coverbtn->size()); + }); layout->addStretch(1); @@ -134,14 +144,15 @@ void GlobalThemeWidget::initWallPaperWidget() QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择PNG文件"), "", tr("PNG 文件 (*.png)")); if (newFilePath.isEmpty()) { qDebug() << "Selected file path:" << newFilePath; - updateCoverFilePath(m_wallpaperpath); + updateWallpaperFilePath(m_wallpaperpath); }else{ - - updateCoverFilePath(newFilePath); + updateWallpaperFilePath(newFilePath); emit wallpaperupdate(newFilePath); + emit newWallpaperFilePath(newFilePath); QPixmap pixmap(newFilePath); coverbtn->setIcon(QIcon(pixmap)); coverbtn->setIconSize(coverbtn->size()); + } }); @@ -177,7 +188,7 @@ void GlobalThemeWidget::initExteriorWidget() m_preview->updateOverlayImage(":/resource/background/panel-dark.png"); m_preview->updatescale(); } - + emit newExterior(combobox->itemData(index).value()); }); layout->addWidget(title); @@ -215,7 +226,7 @@ void GlobalThemeWidget::initFilletWidget() showButton->setText(QString::number(value)+"px"); m_preview->updatescale(); m_preview->updateWidgetRadius(value); - + emit newRadius(value); }); layout->addWidget(title); @@ -253,6 +264,7 @@ void GlobalThemeWidget::AccentColorWidget() qDebug() << "RGB values:" << selectedColor.red() << selectedColor.green() << selectedColor.blue(); m_preview->updatescale(); m_preview->updateButtonColor(selectedColor); + emit newAccentColor(selectedColor); }); layout->addWidget(title); @@ -261,7 +273,7 @@ void GlobalThemeWidget::AccentColorWidget() m_accentcolorwidget->setLayout(layout); } -void GlobalThemeWidget::updateCoverFilePath(const QString& coverFilePath) { +void GlobalThemeWidget::updateWallpaperFilePath(const QString& coverFilePath) { m_wallpaperpath = coverFilePath; if (m_preview != nullptr) { diff --git a/src/globalthemewidget.h b/src/globalthemewidget.h index 8b575c3..797aacc 100644 --- a/src/globalthemewidget.h +++ b/src/globalthemewidget.h @@ -20,9 +20,14 @@ class GlobalThemeWidget : public QWidget Q_OBJECT public: explicit GlobalThemeWidget(QWidget *parent = nullptr); - + QString getWallpaperPath(); signals: void wallpaperupdate(const QString& filePath); + void newWallpaperFilePath(const QString& path); + void newCoverFilePath(const QString& path); + void newRadius(const int radius); + void newAccentColor(const QColor selectedColor); + void newExterior(const QColor selectedColor); private: void initPreviewWidget(); void initRightWidget(); @@ -32,8 +37,9 @@ private: void initExteriorWidget(); void initFilletWidget(); void AccentColorWidget(); - void updateCoverFilePath(const QString& coverFilePath); + void updateWallpaperFilePath(const QString& coverFilePath); void addspaceritem(); + QWidget *m_globalthemewidget; QWidget *m_coverwidget; QWidget *m_wallpaperwidget; @@ -42,7 +48,7 @@ private: QWidget *m_accentcolorwidget; QVBoxLayout *m_previewlayout; QString m_wallpaperpath = ":/resource/background/background-light.png"; - QString m_coverpath = ""; + QString m_coverpath = ":/resource/background/background-light.png"; QWidget *m_viewportwidget; QScrollArea *m_scrollArea; diff --git a/src/iconthemewidget.cpp b/src/iconthemewidget.cpp index e131bc7..0dc3566 100644 --- a/src/iconthemewidget.cpp +++ b/src/iconthemewidget.cpp @@ -84,8 +84,8 @@ void IconThemeWidget::initEditWidget() clickedWidget->setcustomicon(newFilePath); qDebug() << "Selected file path:" << newFilePath<< "Corresponding widgetName:" << widgetName; m_preview->updateIcon(widgetName, newFilePath); - } + emit newAppIconsMap(m_customiconpathmap); } } }); @@ -138,6 +138,7 @@ void IconThemeWidget::initSystemEditWidget() qDebug() << "Selected file path:" << newFilePath<< "Corresponding widgetName:" << widgetName; m_systempreview->updateIcon(widgetName, newFilePath); } + emit newSystemIconsMap(m_systemcustomiconpathmap); } } }); @@ -194,7 +195,7 @@ void IconThemeWidget::initSystemMaps() qDebug() <<"key----------" <keys() <<"value-----------" <; + m_systemcustomiconpathmap= m_systemiconpathmap; m_systempathWidgetMap = new QMap; } diff --git a/src/iconthemewidget.h b/src/iconthemewidget.h index a9dddfd..117ee99 100644 --- a/src/iconthemewidget.h +++ b/src/iconthemewidget.h @@ -29,6 +29,8 @@ public: void initRightWidget(); signals: void wallpaperupdate(const QString& filePath); + void newAppIconsMap(QMap *appiconsmap); + void newSystemIconsMap(QMap *systemiconsmap); private: QStringList getWidgetNamesFromFilesInDirectory(const QString& directoryPath); diff --git a/src/infocreatewidget.cpp b/src/infocreatewidget.cpp index d9ec5b2..370ac01 100644 --- a/src/infocreatewidget.cpp +++ b/src/infocreatewidget.cpp @@ -241,5 +241,3 @@ void InfoCreateWidget::InfoProcess(const QString &m_date){ }); } - - diff --git a/src/maininterface.cpp b/src/maininterface.cpp index de3ea37..b5e52e5 100644 --- a/src/maininterface.cpp +++ b/src/maininterface.cpp @@ -1,9 +1,11 @@ #include "maininterface.h" + MainInterface::MainInterface(QWidget *parent) : QWidget(parent) { // this->setBackgroundRole(QPalette::Base); + m_belowwidget = new QWidget(this); init(); @@ -12,7 +14,33 @@ MainInterface::MainInterface(QWidget *parent) : QWidget(parent) layout->addWidget(m_belowwidget); this->setLayout(layout); - + connect(m_globalthemewidget, &GlobalThemeWidget::newWallpaperFilePath, this, [&](const QString& path) { + emit wallpaperPathChanged(path); + }); + connect(m_globalthemewidget, &GlobalThemeWidget::newCoverFilePath, this, [&](const QString& path) { + emit coverPathChanged(path); + }); + connect(m_globalthemewidget, &GlobalThemeWidget::newRadius, this, [&](const int radius) { + emit radiusChanged(radius); + }); + connect(m_globalthemewidget, &GlobalThemeWidget::newAccentColor, this, [&](const QColor selectedColor) { + emit accentColorChanged(selectedColor); + }); + connect(m_globalthemewidget, &GlobalThemeWidget::newExterior, this, [&](const QColor selectedColor) { + emit exteriorChanged(selectedColor); + }); + connect(m_iconthemewidget, &IconThemeWidget::newAppIconsMap, this, [&]( QMap *appiconsmaps) { + emit appIconsMapChanged(appiconsmaps); + }); + connect(m_iconthemewidget, &IconThemeWidget::newSystemIconsMap, this, [&]( QMap *systemiconsmaps) { + emit systemIconsMapChanged(systemiconsmaps); + }); + connect(m_cursorthemewidget, &CursorThemeWidget::newCursorMap, this, [&]( QMap *cursormaps) { + emit cursorMapChanged(cursormaps); + }); + connect(m_cursorthemewidget, &CursorThemeWidget::newTimeCursorMap, this, [&]( QMap *timecursormaps) { + emit timeCursorMapChanged(timecursormaps); + }); } void MainInterface::init() diff --git a/src/maininterface.h b/src/maininterface.h index d71a296..90ef918 100644 --- a/src/maininterface.h +++ b/src/maininterface.h @@ -32,6 +32,15 @@ public: void setCursorTheme(); signals: void wallpaperupdate(const QString& filePath); + void wallpaperPathChanged(QString path); + void coverPathChanged(QString path); + void radiusChanged(int radius); + void accentColorChanged(QColor accentcolor); + void exteriorChanged(QColor exteriorcolor); + void appIconsMapChanged(QMap *appiconsmap); + void systemIconsMapChanged(QMap *systemiconsmap); + void cursorMapChanged(QMap *appiconsmap); + void timeCursorMapChanged(QMap *systemiconsmap); private: void init(); void initLeftBar(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9d19272..f77f10d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4,7 +4,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { -// setWindowFlags(Qt::FramelessWindowHint); + setWindowFlags(Qt::FramelessWindowHint); initUI(); m_titlebar = new TitleBar(this); @@ -17,6 +17,15 @@ MainWindow::MainWindow(QWidget *parent) setMouseTracking(true); connect(m_titlebar, &TitleBar::gohomesignal, this, &MainWindow::onGoHomeClicked); FileProcess(); + m_bridge = new Bridge(); + connect(m_maininterface, &MainInterface::wallpaperPathChanged, m_bridge, &Bridge::wallpaperPathChanged); + connect(m_maininterface, &MainInterface::coverPathChanged, m_bridge, &Bridge::coverPathChanged); + 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::appIconsMapChanged, m_bridge, &Bridge::appIconsMapChanged); + connect(m_maininterface, &MainInterface::systemIconsMapChanged, m_bridge, &Bridge::systemIconsMapChanged); + connect(m_maininterface, &MainInterface::cursorMapChanged, m_bridge, &Bridge::systemIconsMapChanged); } MainWindow::~MainWindow() diff --git a/src/mainwindow.h b/src/mainwindow.h index 458671a..9145c93 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include "maininterface.h" +#include "src/bridge.h" #include #include @@ -64,6 +65,7 @@ private: EntryButton *m_iconbtn; EntryButton *m_cursorbtn; MainInterface *m_maininterface; + Bridge *m_bridge; FileProcess m_fileProcess; TitleBar*m_titlebar; QPoint m_dragStartPosition;