添加图标跟随主题变化

This commit is contained in:
youdiansaodongxi 2023-06-14 11:40:12 +08:00
parent c51e78b505
commit ea35c8fd75
8 changed files with 32 additions and 0 deletions

View File

@ -41,6 +41,7 @@ StyleBackground {
width: iconGrid.cellWidth
height: iconGrid.cellHeight
source: modelData
cache: false
}
}
}

View File

@ -61,6 +61,7 @@ Item {
height: root.iconHeight
width: root.iconWidth
source: root.appIcon
cache: false
}
StyleText {

View File

@ -256,6 +256,7 @@ RowLayout {
height: 96
width: 96
source: icon
cache: false
}
}

View File

@ -20,6 +20,8 @@
#include "app-data-manager.h"
#include "app-manager.h"
#include "commons.h"
#include "settings.h"
#include <QDebug>
#include <QAbstractListModel>
#include <application-info.h>
@ -55,6 +57,7 @@ public:
Q_INVOKABLE void openMenu(const int &index);
public Q_SLOTS:
void exchangedAppsOrder(int startIndex, int endIndex);
void onStyleChanged(const GlobalSetting::Key &key);
private:
QVector<DataEntity> m_favoriteAppsData;
@ -72,6 +75,7 @@ FavoriteExtension::FavoriteExtension(QObject *parent) : MenuExtensionIFace(paren
updateFavoriteData();
connect(AppDataManager::instance(),&AppDataManager::favoriteAppChanged, this,&FavoriteExtension::updateFavoriteData);
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, m_favoriteAppsModel, &FavoriteAppsModel::onStyleChanged);
}
FavoriteExtension::~FavoriteExtension()
@ -181,6 +185,14 @@ void FavoriteAppsModel::exchangedAppsOrder(int startIndex, int endIndex)
AppDataManager::instance()->changedFavoriteOrderSignal(startId, endNum);
}
void FavoriteAppsModel::onStyleChanged(const GlobalSetting::Key &key)
{
if (key == GlobalSetting::IconThemeName) {
beginResetModel();
endResetModel();
}
}
bool FavoriteMenuProvider::isSupport(const MenuProvider::RequestType &type)
{
return type == DataType;

View File

@ -20,6 +20,7 @@
#include "app-manager.h"
#include "menu-manager.h"
#include "app-folder-helper.h"
#include "settings.h"
#include <QObject>
#include <QString>
@ -31,6 +32,7 @@ AppModel::AppModel(QObject *parent) : QAbstractListModel(parent)
reloadPluginData();
connect(DataProviderManager::instance(), &DataProviderManager::dataChanged, this, &AppModel::onPluginDataChanged);
connect(DataProviderManager::instance(), &DataProviderManager::pluginChanged, this, &AppModel::reloadPluginData);
connect(GlobalSetting::instance(), &GlobalSetting::styleChanged, this, &AppModel::onStyleChanged);
}
int AppModel::rowCount(const QModelIndex &parent) const
@ -121,6 +123,14 @@ void AppModel::reloadPluginData()
resetModel(data);
}
void AppModel::onStyleChanged(const GlobalSetting::Key &key)
{
if (key == GlobalSetting::IconThemeName) {
Q_EMIT beginResetModel();
Q_EMIT endResetModel();
}
}
void AppModel::toRenameFolder(QString id)
{
Q_EMIT renameText(id);

View File

@ -25,6 +25,7 @@
#include "commons.h"
#include "data-provider-manager.h"
#include "menu-provider.h"
#include "settings.h"
namespace UkuiMenu {
@ -53,6 +54,7 @@ public Q_SLOTS:
private Q_SLOTS:
void onPluginDataChanged(QVector<DataEntity> data, DataUpdateMode::Mode mode, quint32 index);
void reloadPluginData();
void onStyleChanged(const GlobalSetting::Key& key);
private:
void resetModel(QVector<DataEntity> &data);

View File

@ -31,6 +31,7 @@
#define UKUI_STYLE_NAME_KEY "styleName"
#define UKUI_STYLE_THEME_COLOR_KEY "themeColor"
#define UKUI_STYLE_SYSTEM_FONT_SIZE "systemFontSize"
#define UKUI_STYLE_ICON_THEME_NAME_KEY "iconThemeName"
namespace UkuiMenu {
@ -83,6 +84,9 @@ void GlobalSetting::initStyleSetting()
} else if (key == UKUI_STYLE_SYSTEM_FONT_SIZE) {
updateData(SystemFontSize, settings->get(key));
Q_EMIT styleChanged(SystemFontSize);
} else if (key == UKUI_STYLE_ICON_THEME_NAME_KEY) {
updateData(IconThemeName, settings->get(key));
Q_EMIT styleChanged(IconThemeName);
}
});
}

View File

@ -52,6 +52,7 @@ public:
UnKnowKey = 0,
StyleName,
ThemeColor,
IconThemeName,
Transparency,
EffectEnabled,
SystemFontSize