Skip to content

Commit

Permalink
Use KDE's icon engine
Browse files Browse the repository at this point in the history
It has KDE color schemes support that prevents dark icons on dark background
  • Loading branch information
ilya-fedin committed Oct 21, 2024
1 parent 7aaa013 commit 280b5f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000 -DUSE_WIDGETS)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core Widgets OPTIONAL_COMPONENTS QuickControls2 LinguistTools)
find_package(KF6Config)
find_package(KF6ColorScheme)
find_package(KF6IconThemes)

get_target_property(QT_QTPATHS_EXECUTABLE Qt6::qtpaths IMPORTED_LOCATION)

Expand Down
3 changes: 2 additions & 1 deletion src/qt6ct-qtplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)

add_library(qt6ct-qtplugin MODULE ${app_SRCS})
set_target_properties(qt6ct-qtplugin PROPERTIES OUTPUT_NAME qt6ct)
target_link_libraries(qt6ct-qtplugin PRIVATE Qt6::Widgets Qt6::GuiPrivate $<TARGET_NAME_IF_EXISTS:Qt6::QuickControls2> qt6ct-common)
target_link_libraries(qt6ct-qtplugin PRIVATE Qt6::Widgets Qt6::GuiPrivate $<TARGET_NAME_IF_EXISTS:Qt6::QuickControls2> $<TARGET_NAME_IF_EXISTS:KF6::IconThemes> qt6ct-common)
target_compile_definitions(qt6ct-qtplugin PRIVATE $<$<TARGET_EXISTS:KF6::IconThemes>:KF_ICONTHEMES_LIB>)
install(TARGETS qt6ct-qtplugin DESTINATION ${PLUGINDIR}/platformthemes)
12 changes: 12 additions & 0 deletions src/qt6ct-qtplugin/qt6ctplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
#include <QStringList>
#include <qpa/qplatformthemefactory_p.h>

#ifdef KF_ICONTHEMES_LIB
#include <KIconEngine>
#include <KIconLoader>
#endif

Q_LOGGING_CATEGORY(lqt6ct, "qt6ct", QtWarningMsg)

//QT_QPA_PLATFORMTHEME=qt6ct
Expand Down Expand Up @@ -161,6 +166,13 @@ QIcon Qt6CTPlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::Ic
return QIcon::fromTheme(type.iconName());
}

#ifdef KF_ICONTHEMES_LIB
QIconEngine *Qt6CTPlatformTheme::createIconEngine(const QString &iconName) const
{
return new KIconEngine(iconName, KIconLoader::global());
}
#endif

void Qt6CTPlatformTheme::applySettings()
{
if(!QGuiApplication::desktopSettingsAware() || m_isIgnored)
Expand Down
4 changes: 3 additions & 1 deletion src/qt6ct-qtplugin/qt6ctplatformtheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class Qt6CTPlatformTheme : public QObject, public QGenericUnixTheme
//virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
// QPlatformTheme::IconOptions iconOptions = 0) const;

//virtual QIconEngine *createIconEngine(const QString &iconName) const;
#ifdef KF_ICONTHEMES_LIB
virtual QIconEngine *createIconEngine(const QString &iconName) const override;
#endif
//virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
//virtual QString standardButtonText(int button) const;

Expand Down

0 comments on commit 280b5f5

Please sign in to comment.