Icon theme management
Closed, ResolvedPublic

Description

Currently (version 15.12), to make icon theme adjust to the color theme, we have included all icons in Kdenlive's git with a prefix (lt_ for light icons and dk_ for dark icons) and use a custom KoIcon::themedIcon function. This is far from ideal but was at the time the only way to dynamically change icons.

Since Qt5.5.1 and KF5 5.16 (or 5.17 not sure), we can now use a simple Qt feature: QIcon::setThemeName that will change the icon theme on the fly. So we can now create Icon Themes as Qt resources - keeping the original icon names. These themes can simply contain the Kdenlive specific icons that are not in Breeze and inherit icons from the official Breeze theme. That is a much cleaner and simpler way to manage the icon theme problem.

However, it required Qt5.5, so we want to wait until it is more widespread before making the switch.
Update august 2018: this is now done in the refactoring branch

mardelle created this task.Dec 29 2015, 5:41 PM
mardelle updated the task description. (Show Details)
mardelle raised the priority of this task from to Needs Triage.
mardelle claimed this task.
mardelle added a project: Kdenlive.
mardelle moved this task to In Progress on the Kdenlive board.
mardelle added a subscriber: mardelle.

Patch is basically something like:

//////////

@@ -216,7 +217,7 @@ qt5_add_dbus_adaptor(kdenlive_SRCS

mainwindow.h
MainWindow

)
-qt5_add_resources(kdenlive_SRCS ui/resources.qrc uiresources.qrc)
+qt5_add_resources(kdenlive_SRCS ui/resources.qrc uiresources.qrc iconresources.qrc)
add_executable(kdenlive

${kdenlive_SRCS}
${kdenlive_UIS}

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index bf8cf21..7834870 100644

  • a/src/mainwindow.cpp

+++ b/src/mainwindow.cpp
@@ -143,6 +143,8 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &

qRegisterMetaType<audioByteArray> ("audioByteArray");
qRegisterMetaType< QVector <int> > ();
qRegisterMetaType<requestClipInfo> ("requestClipInfo");

+
+ QIcon::setThemeName("kbreeze");

Core::build(this);
KActionMenu *themeAction= new KActionMenu(i18n("Theme"), this);

@@ -461,6 +463,10 @@ void MainWindow::slotThemeChanged(const QString &theme)

QPalette plt = palette();
 
KdenliveSettings::setColortheme(theme);

+ QColor background = qApp->palette().window().color();
+ bool useDarkIcons = background.value() < 100;
+ QIcon::setThemeName(useDarkIcons ? "kbreeze-dark" : "kbreeze");
+

if (m_effectStack) {
    m_effectStack->updatePalette()

///////////

Then we can use the official QIcon::fromTheme function to create icons. The 2 custom icon themes are called "kbreeze" and "kbreeze-dark", and contain the following index.theme file:

////
[Icon Theme]
Name=kbreeze

DisplayDepth=32

Inherits=breeze

  1. Directories
  2. ordered by category and alphabetically

Directories=actions/22

[actions/22]
Size=22
Context=Actions
Type=Fixed

EOF

//////////

The icon theme resources file, iconresources.qrc is like this:

//

<RCC>

<qresource>
  <file>icons/kbreeze/index.theme</file>
  <file>icons/kbreeze/actions/22/audio-volume-muted.svg</file>

  <file>icons/kbreeze-dark/index.theme</file>
  <file>icons/kbreeze-dark/actions/22/audio-volume-muted.svg</file>
  </qresource>

</RCC>

/////

mardelle updated the task description. (Show Details)Dec 29 2015, 5:50 PM

Since KDE Frameworks 5.23, icons automatically adjust to text's color, making things much easier.
We just need to put our icons in a qrc resource, and add some style info (see breeze icons for reference).
Currently implemented for a few icons in git master

More infos about KDE framework's icon auto color:
http://notmart.org/blog/2016/05/icon-colors/

jessed added a subscriber: jessed.Jun 15 2016, 6:31 PM

I think Farid brought this up in one of the bugs, recently (or maybe the mailing list). It looks like the oxygen-icons package is required (at least, in Ubuntu-based distros) for Kdenlive, otherwise there's no icons in the layout interface.

Does Kdenlive need oxygen? Shouldn't Breeze suffice? I'm asking because getting rid of another dependency that Kdenlive doesn't always install by default would probably be a good step towards better stability.

frdbr added a subscriber: frdbr.Jun 16 2016, 1:52 AM

I recently did a fresh install of archlinux and kdenlive didn't have icons in the interface... so i had to install oxygen-icons. There should be at least a guideline od dependencies for packagers so we can guarantee a similar experience across all distros.

Farid, which KDE Frameworks version ? When using KDE Frameworks 5.23, it is normal to have no icons using git master because I am currently reviewing our icon handling to use new features

frdbr added a comment.Jun 16 2016, 8:27 PM

It is 5.22 and kdenlive 16.04.1.

In Kdenlive 16.08.2 on Ubuntu 16.10 (Unity 7.5.0 desktop), the layout and interface looks 90% uniform to Kdenlive in its native KDE environment. There are still icons in the "Open" dialog box, the "Render" dialog box, and a few text fields that are still showing the light-theme icons in Breeze dark theme.

mardelle closed this task as Resolved.Aug 9 2018, 7:11 AM
mardelle updated the task description. (Show Details)