dde-dock/plugins/pluginmanager/iconmanager.cpp
caixiangrong 50dad25442 fix: 修改插件区域出现重复的电池图标问题
1.修改电池图标状态刷新处理
2.将电池插件改到快捷面板内
3.快捷面板组合图标改为默认图标

Log: 修改插件区域出现重复的电池图标问题
Bug: https://pms.uniontech.com/bug-view-184085.html
Influence: 任务栏-电池图标状态刷新
Change-Id: I8af36acfd9a42efa186338c115f33255af5c1fa6
2023-01-31 11:26:09 +08:00

81 lines
2.4 KiB
C++

/*
* Copyright (C) 2023 ~ 2023 Deepin Technology Co., Ltd.
*
* Author: donghualin <donghualin@uniontech.com>
*
* Maintainer: donghualin <donghualin@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "iconmanager.h"
#include "dockplugincontroller.h"
#include "pluginsiteminterface.h"
#include <DDciIcon>
#include <DWindowManagerHelper>
#include <DSysInfo>
#include <DPlatformTheme>
#include <QPainter>
#include <QPainterPath>
#define ITEMSPACE 6
#define IMAGESIZE 12
#define ITEMSIZE 18
#define MINISIZE 1
#define STARTPOS 2
DGUI_USE_NAMESPACE
IconManager::IconManager(DockPluginController *pluginController, QObject *parent)
: QObject{parent}
, m_pluginController(pluginController)
, m_position(Dock::Position::Bottom)
, m_displayMode(Dock::DisplayMode::Efficient)
{
}
void IconManager::setPosition(Dock::Position position)
{
m_position = position;
}
void IconManager::setDisplayMode(Dock::DisplayMode displayMode)
{
m_displayMode = displayMode;
}
QPixmap IconManager::pixmap(DGuiApplicationHelper::ColorType colorType) const
{
// 缺省图标
QPixmap pixmap = QIcon::fromTheme("dock-control-panel").pixmap(ITEMSIZE, ITEMSIZE);
QColor foreColor = (colorType == DGuiApplicationHelper::ColorType::DarkType ? Qt::white : Qt::black);
foreColor.setAlphaF(0.8);
QPainter pa(&pixmap);
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
pa.fillRect(pixmap.rect(), foreColor);
return pixmap.scaled(pixmap.size() / qApp->devicePixelRatio());
}
PluginsItemInterface *IconManager::findPlugin(const QString &pluginName) const
{
QList<PluginsItemInterface *> plugins = m_pluginController->currentPlugins();
for (PluginsItemInterface *plugin : plugins) {
if (plugin->pluginName() == pluginName)
return plugin;
}
return nullptr;
}