mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-01 07:05:48 +00:00
fix: dcc dock plugin icon pixelated again
- 部分图片路径写错 - 资源图片直接加到qicon中,qicon.availableSizes[0]={0, 0} - 部分插件没有适配主题颜色 Issue: https://github.com/linuxdeepin/developer-center/issues/5682
This commit is contained in:
parent
c76dcb4361
commit
971cd92007
@ -326,7 +326,7 @@ QIcon DBusDockAdaptors::getSettingIcon(PluginsItemInterface *plugin, QSize &pixm
|
|||||||
{
|
{
|
||||||
auto iconSize = [](const QIcon &icon) {
|
auto iconSize = [](const QIcon &icon) {
|
||||||
QList<QSize> iconSizes = icon.availableSizes();
|
QList<QSize> iconSizes = icon.availableSizes();
|
||||||
if (iconSizes.size() > 0)
|
if (iconSizes.size() > 0 && !iconSizes[0].isNull() )
|
||||||
return iconSizes[0];
|
return iconSizes[0];
|
||||||
|
|
||||||
return defaultIconSize;
|
return defaultIconSize;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <DWindowManagerHelper>
|
#include <DWindowManagerHelper>
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
@ -141,8 +142,17 @@ void MultitaskingPlugin::invokedMenuItem(const QString &itemKey, const QString &
|
|||||||
|
|
||||||
QIcon MultitaskingPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
QIcon MultitaskingPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
||||||
{
|
{
|
||||||
if (dockPart == DockPart::DCCSetting)
|
if (dockPart == DockPart::DCCSetting) {
|
||||||
return QIcon::fromTheme("dcc-multitasking-view",QIcon(":/icons/icons/dcc-multitasking-view.svg"));
|
auto icon = QIcon::fromTheme("dcc-multitasking-view", QIcon(":/icons/dcc-multitasking-view.svg"));
|
||||||
|
QPixmap pixmap = icon.pixmap(QSize(18, 18));
|
||||||
|
if (themeType == DGuiApplicationHelper::ColorType::LightType)
|
||||||
|
return pixmap;
|
||||||
|
|
||||||
|
QPainter pa(&pixmap);
|
||||||
|
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
|
pa.fillRect(pixmap.rect(), Qt::white);
|
||||||
|
return pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
@ -176,4 +186,4 @@ PluginsItemInterface::PluginType MultitaskingPlugin::type()
|
|||||||
PluginFlags MultitaskingPlugin::flags() const
|
PluginFlags MultitaskingPlugin::flags() const
|
||||||
{
|
{
|
||||||
return PluginFlag::Type_Fixed | Attribute_CanSetting;
|
return PluginFlag::Type_Fixed | Attribute_CanSetting;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ find_package(DtkWidget REQUIRED)
|
|||||||
pkg_check_modules(XCB_LIBS REQUIRED IMPORTED_TARGET xcursor)
|
pkg_check_modules(XCB_LIBS REQUIRED IMPORTED_TARGET xcursor)
|
||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS})
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} resource.qrc)
|
||||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
|
||||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ../../interfaces)
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ../../interfaces)
|
||||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
#include "showdesktopplugin.h"
|
#include "showdesktopplugin.h"
|
||||||
|
#include "imageutil.h"
|
||||||
#include "../widgets/tipswidget.h"
|
#include "../widgets/tipswidget.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
using namespace Dock;
|
using namespace Dock;
|
||||||
ShowDesktopPlugin::ShowDesktopPlugin(QObject *parent)
|
ShowDesktopPlugin::ShowDesktopPlugin(QObject *parent)
|
||||||
@ -121,9 +123,17 @@ void ShowDesktopPlugin::refreshIcon(const QString &itemKey)
|
|||||||
|
|
||||||
QIcon ShowDesktopPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
QIcon ShowDesktopPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (dockPart == DockPart::DCCSetting) {
|
if (dockPart == DockPart::DCCSetting) {
|
||||||
return QIcon::fromTheme("dcc-show-desktop", QIcon(":/icons/icons/dcc-show-desktop.svg"));
|
auto loadsvg = []{ return ImageUtil::loadSvg(":/icons/dcc-show-desktop.svg", QSize(18, 18));};
|
||||||
|
auto icon = QIcon::fromTheme("dcc-show-desktop", loadsvg());
|
||||||
|
QPixmap pixmap = icon.pixmap(QSize(18, 18));
|
||||||
|
if (themeType == DGuiApplicationHelper::ColorType::LightType)
|
||||||
|
return pixmap;
|
||||||
|
|
||||||
|
QPainter pa(&pixmap);
|
||||||
|
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
|
pa.fillRect(pixmap.rect(), Qt::white);
|
||||||
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QIcon();
|
return QIcon();
|
||||||
|
@ -4,7 +4,11 @@ set(PLUGIN_NAME "shutdown")
|
|||||||
project(${PLUGIN_NAME})
|
project(${PLUGIN_NAME})
|
||||||
|
|
||||||
# Sources files
|
# Sources files
|
||||||
file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/tipswidget.h" "../../widgets/tipswidget.cpp")
|
file(GLOB_RECURSE SRCS "*.h" "*.cpp"
|
||||||
|
"../../widgets/tipswidget.h"
|
||||||
|
"../../widgets/tipswidget.cpp"
|
||||||
|
"../../frame/util/imageutil.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
@ -275,10 +275,11 @@ void ShutdownPlugin::setSortKey(const QString &itemKey, const int order)
|
|||||||
QIcon ShutdownPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
QIcon ShutdownPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
||||||
{
|
{
|
||||||
if (dockPart == DockPart::DCCSetting) {
|
if (dockPart == DockPart::DCCSetting) {
|
||||||
|
QString iconFile(":/icons/resources/icons/dcc_shutdown.svg");
|
||||||
|
auto pixmap = ImageUtil::loadSvg(iconFile, QSize(18, 18));
|
||||||
if (themeType == DGuiApplicationHelper::ColorType::LightType)
|
if (themeType == DGuiApplicationHelper::ColorType::LightType)
|
||||||
return QIcon(":/icons/resources/icons/dcc_shutdown.svg");
|
return pixmap;
|
||||||
|
|
||||||
QPixmap pixmap(":/icons/resources/icons/dcc_shutdown.svg");
|
|
||||||
QPainter pa(&pixmap);
|
QPainter pa(&pixmap);
|
||||||
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
pa.fillRect(pixmap.rect(), Qt::white);
|
pa.fillRect(pixmap.rect(), Qt::white);
|
||||||
|
@ -530,7 +530,15 @@ QPixmap SoundDevicesWidget::pixmap(DGuiApplicationHelper::ColorType colorType, i
|
|||||||
else if (volmue > maxVolmue * 1 / 3)
|
else if (volmue > maxVolmue * 1 / 3)
|
||||||
volumeString = "medium";
|
volumeString = "medium";
|
||||||
else
|
else
|
||||||
volumeString = "low";;
|
volumeString = "low";
|
||||||
|
|
||||||
return QIcon::fromTheme(QString("audio-volume-%1-symbolic").arg(volumeString)).pixmap(iconWidth, iconHeight);
|
auto pixmap = QIcon::fromTheme(QString("audio-volume-%1-symbolic").arg(volumeString)).pixmap(iconWidth, iconHeight);
|
||||||
|
|
||||||
|
if (colorType == DGuiApplicationHelper::ColorType::LightType)
|
||||||
|
return pixmap;
|
||||||
|
|
||||||
|
QPainter pa(&pixmap);
|
||||||
|
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
|
pa.fillRect(pixmap.rect(), Qt::white);
|
||||||
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "trashplugin.h"
|
#include "trashplugin.h"
|
||||||
#include "../../widgets/tipswidget.h"
|
#include "../../widgets/tipswidget.h"
|
||||||
|
#include "imageutil.h"
|
||||||
|
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
#include <DDesktopServices>
|
#include <DDesktopServices>
|
||||||
@ -174,10 +175,10 @@ void TrashPlugin::pluginSettingsChanged()
|
|||||||
QIcon TrashPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
QIcon TrashPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
|
||||||
{
|
{
|
||||||
if (dockPart == DockPart::DCCSetting) {
|
if (dockPart == DockPart::DCCSetting) {
|
||||||
|
auto pixmap = ImageUtil::loadSvg(":/icons/dcc_trash.svg", QSize(18, 18));
|
||||||
if (themeType == DGuiApplicationHelper::ColorType::LightType)
|
if (themeType == DGuiApplicationHelper::ColorType::LightType)
|
||||||
return QIcon(":/icons/dcc_trash.svg");
|
return pixmap;
|
||||||
|
|
||||||
QPixmap pixmap(":/icons/dcc_trash.svg");
|
|
||||||
QPainter pa(&pixmap);
|
QPainter pa(&pixmap);
|
||||||
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
pa.fillRect(pixmap.rect(), Qt::white);
|
pa.fillRect(pixmap.rect(), Qt::white);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user