Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dcc dock plugin icon pixelated again #938

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/dbus/dbusdockadaptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ QIcon DBusDockAdaptors::getSettingIcon(PluginsItemInterface *plugin, QSize &pixm
{
auto iconSize = [](const QIcon &icon) {
QList<QSize> iconSizes = icon.availableSizes();
if (iconSizes.size() > 0)
if (iconSizes.size() > 0 && !iconSizes[0].isNull() )
return iconSizes[0];

return defaultIconSize;
Expand Down
16 changes: 13 additions & 3 deletions plugins/multitasking/multitaskingplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <DWindowManagerHelper>
#include <DDBusSender>
#include <QPainter>

#include <QIcon>

Expand Down Expand Up @@ -141,8 +142,17 @@ void MultitaskingPlugin::invokedMenuItem(const QString &itemKey, const QString &

QIcon MultitaskingPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
{
if (dockPart == DockPart::DCCSetting)
return QIcon::fromTheme("dcc-multitasking-view",QIcon(":/icons/icons/dcc-multitasking-view.svg"));
if (dockPart == DockPart::DCCSetting) {
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();
}
Expand Down Expand Up @@ -176,4 +186,4 @@ PluginsItemInterface::PluginType MultitaskingPlugin::type()
PluginFlags MultitaskingPlugin::flags() const
{
return PluginFlag::Type_Fixed | Attribute_CanSetting;
}
}
2 changes: 1 addition & 1 deletion plugins/show-desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ find_package(DtkWidget REQUIRED)
pkg_check_modules(XCB_LIBS REQUIRED IMPORTED_TARGET xcursor)

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 ../)
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ../../interfaces)
target_link_libraries(${PLUGIN_NAME} PRIVATE
Expand Down
14 changes: 12 additions & 2 deletions plugins/show-desktop/showdesktopplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "showdesktopplugin.h"
#include "imageutil.h"
#include "../widgets/tipswidget.h"

#include <QIcon>
#include <QDebug>
#include <DDBusSender>
#include <QPainter>

using namespace Dock;
ShowDesktopPlugin::ShowDesktopPlugin(QObject *parent)
Expand Down Expand Up @@ -121,9 +123,17 @@ void ShowDesktopPlugin::refreshIcon(const QString &itemKey)

QIcon ShowDesktopPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
{

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();
Expand Down
6 changes: 5 additions & 1 deletion plugins/shutdown/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set(PLUGIN_NAME "shutdown")
project(${PLUGIN_NAME})

# 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(Qt5Widgets REQUIRED)
Expand Down
5 changes: 3 additions & 2 deletions plugins/shutdown/shutdownplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ void ShutdownPlugin::setSortKey(const QString &itemKey, const int order)
QIcon ShutdownPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
{
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)
return QIcon(":/icons/resources/icons/dcc_shutdown.svg");
return pixmap;

QPixmap pixmap(":/icons/resources/icons/dcc_shutdown.svg");
QPainter pa(&pixmap);
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
pa.fillRect(pixmap.rect(), Qt::white);
Expand Down
12 changes: 10 additions & 2 deletions plugins/sound/sounddeviceswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,15 @@ QPixmap SoundDevicesWidget::pixmap(DGuiApplicationHelper::ColorType colorType, i
else if (volmue > maxVolmue * 1 / 3)
volumeString = "medium";
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 changes: 3 additions & 2 deletions plugins/trash/trashplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "trashplugin.h"
#include "../../widgets/tipswidget.h"
#include "imageutil.h"

#include <DApplication>
#include <DDesktopServices>
Expand Down Expand Up @@ -174,10 +175,10 @@ void TrashPlugin::pluginSettingsChanged()
QIcon TrashPlugin::icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType)
{
if (dockPart == DockPart::DCCSetting) {
auto pixmap = ImageUtil::loadSvg(":/icons/dcc_trash.svg", QSize(18, 18));
if (themeType == DGuiApplicationHelper::ColorType::LightType)
return QIcon(":/icons/dcc_trash.svg");
return pixmap;

QPixmap pixmap(":/icons/dcc_trash.svg");
QPainter pa(&pixmap);
pa.setCompositionMode(QPainter::CompositionMode_SourceIn);
pa.fillRect(pixmap.rect(), Qt::white);
Expand Down