This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Icon does not change color depending on theme

Tags: None
(comma "," separated)
allemensen
Registered Member
Posts
9
Karma
0
OS
I tried to make my plasmoid icon change depending on the theme, like described here: http://notmart.org/blog/2016/02/plasma- ... -you-like/

I cannot get it to work, however. It keeps displaying the color set in the file (which is red so I notice it). I have the following qml (simplified somewhat):
Code: Select all
Item {
        Plasmoid.icon: 'tijink-todo'
}

Note that the code works if I use an already exiting icon, like 'kmail'.

The icon is installed to /usr/local/icons/hicolor/scalable/apps/tijink-todo.svgz, and its decompressed content is
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.0" height="32" width="32">
  <defs id="defs3">
    <style id="current-color-scheme" type="text/css">
      .ColorScheme-Text {
        color:#ff0000;
      }
      .ColorScheme-Background {
        color:#eff0f1;
      }
      .ColorScheme-Highlight {
        color:#3daee9;
      }
      .ColorScheme-ViewText {
        color:#31363b;
      }
      .ColorScheme-ViewBackground {
        color:#fcfcfc;
      }
      .ColorScheme-ViewHover {
        color:#93cee9;
      }
      .ColorScheme-ViewFocus{
        color:#3daee9;
      }
      .ColorScheme-ButtonText {
        color:#31363b;
      }
      .ColorScheme-ButtonBackground {
        color:#eff0f1;
      }
      .ColorScheme-ButtonHover {
        color:#93cee9;
      }
      .ColorScheme-ButtonFocus{
        color:#3daee9;
      }
    </style>
  </defs>
  <path id="path5" class="ColorScheme-Text" d="m 24.839583,6.0000399 c -0.268755,5.86e-4 -0.525966,0.109307 -0.713648,0.301664 0,0 -7.550619,7.7402591 -10.527574,10.7917031 -2.203855,-2.258636 -5.724752,-5.867574 -5.724752,-5.867574 -0.3924213,-0.402104 -1.0389947,-0.402104 -1.431416,0 l -3.1580893,3.237282 c -0.3787854,0.388568 -0.3785774,1.008313 4.68e-4,1.396626 l 9.5983213,9.838644 c 0.392421,0.402103 1.038994,0.402103 1.431415,0 L 28.715897,10.935156 c 0.378784,-0.388568 0.378576,-1.0083151 -4.69e-4,-1.3966281 L 25.557351,6.3017039 C 25.368668,6.1083179 25.109765,5.9995064 24.839583,6.0000399 Z" style="fill:currentColor;fill-opacity:1;stroke:none" />
</svg>


Can somebody see what the problem is and help me fix it? I tried various thing already (like moving the icon to plasma/desktoptheme/default/icons), but might have done something wrong in the process.
allemensen
Registered Member
Posts
9
Karma
0
OS
I solved the problem! There were two issues with my icon: its name should not contain dashes and it should be installed to /usr/share/plasma/desktopstyle/default/icons (or similar, if your distribution uses different paths).

Besides that, I discovered how to pack multiple icons in one file: if your svg file contains multiple groups, each with an id like "{filename}-{subicon}", you can simply set a qml icon to that id and it works. If you do that, note that plasma computes the bounding box of your subicon, so add an invisible rect to maintain the correct size. Example for my icon:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="22" width="22" viewBox="0 0 22 22">
  <defs>
    <style id="current-color-scheme" type="text/css">
      .ColorScheme-Text {
        color:#ff0000;
      }
    </style>
  </defs>
  <g id="tijinktodo">
    <rect x="0" y="0" width="22" height="22" style="fill:none;stroke:none" />
    <path d="m 17.077213,4.1250271 c -0.184769,4.029e-4 -0.361601,0.075148 -0.490633,0.207394 0,0 -5.19105,5.3214276 -7.2377068,7.4192959 C 7.8337231,10.198905 5.4131065,7.7177599 5.4131065,7.7177599 c -0.2697897,-0.2764465 -0.714309,-0.2764465 -0.9840986,0 L 2.2578215,9.9433907 c -0.260415,0.2671413 -0.260272,0.6932163 3.218e-4,0.9601813 l 6.5988459,6.764068 c 0.269789,0.276446 0.714308,0.276446 0.984098,0 L 19.742179,7.5179195 C 20.002593,7.250779 20.00245,6.8247029 19.741857,6.5577376 L 17.570679,4.3324211 C 17.440959,4.1994682 17.262964,4.1246604 17.077213,4.1250271 Z" style="fill:#00bb00;stroke:none;" />
  </g>
  <g id="tijinktodo-monochrome" transform="translate(0,22)">
    <rect x="0" y="0" width="22" height="22" style="fill:none;stroke:none" />
    <path style="fill:currentColor;stroke:none" d="m 17.077213,26.125027 c -0.184769,4.03e-4 -0.361601,0.07515 -0.490633,0.207394 0,0 -5.19105,5.321428 -7.2377068,7.419296 C 7.8337231,32.198905 5.4131065,29.71776 5.4131065,29.71776 c -0.2697897,-0.276447 -0.714309,-0.276447 -0.9840986,0 l -2.1711864,2.225631 c -0.260415,0.267141 -0.260272,0.693216 3.218e-4,0.960181 l 6.5988459,6.764068 c 0.269789,0.276446 0.714308,0.276446 0.984098,0 L 19.742179,29.517919 c 0.260414,-0.26714 0.260271,-0.693216 -3.22e-4,-0.960181 l -2.171178,-2.225317 c -0.12972,-0.132953 -0.307715,-0.207761 -0.493466,-0.207394 z" class="ColorScheme-Text" transform="translate(0,-22)" />
  </g>
</svg>


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]